Fix TaskSchedulingStage

Two things fixed here:
1. It will have problem when cast to TaskRebalancer since old legacy rebalancer 
does not extend from TaskRebalancer
2. Create a dummy SemiAutoRebalancer. It will used for cleaning up those 
uncleaned current state which does not have idealstates or contexts.


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/07170dc5
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/07170dc5
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/07170dc5

Branch: refs/heads/master
Commit: 07170dc5784ebb9c3a92a15d67e7c8c94bab0e88
Parents: bd657cf
Author: Junkai Xue <[email protected]>
Authored: Wed Aug 15 11:33:55 2018 -0700
Committer: Lei Xia <[email protected]>
Committed: Fri Sep 21 14:17:01 2018 -0700

----------------------------------------------------------------------
 .../controller/stages/task/TaskSchedulingStage.java    | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/07170dc5/helix-core/src/main/java/org/apache/helix/controller/stages/task/TaskSchedulingStage.java
----------------------------------------------------------------------
diff --git 
a/helix-core/src/main/java/org/apache/helix/controller/stages/task/TaskSchedulingStage.java
 
b/helix-core/src/main/java/org/apache/helix/controller/stages/task/TaskSchedulingStage.java
index fd31dc6..86c6c32 100644
--- 
a/helix-core/src/main/java/org/apache/helix/controller/stages/task/TaskSchedulingStage.java
+++ 
b/helix-core/src/main/java/org/apache/helix/controller/stages/task/TaskSchedulingStage.java
@@ -8,6 +8,7 @@ import org.apache.helix.controller.LogUtil;
 import org.apache.helix.controller.pipeline.AbstractBaseStage;
 import org.apache.helix.controller.pipeline.StageException;
 import org.apache.helix.controller.rebalancer.Rebalancer;
+import org.apache.helix.controller.rebalancer.SemiAutoRebalancer;
 import org.apache.helix.controller.rebalancer.internal.MappingCalculator;
 import org.apache.helix.controller.stages.AttributeName;
 import org.apache.helix.controller.stages.BestPossibleStateOutput;
@@ -131,13 +132,15 @@ public class TaskSchedulingStage extends 
AbstractBaseStage {
                 + resourceName);
       }
     } else {
-      return false;
+      // Create dummy rebalancer for dropping existing current states
+      rebalancer = new SemiAutoRebalancer();
     }
 
-    TaskRebalancer taskRebalancer = TaskRebalancer.class.cast(rebalancer);
-    taskRebalancer.setClusterStatusMonitor(
-        (ClusterStatusMonitor) 
event.getAttribute(AttributeName.clusterStatusMonitor.name()));
-
+    if (rebalancer instanceof TaskRebalancer) {
+      TaskRebalancer taskRebalancer = TaskRebalancer.class.cast(rebalancer);
+      taskRebalancer.setClusterStatusMonitor(
+          (ClusterStatusMonitor) 
event.getAttribute(AttributeName.clusterStatusMonitor.name()));
+    }
     ResourceAssignment partitionStateAssignment = null;
     try {
       HelixManager manager = 
event.getAttribute(AttributeName.helixmanager.name());

Reply via email to