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_r357441234
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedRebalancer.java
 ##########
 @@ -326,32 +328,17 @@ public void close() {
     return newIdealStates;
   }
 
-  // Coordinate baseline recalculation and partial rebalance according to the 
cluster changes.
+  // Coordinate global rebalance and partial rebalance according to the 
cluster changes.
   protected Map<String, ResourceAssignment> computeBestPossibleAssignment(
       ResourceControllerDataProvider clusterData, Map<String, Resource> 
resourceMap,
-      Set<String> activeNodes, final CurrentStateOutput currentStateOutput)
+      Set<String> activeNodes, final CurrentStateOutput currentStateOutput,
+      RebalanceAlgorithm algorithm)
       throws HelixRebalanceException {
-    getChangeDetector().updateSnapshots(clusterData);
-    // Get all the changed items' information. Filter for the items that have 
content changed.
-    final Map<HelixConstants.ChangeType, Set<String>> clusterChanges =
-        getChangeDetector().getChangeTypes().stream()
-            .collect(Collectors.toMap(changeType -> changeType, changeType -> {
-              Set<String> itemKeys = new HashSet<>();
-              
itemKeys.addAll(getChangeDetector().getAdditionsByType(changeType));
-              
itemKeys.addAll(getChangeDetector().getChangesByType(changeType));
-              
itemKeys.addAll(getChangeDetector().getRemovalsByType(changeType));
-              return itemKeys;
-            })).entrySet().stream().filter(changeEntry -> 
!changeEntry.getValue().isEmpty())
-            .collect(Collectors
-                .toMap(changeEntry -> changeEntry.getKey(), changeEntry -> 
changeEntry.getValue()));
-
-    // Perform Global Baseline Calculation
-    refreshBaseline(clusterData, clusterChanges, resourceMap, 
currentStateOutput);
-
-    // Perform partial rebalance
+    // Perform global rebalance for a new baseline assignment
+    globalRebalance(clusterData, resourceMap, currentStateOutput, algorithm);
 
 Review comment:
   Yes, I'm reviewing all together with your potential next PR. I feel like a 
boolean variable explicitly here will make the code more readable (without 
looking into how `globalRebalance` does in details) 

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