-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resourcemanger: create cpu monitor (#39962)
ref #39657
- Loading branch information
1 parent
97a9e63
commit 53572f8
Showing
5 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "resourcemanage", | ||
srcs = ["rm.go"], | ||
importpath = "github.com/pingcap/tidb/resourcemanager", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//util", | ||
"//util/cpu", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2022 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package resourcemanager | ||
|
||
import ( | ||
tidbutil "github.com/pingcap/tidb/util" | ||
"github.com/pingcap/tidb/util/cpu" | ||
) | ||
|
||
// GlobalResourceManager is a global resource manager | ||
var GlobalResourceManager = NewResourceManger() | ||
|
||
// ResourceManager is a resource manager | ||
type ResourceManager struct { | ||
cpuObserver *cpu.Observer | ||
wg tidbutil.WaitGroupWrapper | ||
} | ||
|
||
// NewResourceManger is to create a new resource manager | ||
func NewResourceManger() *ResourceManager { | ||
return &ResourceManager{ | ||
cpuObserver: cpu.NewCPUObserver(), | ||
} | ||
} | ||
|
||
// Start is to start resource manager | ||
func (r *ResourceManager) Start() { | ||
r.wg.Run(r.cpuObserver.Start) | ||
} | ||
|
||
// Stop is to stop resource manager | ||
func (r *ResourceManager) Stop() { | ||
r.cpuObserver.Stop() | ||
r.wg.Done() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters