Skip to content

Commit

Permalink
scheduler: remove old scheduler name (#8516)
Browse files Browse the repository at this point in the history
ref #8379

Signed-off-by: okJiang <[email protected]>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
okJiang and ti-chi-bot[bot] authored Aug 21, 2024
1 parent 9c14c63 commit ce1d0e8
Show file tree
Hide file tree
Showing 56 changed files with 164 additions and 218 deletions.
2 changes: 1 addition & 1 deletion pkg/mcs/scheduling/server/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/tikv/pd/pkg/schedule/scatter"
"github.com/tikv/pd/pkg/schedule/schedulers"
"github.com/tikv/pd/pkg/schedule/splitter"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/slice"
"github.com/tikv/pd/pkg/statistics"
"github.com/tikv/pd/pkg/statistics/buckets"
Expand Down
2 changes: 1 addition & 1 deletion pkg/mcs/scheduling/server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"github.com/tikv/pd/pkg/core/storelimit"
mcsconstant "github.com/tikv/pd/pkg/mcs/utils/constant"
sc "github.com/tikv/pd/pkg/schedule/config"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/slice"
"github.com/tikv/pd/pkg/storage/endpoint"
"github.com/tikv/pd/pkg/utils/configutil"
Expand Down
2 changes: 1 addition & 1 deletion pkg/mock/mockconfig/mockconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package mockconfig

import (
sc "github.com/tikv/pd/pkg/schedule/config"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/server/config"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/checker/merge_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/tikv/pd/pkg/schedule/labeler"
"github.com/tikv/pd/pkg/schedule/operator"
"github.com/tikv/pd/pkg/schedule/placement"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/utils/logutil"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/checker/replica_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/tikv/pd/pkg/schedule/config"
sche "github.com/tikv/pd/pkg/schedule/core"
"github.com/tikv/pd/pkg/schedule/operator"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/checker/rule_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/tikv/pd/pkg/schedule/filter"
"github.com/tikv/pd/pkg/schedule/operator"
"github.com/tikv/pd/pkg/schedule/placement"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/versioninfo"
"go.uber.org/zap"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/pingcap/errors"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/tikv/pd/pkg/core/storelimit"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/utils/configutil"
"github.com/tikv/pd/pkg/utils/syncutil"
"github.com/tikv/pd/pkg/utils/typeutil"
Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/config/config_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/tikv/pd/pkg/core/constant"
"github.com/tikv/pd/pkg/core/storelimit"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/storage/endpoint"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/schedule/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"github.com/tikv/pd/pkg/schedule/scatter"
"github.com/tikv/pd/pkg/schedule/schedulers"
"github.com/tikv/pd/pkg/schedule/splitter"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/statistics"
"github.com/tikv/pd/pkg/statistics/utils"
"github.com/tikv/pd/pkg/utils/logutil"
Expand Down Expand Up @@ -182,7 +182,7 @@ func (c *Coordinator) driveSlowNodeScheduler() {
case <-ticker.C:
{
// If enabled, exit.
if exists, _ := c.schedulers.IsSchedulerExisted(schedulers.EvictSlowTrendName); exists {
if exists, _ := c.schedulers.IsSchedulerExisted(types.EvictSlowTrendScheduler.String()); exists {
return
}
// If the cluster was set up with `raft-kv2` engine, this cluster should
Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/filter/counter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
)

func TestString(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion pkg/schedule/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/tikv/pd/pkg/schedule/placement"
"github.com/tikv/pd/pkg/schedule/scatter"
"github.com/tikv/pd/pkg/schedule/schedulers"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/statistics"
"github.com/tikv/pd/pkg/statistics/buckets"
"github.com/tikv/pd/pkg/statistics/utils"
Expand Down Expand Up @@ -884,7 +885,8 @@ func (h *Handler) GetSchedulerByStatus(status string, needTS bool) (any, error)

// GetDiagnosticResult returns the diagnostic results of the specified scheduler.
func (h *Handler) GetDiagnosticResult(name string) (*schedulers.DiagnosticResult, error) {
if _, ok := schedulers.DiagnosableSummaryFunc[name]; !ok {
tp := types.StringToSchedulerType[name]
if _, ok := schedulers.DiagnosableSummaryFunc[tp]; !ok {
return nil, errs.ErrSchedulerUndiagnosable.FastGenByArgs(name)
}
co := h.GetCoordinator()
Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/operator/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package operator

import (
"github.com/prometheus/client_golang/prometheus"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
)

var (
Expand Down
4 changes: 1 addition & 3 deletions pkg/schedule/schedulers/balance_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/tikv/pd/pkg/schedule/filter"
"github.com/tikv/pd/pkg/schedule/operator"
"github.com/tikv/pd/pkg/schedule/plan"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/utils/reflectutil"
"github.com/tikv/pd/pkg/utils/syncutil"
"github.com/tikv/pd/pkg/utils/typeutil"
Expand All @@ -40,8 +40,6 @@ import (
)

const (
// BalanceLeaderName is balance leader scheduler name.
BalanceLeaderName = "balance-leader-scheduler"
// BalanceLeaderBatchSize is the default number of operators to transfer leaders by one scheduling.
// Default value is 4 which is subjected by scheduler-max-waiting-operator and leader-schedule-limit
// If you want to increase balance speed more, please increase above-mentioned param.
Expand Down
7 changes: 1 addition & 6 deletions pkg/schedule/schedulers/balance_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,10 @@ import (
"github.com/tikv/pd/pkg/schedule/filter"
"github.com/tikv/pd/pkg/schedule/operator"
"github.com/tikv/pd/pkg/schedule/plan"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"go.uber.org/zap"
)

const (
// BalanceRegionName is balance region scheduler name.
BalanceRegionName = "balance-region-scheduler"
)

type balanceRegionSchedulerConfig struct {
Ranges []core.KeyRange `json:"ranges"`
// TODO: When we prepare to use Ranges, we will need to implement the ReloadConfig function for this scheduler.
Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/schedulers/balance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/tikv/pd/pkg/schedule/config"
"github.com/tikv/pd/pkg/schedule/operator"
"github.com/tikv/pd/pkg/schedule/plan"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/storage"
"github.com/tikv/pd/pkg/utils/operatorutil"
"github.com/tikv/pd/pkg/versioninfo"
Expand Down
4 changes: 1 addition & 3 deletions pkg/schedule/schedulers/balance_witness.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ import (
"github.com/tikv/pd/pkg/schedule/filter"
"github.com/tikv/pd/pkg/schedule/operator"
"github.com/tikv/pd/pkg/schedule/plan"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/utils/reflectutil"
"github.com/tikv/pd/pkg/utils/syncutil"
"github.com/unrolled/render"
"go.uber.org/zap"
)

const (
// BalanceWitnessName is balance witness scheduler name.
BalanceWitnessName = "balance-witness-scheduler"
// balanceWitnessBatchSize is the default number of operators to transfer witnesses by one scheduling.
// Default value is 4 which is subjected by scheduler-max-waiting-operator and witness-schedule-limit
// If you want to increase balance speed more, please increase above-mentioned param.
Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/schedulers/balance_witness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/tikv/pd/pkg/schedule/config"
"github.com/tikv/pd/pkg/schedule/operator"
"github.com/tikv/pd/pkg/schedule/placement"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/storage"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/schedulers/base_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/tikv/pd/pkg/errs"
sche "github.com/tikv/pd/pkg/schedule/core"
"github.com/tikv/pd/pkg/schedule/operator"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/utils/typeutil"
)

Expand Down
36 changes: 22 additions & 14 deletions pkg/schedule/schedulers/diagnostic_recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
sc "github.com/tikv/pd/pkg/schedule/config"
"github.com/tikv/pd/pkg/schedule/operator"
"github.com/tikv/pd/pkg/schedule/plan"
"github.com/tikv/pd/pkg/schedule/types"
)

const (
Expand All @@ -46,27 +47,27 @@ const (

// DiagnosableSummaryFunc includes all implementations of plan.Summary.
// And it also includes all schedulers which pd support to diagnose.
var DiagnosableSummaryFunc = map[string]plan.Summary{
BalanceRegionName: plan.BalancePlanSummary,
BalanceLeaderName: plan.BalancePlanSummary,
var DiagnosableSummaryFunc = map[types.CheckerSchedulerType]plan.Summary{
types.BalanceRegionScheduler: plan.BalancePlanSummary,
types.BalanceLeaderScheduler: plan.BalancePlanSummary,
}

// DiagnosticRecorder is used to manage diagnostic for one scheduler.
type DiagnosticRecorder struct {
schedulerName string
schedulerType types.CheckerSchedulerType
config sc.SchedulerConfigProvider
summaryFunc plan.Summary
results *cache.FIFO
}

// NewDiagnosticRecorder creates a new DiagnosticRecorder.
func NewDiagnosticRecorder(name string, config sc.SchedulerConfigProvider) *DiagnosticRecorder {
summaryFunc, ok := DiagnosableSummaryFunc[name]
func NewDiagnosticRecorder(tp types.CheckerSchedulerType, config sc.SchedulerConfigProvider) *DiagnosticRecorder {
summaryFunc, ok := DiagnosableSummaryFunc[tp]
if !ok {
return nil
}
return &DiagnosticRecorder{
schedulerName: name,
schedulerType: tp,
config: config,
summaryFunc: summaryFunc,
results: cache.NewFIFO(maxDiagnosticResultNum),
Expand Down Expand Up @@ -131,11 +132,11 @@ func (d *DiagnosticRecorder) GetLastResult() *DiagnosticResult {
}
} else if firstStatus == Pending {
// This is used to handle pending status because of reach limit in `IsScheduleAllowed`
resStr = fmt.Sprintf("%s reach limit", d.schedulerName)
resStr = fmt.Sprintf("%v reach limit", d.schedulerType)
}
}
return &DiagnosticResult{
Name: d.schedulerName,
Name: d.schedulerType.String(),
Status: firstStatus,
Summary: resStr,
Timestamp: uint64(time.Now().Unix()),
Expand All @@ -147,7 +148,11 @@ func (d *DiagnosticRecorder) SetResultFromStatus(status string) {
if d == nil {
return
}
result := &DiagnosticResult{Name: d.schedulerName, Timestamp: uint64(time.Now().Unix()), Status: status}
result := &DiagnosticResult{
Name: d.schedulerType.String(),
Timestamp: uint64(time.Now().Unix()),
Status: status,
}
d.results.Put(result.Timestamp, result)
}

Expand All @@ -161,11 +166,14 @@ func (d *DiagnosticRecorder) SetResultFromPlans(ops []*operator.Operator, plans
}

func (d *DiagnosticRecorder) analyze(ops []*operator.Operator, plans []plan.Plan, ts uint64) *DiagnosticResult {
res := &DiagnosticResult{Name: d.schedulerName, Timestamp: ts, Status: Normal}
name := d.schedulerName
res := &DiagnosticResult{
Name: d.schedulerType.String(),
Timestamp: ts,
Status: Normal,
}
// TODO: support more schedulers and checkers
switch name {
case BalanceRegionName, BalanceLeaderName:
switch d.schedulerType {
case types.BalanceRegionScheduler, types.BalanceLeaderScheduler:
if len(ops) != 0 {
res.Status = Scheduling
return res
Expand Down
6 changes: 2 additions & 4 deletions pkg/schedule/schedulers/evict_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@ import (
"github.com/tikv/pd/pkg/schedule/filter"
"github.com/tikv/pd/pkg/schedule/operator"
"github.com/tikv/pd/pkg/schedule/plan"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/utils/apiutil"
"github.com/tikv/pd/pkg/utils/syncutil"
"github.com/unrolled/render"
"go.uber.org/zap"
)

const (
// EvictLeaderName is evict leader scheduler name.
EvictLeaderName = "evict-leader-scheduler"
// EvictLeaderBatchSize is the number of operators to transfer
// leaders by one scheduling
EvictLeaderBatchSize = 3
Expand Down Expand Up @@ -212,7 +210,7 @@ func (conf *evictLeaderSchedulerConfig) delete(id uint64) (any, error) {
return resp, nil
}
conf.Unlock()
if err := conf.removeSchedulerCb(EvictLeaderName); err != nil {
if err := conf.removeSchedulerCb(types.EvictLeaderScheduler.String()); err != nil {
if !errors.ErrorEqual(err, errs.ErrSchedulerNotFound.FastGenByArgs()) {
conf.resetStore(id, keyRanges)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/schedulers/evict_leader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/tikv/pd/pkg/core"
"github.com/tikv/pd/pkg/schedule/operator"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/storage"
"github.com/tikv/pd/pkg/utils/operatorutil"
)
Expand Down
5 changes: 1 addition & 4 deletions pkg/schedule/schedulers/evict_slow_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@ import (
sche "github.com/tikv/pd/pkg/schedule/core"
"github.com/tikv/pd/pkg/schedule/operator"
"github.com/tikv/pd/pkg/schedule/plan"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/utils/apiutil"
"github.com/tikv/pd/pkg/utils/syncutil"
"github.com/unrolled/render"
"go.uber.org/zap"
)

const (
// EvictSlowStoreName is evict leader scheduler name.
EvictSlowStoreName = "evict-slow-store-scheduler"

slowStoreEvictThreshold = 100
slowStoreRecoverThreshold = 1
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/schedulers/evict_slow_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/tikv/pd/pkg/core"
"github.com/tikv/pd/pkg/mock/mockcluster"
"github.com/tikv/pd/pkg/schedule/operator"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/storage"
"github.com/tikv/pd/pkg/utils/operatorutil"
)
Expand Down
7 changes: 1 addition & 6 deletions pkg/schedule/schedulers/evict_slow_trend.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,13 @@ import (
sche "github.com/tikv/pd/pkg/schedule/core"
"github.com/tikv/pd/pkg/schedule/operator"
"github.com/tikv/pd/pkg/schedule/plan"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/utils/apiutil"
"github.com/tikv/pd/pkg/utils/syncutil"
"github.com/unrolled/render"
"go.uber.org/zap"
)

const (
// EvictSlowTrendName is evict leader by slow trend scheduler name.
EvictSlowTrendName = "evict-slow-trend-scheduler"
)

const (
alterEpsilon = 1e-9
minReCheckDurationGap = 120 // default gap for re-check the slow node, unit: s
Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/schedulers/evict_slow_trend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/tikv/pd/pkg/core"
"github.com/tikv/pd/pkg/mock/mockcluster"
"github.com/tikv/pd/pkg/schedule/operator"
types "github.com/tikv/pd/pkg/schedule/type"
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/storage"
"github.com/tikv/pd/pkg/utils/operatorutil"
)
Expand Down
Loading

0 comments on commit ce1d0e8

Please sign in to comment.