You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2019/10/25 18:15:32 UTC

[GitHub] [helix] jiajunwang commented on a change in pull request #535: Adjust the replica rebalance calculating ordering method to avoid a static order.

jiajunwang commented on a change in pull request #535: Adjust the replica rebalance calculating ordering method to avoid a static order.
URL: https://github.com/apache/helix/pull/535#discussion_r339178844
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintBasedAlgorithm.java
 ##########
 @@ -159,12 +159,19 @@ private float getAssignmentNormalizedScore(AssignableNode node, AssignableReplic
           int statePriority1 = replica1.getStatePriority();
           int statePriority2 = replica2.getStatePriority();
           if (statePriority1 == statePriority2) {
-            // If state prioritizes are the same, compare the names.
-            if (resourceName1.equals(resourceName2)) {
-              return replica1.getPartitionName().compareTo(replica2.getPartitionName());
-            } else {
-              return resourceName1.compareTo(resourceName2);
-            }
+            // If state prioritizes are the same, try to randomize the replicas order. Otherwise,
+            // the same replicas might always be moved in the rebalance. This is because their
+            // rebalance calculating will always happen at the critical moment while the cluster is
+            // almost full.
+            //
+            // Note that to ensure the algorithm is deterministic with the same inputs, do not use
+            // Random functions here. Use hashcode based on the cluster topology information to get
+            // a controlled randomized order is good enough.
+            long replicaHash1 = Objects
 
 Review comment:
   It is java hashing based. Just a wrapper.

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


With regards,
Apache Git Services

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