narendly commented on a change in pull request #466: Integrate the WAGED 
rebalancer with all the related components.
URL: https://github.com/apache/helix/pull/466#discussion_r325871225
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintBasedAlgorithm.java
 ##########
 @@ -66,29 +66,26 @@
   @Override
   public OptimalAssignment calculate(ClusterModel clusterModel) throws 
HelixRebalanceException {
     OptimalAssignment optimalAssignment = new OptimalAssignment();
-    Map<String, Set<AssignableReplica>> replicasByResource = 
clusterModel.getAssignableReplicaMap();
     List<AssignableNode> nodes = new 
ArrayList<>(clusterModel.getAssignableNodes().values());
-
-    // TODO: different orders of resource/replica could lead to different 
greedy assignments, will
-    // revisit and improve the performance
-    for (String resource : replicasByResource.keySet()) {
-      for (AssignableReplica replica : replicasByResource.get(resource)) {
-        Optional<AssignableNode> maybeBestNode =
-            getNodeWithHighestPoints(replica, nodes, 
clusterModel.getContext(), optimalAssignment);
-        // stop immediately if any replica cannot find best assignable node
-        if (optimalAssignment.hasAnyFailure()) {
-          String errorMessage = String.format(
-              "Unable to find any available candidate node for partition %s; 
Fail reasons: %s",
-              replica.getPartitionName(), optimalAssignment.getFailures());
-          throw new HelixRebalanceException(errorMessage,
-              HelixRebalanceException.Type.FAILED_TO_CALCULATE);
-        }
-        maybeBestNode.ifPresent(node -> 
clusterModel.assign(replica.getResourceName(),
-            replica.getPartitionName(), replica.getReplicaState(), 
node.getInstanceName()));
+    // Sort the replicas so the input is stable for the greedy algorithm.
+    // For the other algorithm implementation, this sorting could be 
unnecessary.
+    for (AssignableReplica replica : 
getOrderedAssignableReplica(clusterModel)) {
 
 Review comment:
   This doesn't answer my question...

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org
For additional commands, e-mail: reviews-h...@helix.apache.org

Reply via email to