Skip to content

Commit

Permalink
schedule: add enable-joint-consensus config (#2955)
Browse files Browse the repository at this point in the history
Signed-off-by: Zheng Xiangsheng <hundundm@gmail.com>
  • Loading branch information
HunDunDM authored Sep 15, 2020
1 parent c46184e commit 5d04a6a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,8 @@ type ScheduleConfig struct {
EnableLocationReplacement bool `toml:"enable-location-replacement" json:"enable-location-replacement,string"`
// EnableDebugMetrics is the option to enable debug metrics.
EnableDebugMetrics bool `toml:"enable-debug-metrics" json:"enable-debug-metrics,string"`
// EnableJointConsensus is the option to enable using joint consensus as a operator step.
EnableJointConsensus bool `toml:"enable-joint-consensus" json:"enable-joint-consensus,string"`

// Schedulers support for loading customized schedulers
Schedulers SchedulerConfigs `toml:"schedulers" json:"schedulers-v2"` // json v2 is for the sake of compatible upgrade
Expand Down Expand Up @@ -727,6 +729,7 @@ func (c *ScheduleConfig) Clone() *ScheduleConfig {
EnableRemoveExtraReplica: c.EnableRemoveExtraReplica,
EnableLocationReplacement: c.EnableLocationReplacement,
EnableDebugMetrics: c.EnableDebugMetrics,
EnableJointConsensus: c.EnableJointConsensus,
StoreLimitMode: c.StoreLimitMode,
Schedulers: schedulers,
}
Expand Down Expand Up @@ -755,6 +758,7 @@ const (
defaultSchedulerMaxWaitingOperator = 5
defaultLeaderSchedulePolicy = "count"
defaultStoreLimitMode = "manual"
defaultEnableJointConsensus = true
)

func (c *ScheduleConfig) adjust(meta *configMetaData) error {
Expand Down Expand Up @@ -803,6 +807,9 @@ func (c *ScheduleConfig) adjust(meta *configMetaData) error {
if !meta.IsDefined("store-limit-mode") {
adjustString(&c.StoreLimitMode, defaultStoreLimitMode)
}
if !meta.IsDefined("enable-joint-consensus") {
c.EnableJointConsensus = defaultEnableJointConsensus
}
adjustFloat64(&c.LowSpaceRatio, defaultLowSpaceRatio)
adjustFloat64(&c.HighSpaceRatio, defaultHighSpaceRatio)

Expand Down
7 changes: 6 additions & 1 deletion server/config/persist_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,16 @@ func (o *PersistOptions) IsLocationReplacementEnabled() bool {
return o.GetScheduleConfig().EnableLocationReplacement
}

// IsDebugMetricsEnabled mocks method
// IsDebugMetricsEnabled returns if debug metrics is enabled.
func (o *PersistOptions) IsDebugMetricsEnabled() bool {
return o.GetScheduleConfig().EnableDebugMetrics
}

// IsUseJointConsensus returns if using joint consensus as a operator step is enabled.
func (o *PersistOptions) IsUseJointConsensus() bool {
return o.GetScheduleConfig().EnableJointConsensus
}

// GetHotRegionCacheHitsThreshold is a threshold to decide if a region is hot.
func (o *PersistOptions) GetHotRegionCacheHitsThreshold() int {
return int(o.GetScheduleConfig().HotRegionCacheHitsThreshold)
Expand Down
2 changes: 1 addition & 1 deletion server/schedule/operator/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func NewBuilder(desc string, cluster opt.Cluster, region *core.RegionInfo, opts
b.originLeaderStoreID = originLeaderStoreID
b.targetPeers = originPeers.Copy()
b.allowDemote = supportJointConsensus
b.useJointConsensus = supportJointConsensus
b.useJointConsensus = supportJointConsensus && cluster.GetOpts().IsUseJointConsensus()
b.err = err
return b
}
Expand Down

0 comments on commit 5d04a6a

Please sign in to comment.