Skip to content

Commit

Permalink
address the comment
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed Jul 10, 2023
1 parent 2a7a43e commit 6401d33
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/schedule/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (c *Coordinator) RunUntilStop() {
c.Run()
<-c.ctx.Done()
log.Info("Coordinator is stopping")
c.GetSchedulersController().GetWaitGroup().Wait()
c.GetSchedulersController().Wait()
c.wg.Wait()
log.Info("Coordinator has been stopped")
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/schedule/schedulers/scheduler_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ func NewController(ctx context.Context, cluster sche.ScheduleCluster, storage en
}
}

// GetWaitGroup returns the waitGroup of the controller.
func (c *Controller) GetWaitGroup() *sync.WaitGroup {
return &c.wg
// Wait waits on all schedulers to exit.
func (c *Controller) Wait() {
c.wg.Wait()
}

// GetScheduler returns a schedule controller by name.
Expand Down
16 changes: 8 additions & 8 deletions server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2440,7 +2440,7 @@ func prepare(setCfg func(*config.ScheduleConfig), setTc func(*testCluster), run
}
return tc, co, func() {
co.Stop()
co.GetSchedulersController().GetWaitGroup().Wait()
co.GetSchedulersController().Wait()
co.GetWaitGroup().Wait()
hbStreams.Close()
cancel()
Expand Down Expand Up @@ -2723,7 +2723,7 @@ func TestCheckCache(t *testing.T) {
re.Len(oc.GetOperators(), 1)
re.Empty(co.GetCheckerController().GetWaitingRegions())

co.GetSchedulersController().GetWaitGroup().Wait()
co.GetSchedulersController().Wait()
co.GetWaitGroup().Wait()
re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/schedule/break-patrol"))
}
Expand Down Expand Up @@ -2976,7 +2976,7 @@ func TestPersistScheduler(t *testing.T) {
re.Len(sc.GetSchedulerNames(), defaultCount-3)
re.NoError(co.GetCluster().GetPersistOptions().Persist(storage))
co.Stop()
co.GetSchedulersController().GetWaitGroup().Wait()
co.GetSchedulersController().Wait()
co.GetWaitGroup().Wait()
// make a new coordinator for testing
// whether the schedulers added or removed in dynamic way are recorded in opt
Expand Down Expand Up @@ -3006,7 +3006,7 @@ func TestPersistScheduler(t *testing.T) {
sc = co.GetSchedulersController()
re.Len(sc.GetSchedulerNames(), 3)
co.Stop()
co.GetSchedulersController().GetWaitGroup().Wait()
co.GetSchedulersController().Wait()
co.GetWaitGroup().Wait()
// suppose restart PD again
_, newOpt, err = newTestScheduleConfig()
Expand Down Expand Up @@ -3034,7 +3034,7 @@ func TestPersistScheduler(t *testing.T) {
re.Len(sc.GetSchedulerNames(), 4)
re.NoError(co.GetCluster().GetPersistOptions().Persist(co.GetCluster().GetStorage()))
co.Stop()
co.GetSchedulersController().GetWaitGroup().Wait()
co.GetSchedulersController().Wait()
co.GetWaitGroup().Wait()
_, newOpt, err = newTestScheduleConfig()
re.NoError(err)
Expand Down Expand Up @@ -3091,7 +3091,7 @@ func TestRemoveScheduler(t *testing.T) {
re.Empty(sc.GetSchedulerNames())
re.NoError(co.GetCluster().GetPersistOptions().Persist(co.GetCluster().GetStorage()))
co.Stop()
co.GetSchedulersController().GetWaitGroup().Wait()
co.GetSchedulersController().Wait()
co.GetWaitGroup().Wait()

// suppose restart PD again
Expand All @@ -3105,7 +3105,7 @@ func TestRemoveScheduler(t *testing.T) {
// the option remains default scheduler
re.Len(co.GetCluster().GetPersistOptions().GetSchedulers(), defaultCount)
co.Stop()
co.GetSchedulersController().GetWaitGroup().Wait()
co.GetSchedulersController().Wait()
co.GetWaitGroup().Wait()
}

Expand Down Expand Up @@ -3137,7 +3137,7 @@ func TestRestart(t *testing.T) {
re.NoError(dispatchHeartbeat(co, region, stream))
region = waitPromoteLearner(re, stream, region, 2)
co.Stop()
co.GetSchedulersController().GetWaitGroup().Wait()
co.GetSchedulersController().Wait()
co.GetWaitGroup().Wait()

// Recreate coordinator then add another replica on store 3.
Expand Down

0 comments on commit 6401d33

Please sign in to comment.