Skip to content

Commit

Permalink
remove GetPersistOptions for cluster
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed Aug 8, 2023
1 parent 6e36619 commit 619a97e
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 28 deletions.
5 changes: 0 additions & 5 deletions pkg/mcs/scheduling/server/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ func (c *Cluster) BucketsStats(degree int, regionIDs ...uint64) map[uint64][]*bu
return c.hotStat.BucketsStats(degree, regionIDs...)
}

// GetPersistOptions returns the persist options.
func (c *Cluster) GetPersistOptions() sc.ConfProvider {
return c.persistConfig
}

// TODO: implement the following methods

// GetStorage returns the storage.
Expand Down
5 changes: 0 additions & 5 deletions pkg/mock/mockcluster/mockcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ func (mc *Cluster) AllocID() (uint64, error) {
return mc.IDAllocator.Alloc()
}

// GetPersistOptions returns the persist options.
func (mc *Cluster) GetPersistOptions() sc.ConfProvider {
return mc.PersistOptions
}

// UpdateRegionsLabelLevelStats updates the label level stats for the regions.
func (mc *Cluster) UpdateRegionsLabelLevelStats(regions []*core.RegionInfo) {}

Expand Down
8 changes: 4 additions & 4 deletions pkg/schedule/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (c *Coordinator) PatrolRegions() {
}

func (c *Coordinator) isSchedulingHalted() bool {
return c.cluster.GetPersistOptions().IsSchedulingHalted()
return c.cluster.GetSchedulerConfig().IsSchedulingHalted()
}

func (c *Coordinator) checkRegions(startKey []byte) (key []byte, regions []*core.RegionInfo) {
Expand Down Expand Up @@ -376,7 +376,7 @@ func (c *Coordinator) initSchedulers() {
log.Fatal("cannot load schedulers' config", errs.ZapError(err))
}

scheduleCfg := c.cluster.GetPersistOptions().GetScheduleConfig().Clone()
scheduleCfg := c.cluster.GetSchedulerConfig().GetScheduleConfig().Clone()
// The new way to create scheduler with the independent configuration.
for i, name := range scheduleNames {
data := configs[i]
Expand Down Expand Up @@ -435,8 +435,8 @@ func (c *Coordinator) initSchedulers() {

// Removes the invalid scheduler config and persist.
scheduleCfg.Schedulers = scheduleCfg.Schedulers[:k]
c.cluster.GetPersistOptions().SetScheduleConfig(scheduleCfg)
if err := c.cluster.GetPersistOptions().Persist(c.cluster.GetStorage()); err != nil {
c.cluster.GetSchedulerConfig().SetScheduleConfig(scheduleCfg)
if err := c.cluster.GetSchedulerConfig().Persist(c.cluster.GetStorage()); err != nil {
log.Error("cannot persist schedule config", errs.ZapError(err))
}
}
Expand Down
1 change: 0 additions & 1 deletion pkg/schedule/core/cluster_informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type ClusterInformer interface {

GetStorage() storage.Storage
UpdateRegionsLabelLevelStats(regions []*core.RegionInfo)
GetPersistOptions() sc.ConfProvider
}

// SchedulerCluster is an aggregate interface that wraps multiple interfaces
Expand Down
4 changes: 2 additions & 2 deletions pkg/unsaferecovery/unsafe_recovery_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type cluster interface {
DropCacheAllRegion()
AllocID() (uint64, error)
BuryStore(storeID uint64, forceBury bool) error
GetPersistOptions() sc.ConfProvider
GetSchedulerConfig() sc.SchedulerConfigProvider
}

// Controller is used to control the unsafe recovery process.
Expand Down Expand Up @@ -493,7 +493,7 @@ func (u *Controller) changeStage(stage stage) {
u.stage = stage
// Halt and resume the scheduling once the running state changed.
running := isRunning(stage)
if opt := u.cluster.GetPersistOptions(); opt.IsSchedulingHalted() != running {
if opt := u.cluster.GetSchedulerConfig(); opt.IsSchedulingHalted() != running {
opt.SetHaltScheduling(running, "online-unsafe-recovery")
}

Expand Down
5 changes: 0 additions & 5 deletions server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,11 +758,6 @@ func (c *RaftCluster) GetOpts() sc.ConfProvider {
return c.opt
}

// GetPersistOptions returns cluster's configuration.
func (c *RaftCluster) GetPersistOptions() sc.ConfProvider {
return c.opt
}

// GetScheduleConfig returns scheduling configurations.
func (c *RaftCluster) GetScheduleConfig() *sc.ScheduleConfig {
return c.opt.GetScheduleConfig()
Expand Down
12 changes: 6 additions & 6 deletions server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2999,7 +2999,7 @@ func TestPersistScheduler(t *testing.T) {
re.NoError(controller.RemoveScheduler(schedulers.BalanceWitnessName))
re.NoError(controller.RemoveScheduler(schedulers.TransferWitnessLeaderName))
re.Len(controller.GetSchedulerNames(), defaultCount-3)
re.NoError(co.GetCluster().GetPersistOptions().Persist(storage))
re.NoError(co.GetCluster().GetSchedulerConfig().Persist(storage))
co.Stop()
co.GetSchedulersController().Wait()
co.GetWaitGroup().Wait()
Expand Down Expand Up @@ -3052,12 +3052,12 @@ func TestPersistScheduler(t *testing.T) {

// the scheduler option should contain 6 items
// the `hot scheduler` are disabled
re.Len(co.GetCluster().GetPersistOptions().(*config.PersistOptions).GetSchedulers(), defaultCount+3)
re.Len(co.GetCluster().GetSchedulerConfig().(*config.PersistOptions).GetSchedulers(), defaultCount+3)
re.NoError(controller.RemoveScheduler(schedulers.GrantLeaderName))
// the scheduler that is not enable by default will be completely deleted
re.Len(co.GetCluster().GetPersistOptions().(*config.PersistOptions).GetSchedulers(), defaultCount+2)
re.Len(co.GetCluster().GetSchedulerConfig().(*config.PersistOptions).GetSchedulers(), defaultCount+2)
re.Len(controller.GetSchedulerNames(), 4)
re.NoError(co.GetCluster().GetPersistOptions().Persist(co.GetCluster().GetStorage()))
re.NoError(co.GetCluster().GetSchedulerConfig().Persist(co.GetCluster().GetStorage()))
co.Stop()
co.GetSchedulersController().Wait()
co.GetWaitGroup().Wait()
Expand Down Expand Up @@ -3114,7 +3114,7 @@ func TestRemoveScheduler(t *testing.T) {
re.NoError(err)
re.Empty(sches)
re.Empty(controller.GetSchedulerNames())
re.NoError(co.GetCluster().GetPersistOptions().Persist(co.GetCluster().GetStorage()))
re.NoError(co.GetCluster().GetSchedulerConfig().Persist(co.GetCluster().GetStorage()))
co.Stop()
co.GetSchedulersController().Wait()
co.GetWaitGroup().Wait()
Expand All @@ -3128,7 +3128,7 @@ func TestRemoveScheduler(t *testing.T) {
co.Run()
re.Empty(controller.GetSchedulerNames())
// the option remains default scheduler
re.Len(co.GetCluster().GetPersistOptions().(*config.PersistOptions).GetSchedulers(), defaultCount)
re.Len(co.GetCluster().GetSchedulerConfig().(*config.PersistOptions).GetSchedulers(), defaultCount)
co.Stop()
co.GetSchedulersController().Wait()
co.GetWaitGroup().Wait()
Expand Down

0 comments on commit 619a97e

Please sign in to comment.