kaisun2000 commented on a change in pull request #1532:
URL: https://github.com/apache/helix/pull/1532#discussion_r541482871



##########
File path: 
helix-core/src/main/java/org/apache/helix/controller/stages/IntermediateStateCalcStage.java
##########
@@ -276,116 +191,173 @@ private void 
validateMaxPartitionsPerInstance(ClusterEvent event,
   }
 
   /**
-   * Compute intermediate partition states for a prioritized resource.
-   * @param cache
-   * @param clusterStatusMonitor
-   * @param idealState
-   * @param resource
+   * Go through each resource, and based on messageSelected and currentState, 
compute
+   * messageOutput while maintaining throttling constraints (for example, 
ensure that the number
+   * of possible pending state transitions does NOT go over the set threshold).
+   * @param event
+   * @param resourceMap
    * @param currentStateOutput
-   * @param bestPossiblePartitionStateMap
-   * @param preferenceLists
-   * @param throttleController
+   * @param selectedMessage
+   * @param retracedResourceStateMap out
    * @return
    */
-  private PartitionStateMap 
computeIntermediatePartitionState(ResourceControllerDataProvider cache,
-      ClusterStatusMonitor clusterStatusMonitor, IdealState idealState, 
Resource resource,
-      CurrentStateOutput currentStateOutput, PartitionStateMap 
bestPossiblePartitionStateMap,
-      Map<String, List<String>> preferenceLists,
-      StateTransitionThrottleController throttleController) {
-    String resourceName = resource.getResourceName();
-    LogUtil.logDebug(logger, _eventId, String.format("Processing resource: 
%s", resourceName));
+  private MessageOutput compute(ClusterEvent event, Map<String, Resource> 
resourceMap,
+      CurrentStateOutput currentStateOutput, MessageOutput selectedMessage,
+      ResourcesStateMap retracedResourceStateMap,
+      List<Message> throttledRecoveryMsg, List<Message> throttledLoadMsg) {
+    MessageOutput output = new MessageOutput();
 
-    // Throttling is applied only on FULL-AUTO mode
-    if (!throttleController.isThrottleEnabled()
-        || 
!IdealState.RebalanceMode.FULL_AUTO.equals(idealState.getRebalanceMode())) {
-      return bestPossiblePartitionStateMap;
-    }
+    ResourceControllerDataProvider dataCache =
+        event.getAttribute(AttributeName.ControllerDataProvider.name());
 
-    String stateModelDefName = idealState.getStateModelDefRef();
-    StateModelDefinition stateModelDef = 
cache.getStateModelDef(stateModelDefName);
-    PartitionStateMap intermediatePartitionStateMap = new 
PartitionStateMap(resourceName);
+    StateTransitionThrottleController throttleController =
+        new StateTransitionThrottleController(resourceMap.keySet(), 
dataCache.getClusterConfig(),
+            dataCache.getLiveInstances().keySet());
 
-    Set<Partition> partitionsNeedRecovery = new HashSet<>();
-    Set<Partition> partitionsNeedLoadBalance = new HashSet<>();
-    Set<Partition> partitionsWithErrorStateReplica = new HashSet<>();
-    for (Partition partition : resource.getPartitions()) {
-      Map<String, String> currentStateMap =
-          currentStateOutput.getCurrentStateMap(resourceName, partition);
-      Map<String, String> bestPossibleMap =
-          bestPossiblePartitionStateMap.getPartitionMap(partition);
-      List<String> preferenceList = 
preferenceLists.get(partition.getPartitionName());
+    // Resource level prioritization based on the numerical (sortable) 
priority field.

Review comment:
       Feel free to skip the IntermediateStateCalcStage, the new logic is in 
PerReplicaThrottleStage.




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