i3wangyi commented on a change in pull request #639: Refine the WAGED 
rebalancer to minimize the partial rebalance workload.
URL: https://github.com/apache/helix/pull/639#discussion_r354619155
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/model/ClusterModelProvider.java
 ##########
 @@ -75,9 +150,25 @@ public static ClusterModel 
generateClusterModel(ResourceControllerDataProvider d
     // Check if the replicas need to be reassigned.
     Map<String, Set<AssignableReplica>> allocatedReplicas =
         new HashMap<>(); // <instanceName, replica set>
-    Set<AssignableReplica> toBeAssignedReplicas =
-        findToBeAssignedReplicas(replicaMap, clusterChanges, activeInstances,
-            dataProvider.getLiveInstances().keySet(), bestPossibleAssignment, 
allocatedReplicas);
+    Set<AssignableReplica> toBeAssignedReplicas;
+    switch (scopeType) {
+      case GLOBAL_BASELINE:
+        toBeAssignedReplicas = 
findToBeAssignedReplicasByClusterChanges(replicaMap, activeInstances,
+            dataProvider.getLiveInstances().keySet(), clusterChanges, 
bestPossibleAssignment,
+            allocatedReplicas);
+        break;
+      case PARTIAL:
+        // Filter to remove the replicas that do not exist in the baseline 
given but exist in
+        // replicaMap. This is because such replicas are new additions that do 
not need to be
+        // rebalanced right away.
+        retainExistingReplicas(replicaMap, baselineAssignment);
+        toBeAssignedReplicas =
+            findToBeAssignedReplicasByComparingBaseline(replicaMap, 
activeInstances,
+                baselineAssignment, bestPossibleAssignment, allocatedReplicas);
 
 Review comment:
   I understand the scopeType will make an impact on the replicaMap data 
structure. My general suggestion is: instead of dealing with content in the 
private static method here, can we move the logics in the public static method? 
So the private static method doesn't get changed and you don't even need enum 
type 

----------------------------------------------------------------
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]


With regards,
Apache Git Services

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

Reply via email to