-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: instead scheduler type string of types.CheckerSchedulerType #8485
Changes from 9 commits
ede4112
d48eaa0
915e6ba
fdd8821
1f20ae6
3ada3f5
912cde3
95fc46b
43a5eb1
d227f56
87acf7f
f91836a
7d38383
25f5f1a
bdb4d19
afc4fbe
f9362a0
ebcc655
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
"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/statistics" | ||
"github.com/tikv/pd/pkg/statistics/utils" | ||
"github.com/tikv/pd/pkg/utils/logutil" | ||
|
@@ -187,7 +188,7 @@ | |
// If the cluster was set up with `raft-kv2` engine, this cluster should | ||
// enable `evict-slow-trend` scheduler as default. | ||
if c.GetCluster().GetStoreConfig().IsRaftKV2() { | ||
typ := schedulers.EvictSlowTrendType | ||
typ := types.EvictSlowTrendScheduler | ||
args := []string{} | ||
|
||
s, err := schedulers.CreateScheduler(typ, c.opController, c.cluster.GetStorage(), schedulers.ConfigSliceDecoder(typ, args), c.schedulers.RemoveScheduler) | ||
|
@@ -275,7 +276,7 @@ | |
typ := schedulers.FindSchedulerTypeByName(name) | ||
var cfg sc.SchedulerConfig | ||
for _, c := range scheduleCfg.Schedulers { | ||
if c.Type == typ { | ||
if c.Type == types.SchedulerTypeCompatibleMap[typ] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about renaming to |
||
cfg = c | ||
break | ||
} | ||
|
@@ -288,20 +289,23 @@ | |
log.Info("skip create scheduler with independent configuration", zap.String("scheduler-name", name), zap.String("scheduler-type", cfg.Type), zap.Strings("scheduler-args", cfg.Args)) | ||
continue | ||
} | ||
s, err := schedulers.CreateScheduler(cfg.Type, c.opController, c.cluster.GetStorage(), schedulers.ConfigJSONDecoder([]byte(data)), c.schedulers.RemoveScheduler) | ||
s, err := schedulers.CreateScheduler(types.ConvertOldStr2Type[cfg.Type], c.opController, | ||
c.cluster.GetStorage(), schedulers.ConfigJSONDecoder([]byte(data)), c.schedulers.RemoveScheduler) | ||
if err != nil { | ||
log.Error("can not create scheduler with independent configuration", zap.String("scheduler-name", name), zap.Strings("scheduler-args", cfg.Args), errs.ZapError(err)) | ||
continue | ||
} | ||
if needRun { | ||
log.Info("create scheduler with independent configuration", zap.String("scheduler-name", s.GetName())) | ||
if err = c.schedulers.AddScheduler(s); err != nil { | ||
log.Error("can not add scheduler with independent configuration", zap.String("scheduler-name", s.GetName()), zap.Strings("scheduler-args", cfg.Args), errs.ZapError(err)) | ||
log.Error("can not add scheduler with independent configuration", | ||
zap.String("scheduler-name", s.GetName()), zap.Strings("scheduler-args", cfg.Args), errs.ZapError(err)) | ||
} | ||
} else { | ||
log.Info("create scheduler handler with independent configuration", zap.String("scheduler-name", s.GetName())) | ||
if err = c.schedulers.AddSchedulerHandler(s); err != nil { | ||
log.Error("can not add scheduler handler with independent configuration", zap.String("scheduler-name", s.GetName()), zap.Strings("scheduler-args", cfg.Args), errs.ZapError(err)) | ||
log.Error("can not add scheduler handler with independent configuration", | ||
zap.String("scheduler-name", s.GetName()), zap.Strings("scheduler-args", cfg.Args), errs.ZapError(err)) | ||
} | ||
} | ||
} | ||
|
@@ -316,16 +320,22 @@ | |
continue | ||
} | ||
|
||
s, err := schedulers.CreateScheduler(schedulerCfg.Type, c.opController, c.cluster.GetStorage(), schedulers.ConfigSliceDecoder(schedulerCfg.Type, schedulerCfg.Args), c.schedulers.RemoveScheduler) | ||
tp := types.ConvertOldStr2Type[schedulerCfg.Type] | ||
s, err := schedulers.CreateScheduler(tp, c.opController, | ||
c.cluster.GetStorage(), schedulers.ConfigSliceDecoder(tp, schedulerCfg.Args), c.schedulers.RemoveScheduler) | ||
if err != nil { | ||
log.Error("can not create scheduler", zap.String("scheduler-type", schedulerCfg.Type), zap.Strings("scheduler-args", schedulerCfg.Args), errs.ZapError(err)) | ||
log.Error("can not create scheduler", zap.Stringer("type", tp), zap.String("scheduler-type", schedulerCfg.Type), | ||
zap.Strings("scheduler-args", schedulerCfg.Args), errs.ZapError(err)) | ||
continue | ||
} | ||
|
||
if needRun { | ||
log.Info("create scheduler", zap.String("scheduler-name", s.GetName()), zap.Strings("scheduler-args", schedulerCfg.Args)) | ||
if err = c.schedulers.AddScheduler(s, schedulerCfg.Args...); err != nil && !errors.ErrorEqual(err, errs.ErrSchedulerExisted.FastGenByArgs()) { | ||
log.Error("can not add scheduler", zap.String("scheduler-name", s.GetName()), zap.Strings("scheduler-args", schedulerCfg.Args), errs.ZapError(err)) | ||
log.Info("create scheduler", zap.String("scheduler-name", s.GetName()), | ||
zap.Strings("scheduler-args", schedulerCfg.Args)) | ||
if err = c.schedulers.AddScheduler(s, schedulerCfg.Args...); err != nil && | ||
!errors.ErrorEqual(err, errs.ErrSchedulerExisted.FastGenByArgs()) { | ||
log.Error("can not add scheduler", zap.String("scheduler-name", | ||
s.GetName()), zap.Strings("scheduler-args", schedulerCfg.Args), errs.ZapError(err)) | ||
} else { | ||
// Only records the valid scheduler config. | ||
scheduleCfg.Schedulers[k] = schedulerCfg | ||
|
@@ -362,7 +372,7 @@ | |
log.Error("GetFunction SchedulerType error", errs.ZapError(err)) | ||
return | ||
} | ||
schedulerType := SchedulerType.(func() string) | ||
schedulerType := SchedulerType.(func() types.CheckerSchedulerType) | ||
// get func: SchedulerArgs from plugin | ||
SchedulerArgs, err := c.pluginInterface.GetFunction(pluginPath, "SchedulerArgs") | ||
if err != nil { | ||
|
@@ -373,7 +383,7 @@ | |
// create and add user scheduler | ||
s, err := schedulers.CreateScheduler(schedulerType(), c.opController, c.cluster.GetStorage(), schedulers.ConfigSliceDecoder(schedulerType(), schedulerArgs()), c.schedulers.RemoveScheduler) | ||
if err != nil { | ||
log.Error("can not create scheduler", zap.String("scheduler-type", schedulerType()), errs.ZapError(err)) | ||
log.Error("can not create scheduler", zap.Stringer("scheduler-type", schedulerType()), errs.ZapError(err)) | ||
return | ||
} | ||
log.Info("create scheduler", zap.String("scheduler-name", s.GetName())) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,8 +43,6 @@ import ( | |
const ( | ||
// BalanceLeaderName is balance leader scheduler name. | ||
BalanceLeaderName = "balance-leader-scheduler" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we will unify it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will be in the next pr |
||
// BalanceLeaderType is balance leader scheduler type. | ||
BalanceLeaderType = "balance-leader" | ||
// 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. | ||
|
@@ -536,7 +534,7 @@ func (l *balanceLeaderScheduler) createOperator(solver *solver, collector *plan. | |
} | ||
solver.Step++ | ||
defer func() { solver.Step-- }() | ||
op, err := operator.CreateTransferLeaderOperator(BalanceLeaderType, solver, solver.Region, solver.targetStoreID(), []uint64{}, operator.OpLeader) | ||
op, err := operator.CreateTransferLeaderOperator(l.GetName(), solver, solver.Region, solver.targetStoreID(), []uint64{}, operator.OpLeader) | ||
if err != nil { | ||
log.Debug("fail to create balance leader operator", errs.ZapError(err)) | ||
if collector != nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does ConvertOldStrToType sound to you? Variable names with embedded numbers are not common in PD.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are same for me. I can update it