xyuanlu commented on a change in pull request #1756:
URL: https://github.com/apache/helix/pull/1756#discussion_r640100876



##########
File path: helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
##########
@@ -210,19 +231,36 @@ public static String serializeByComma(List<String> 
objects) {
       String metadataStoreAddress, ClusterConfig clusterConfig,
       List<InstanceConfig> instanceConfigs, List<String> liveInstances,
       List<IdealState> idealStates, List<ResourceConfig> resourceConfigs) {
-    return getAssignmentForWagedFullAutoImpl(metadataStoreAddress, 
clusterConfig,
-        instanceConfigs, liveInstances, idealStates, resourceConfigs, false);
+    return getAssignmentForWagedFullAutoHelper(metadataStoreAddress, 
clusterConfig, instanceConfigs,
+        liveInstances, idealStates, resourceConfigs, false);
   }
 
-  /*
-   * If usePrefLists is set to true, the returned assignment is based on 
preference lists; if
-   * false, the returned assignment is based on partition state mapping, which 
may differ from
-   * preference lists.
-   */
-  private static Map<String, ResourceAssignment> 
getAssignmentForWagedFullAutoImpl(
+  private static Map<String, ResourceAssignment> 
getAssignmentForWagedFullAutoHelper(
+      ZkBucketDataAccessor zkBucketDataAccessor, HelixDataAccessor 
helixDataAccessor,
+      ClusterConfig clusterConfig, List<InstanceConfig> instanceConfigs, 
List<String> liveInstances,
+      List<IdealState> idealStates, List<ResourceConfig> resourceConfigs, 
boolean usePrefLists) {
+
+    // Copy the cluster config and make globalRebalance happen synchronously
+    // Otherwise, globalRebalance may not complete and this util might end up 
returning
+    // an empty assignment.
+    ClusterConfig globalSyncClusterConfig = new 
ClusterConfig(clusterConfig.getRecord());
+    globalSyncClusterConfig.setGlobalRebalanceAsyncMode(false);
+
+    // Create an instance of read-only WAGED rebalancer
+    ReadOnlyWagedRebalancer readOnlyWagedRebalancer =
+        new ReadOnlyWagedRebalancer(zkBucketDataAccessor, 
globalSyncClusterConfig.getClusterName(),
+            globalSyncClusterConfig.getGlobalRebalancePreference());
+
+    return getAssignmentForWagedFullAutoImpl(helixDataAccessor, 
readOnlyWagedRebalancer,
+        globalSyncClusterConfig, instanceConfigs, liveInstances, idealStates, 
resourceConfigs,
+        usePrefLists);
+  }
+
+  private static Map<String, ResourceAssignment> 
getAssignmentForWagedFullAutoHelper(

Review comment:
       TFTR. If we make data accessor construction logic private, when adding a 
new REAT API, then the caller still need to pass a raw ZK address? 




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to