Github user kanakb commented on a diff in the pull request:

    https://github.com/apache/helix/pull/52#discussion_r80157395
  
    --- Diff: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/strategy/AutoRebalanceStrategy.java
 ---
    @@ -177,15 +176,26 @@ private void assignOrphans() {
         while (it.hasNext()) {
           Replica replica = it.next();
           boolean added = false;
    -      int startIndex = computeRandomStartIndex(replica);
    -      for (int index = startIndex; index < startIndex + 
_liveNodesList.size(); index++) {
    -        Node receiver = _liveNodesList.get(index % _liveNodesList.size());
    -        if (receiver.capacity > receiver.currentlyAssigned && 
receiver.canAdd(replica)) {
    -          receiver.currentlyAssigned = receiver.currentlyAssigned + 1;
    -          receiver.nonPreferred.add(replica);
    -          receiver.newReplicas.add(replica);
    -          added = true;
    -          break;
    +
    +      // first find if it preferred node still has capacity
    +      Node preferred = _preferredAssignment.get(replica);
    +      if (preferred.capacity > preferred.currentlyAssigned && 
preferred.canAdd(replica)) {
    --- End diff --
    
    Can you refactor this into a method, since this is basically the same code 
as below?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to