jiajunwang commented on a change in pull request #651: Improve the algorithm so 
it prioritizes the assignment to the idle nodes when the constraint evaluation 
results are the same
URL: https://github.com/apache/helix/pull/651#discussion_r356812688
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintBasedAlgorithm.java
 ##########
 @@ -113,8 +112,24 @@ public OptimalAssignment calculate(ClusterModel 
clusterModel) throws HelixRebala
 
     return candidateNodes.parallelStream().map(node -> new 
HashMap.SimpleEntry<>(node,
         getAssignmentNormalizedScore(node, replica, clusterContext)))
-        .max(Comparator.comparingDouble((scoreEntry) -> scoreEntry.getValue()))
-        .map(Map.Entry::getKey);
+        .max((nodeEntry1, nodeEntry2) -> {
+          int scoreCompareResult =  
nodeEntry1.getValue().compareTo(nodeEntry2.getValue());
+          if (scoreCompareResult == 0) {
+            // If the evaluation scores of 2 nodes are the same, the algorithm 
assigns the replica
+            // to the idle node first.
+            boolean isNodeOneIdle =
 
 Review comment:
   That logic will be different, note that the score is still the most 
important thing. If I change it as you suggested, the busy node will always win 
regardless of the score. As I explained to you earlier, this should only change 
the behavior when the evaluation cannot tell the difference between 2 nodes.

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