himanshukandwal commented on code in PR #2778:
URL: https://github.com/apache/helix/pull/2778#discussion_r1526730635


##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/MaintenanceRebalancer.java:
##########
@@ -55,12 +59,19 @@ public IdealState computeNewIdealState(String resourceName, 
IdealState currentId
 
     // One principal is to prohibit DROP -> OFFLINE and OFFLINE -> DROP state 
transitions.
     // Derived preference list from current state with state priority
+    StateModelDefinition stateModelDef = 
clusterData.getStateModelDef(currentIdealState.getStateModelDefRef());
+
     for (Partition partition : currentStateMap.keySet()) {
       Map<String, String> stateMap = currentStateMap.get(partition);
       List<String> preferenceList = new ArrayList<>(stateMap.keySet());
+
+      // This sorting preserves the ordering of current state hosts in the 
order of current IS pref list
       Collections.sort(preferenceList, new 
PreferenceListNodeComparator(stateMap,
-          
clusterData.getStateModelDef(currentIdealState.getStateModelDefRef()),
-          Collections.<String>emptyList()));
+          stateModelDef, 
currentIdealState.getPreferenceList(partition.getPartitionName())));
+
+      // This sorts the current state hosts based on the priority
+      preferenceList.sort(new StatePriorityComparator(stateMap, 
stateModelDef));

Review Comment:
   Yes, updated code with an example as well. Thanks Komal!



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

To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to