i3wangyi 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_r356814443
##########
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:
My suggestion of the multiply is after you check if the score equals.
----------------------------------------------------------------
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]