From 7608f63d80ab586e9a15c531979fe80059540f25 Mon Sep 17 00:00:00 2001 From: nolouch Date: Fri, 17 May 2019 11:10:22 +0800 Subject: [PATCH] address comments Signed-off-by: nolouch --- server/schedule/operator_controller.go | 11 ++++++----- server/schedule/operator_controller_test.go | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/server/schedule/operator_controller.go b/server/schedule/operator_controller.go index 49bc3c46c53b..c488e135c836 100644 --- a/server/schedule/operator_controller.go +++ b/server/schedule/operator_controller.go @@ -134,22 +134,23 @@ func (oc *OperatorController) pollNeedDispatchRegion() (r *core.RegionInfo, next return nil, false } - // pushs with new notify time. + // pushes with new notify time. item.time = oc.getNextPushOperatorTime(step, now) heap.Push(&oc.opNotifierQueue, item) return r, true } -// PushOperators periodically pushs the unfinished operator to the excutor(TiKV). +// PushOperators periodically pushes the unfinished operator to the executor(TiKV). func (oc *OperatorController) PushOperators() { for { r, next := oc.pollNeedDispatchRegion() - if r == nil && !next { - break - } if r == nil { + if !next { + break + } continue } + oc.Dispatch(r, DispatchFromNotifierQueue) } } diff --git a/server/schedule/operator_controller_test.go b/server/schedule/operator_controller_test.go index c7f65bd26be5..56f52edb51a5 100644 --- a/server/schedule/operator_controller_test.go +++ b/server/schedule/operator_controller_test.go @@ -111,7 +111,7 @@ func (t *testOperatorControllerSuite) TestPollDispatchRegion(c *C) { op2 := NewOperator("test", 2, &metapb.RegionEpoch{}, OpRegion, steps...) region1 := tc.GetRegion(1) region2 := tc.GetRegion(2) - // Adds operator and pushs to the notifier queue. + // Adds operator and pushes to the notifier queue. { oc.SetOperator(op1) oc.SetOperator(op2)