xyuanlu commented on a change in pull request #1456:
URL: https://github.com/apache/helix/pull/1456#discussion_r508061282



##########
File path: 
helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
##########
@@ -1299,6 +1308,10 @@ protected void 
checkLiveInstancesObservation(List<LiveInstance> liveInstances,
   }
 
   public void shutdown() throws InterruptedException {
+    if (_periodicRebalancerFutureTasks != null) {
+      _periodicRebalancerFutureTasks.cancel(false);
+    }

Review comment:
       Yea you are correct. shutDown will cancel tasks later. Updated. 

##########
File path: 
helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
##########
@@ -333,15 +338,19 @@ private void forceRebalance(HelixManager manager, 
ClusterEventType eventType) {
   void startPeriodRebalance(long period, HelixManager manager) {
     if (period != _timerPeriod) {
       logger.info("Controller starting periodical rebalance timer at period " 
+ period);
-      if (_periodicalRebalanceTimer != null) {
-        _periodicalRebalanceTimer.cancel();
+      ScheduledFuture lastScheduledFuture = null;
+      synchronized (_lock) {
+        if (_periodicRebalancerFutureTasks!=null && 
!_periodicRebalancerFutureTasks.isCancelled()) {
+          lastScheduledFuture = _periodicRebalancerFutureTasks;
+        }
+        _timerPeriod = period;
+        _periodicRebalancerFutureTasks = _periodicalRebalanceExecutor
+            .scheduleAtFixedRate(new RebalanceTask(manager, 
ClusterEventType.PeriodicalRebalance),
+                _timerPeriod, _timerPeriod, TimeUnit.MILLISECONDS);
+      }
+      if (lastScheduledFuture != null) {
+        lastScheduledFuture.cancel(true /* mayInterruptIfRunning */);

Review comment:
       Updated.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to