Source:
private void chargePendingTransition(Resource resource, CurrentStateOutput currentStateOutput, StateTransitionThrottleController throttleController, Set<Partition> partitionsNeedRecovery, Set<Partition> partitionsNeedLoadbalance, ResourceControllerDataProvider cache, PartitionStateMap bestPossiblePartitionStateMap, PartitionStateMap intermediatePartitionStateMap) { String resourceName = resource.getResourceName(); for (Partition partition : resource.getPartitions()) { Map<String, String> currentStateMap = currentStateOutput.getCurrentStateMap(resourceName, partition); Map<String, String> pendingMap = currentStateOutput.getPendingStateMap(resourceName, partition); StateTransitionThrottleConfig.RebalanceType rebalanceType = RebalanceType.NONE; if (partitionsNeedRecovery.contains(partition)) { rebalanceType = StateTransitionThrottleConfig.RebalanceType.RECOVERY_BALANCE; } else if (partitionsNeedLoadbalance.contains(partition)) { rebalanceType = StateTransitionThrottleConfig.RebalanceType.LOAD_BALANCE; } if (pendingMap.size() > 0) { boolean shouldChargePartition = false; for (String instance : pendingMap.keySet()) { String currentState = currentStateMap.get(instance); String pendingState = pendingMap.get(instance); if (pendingState != null && !pendingState.equals(currentState) && !cache.getDisabledInstancesForPartition(resourceName, partition.getPartitionName()) .contains(instance)) { throttleController.chargeInstance(rebalanceType, instance); shouldChargePartition = true; cleanPartitionsAreCharged(partition, partitionsNeedRecovery, partitionsNeedLoadbalance, rebalanceType); intermediatePartitionStateMap .setState(partition, bestPossiblePartitionStateMap.getPartitionMap(partition)); } } if (shouldChargePartition) { throttleController.chargeCluster(rebalanceType); throttleController.chargeResource(rebalanceType, resourceName); } } } }

Target:
private void chargePendingTransition(Resource resource, CurrentStateOutput currentStateOutput, StateTransitionThrottleController throttleController, Set<Partition> partitionsNeedRecovery, Set<Partition> partitionsNeedLoadbalance, ResourceControllerDataProvider cache, PartitionStateMap bestPossiblePartitionStateMap, PartitionStateMap intermediatePartitionStateMap) { String resourceName = resource.getResourceName(); for (Partition partition : resource.getPartitions()) { Map<String, String> currentStateMap = currentStateOutput.getCurrentStateMap(resourceName, partition); Map<String, String> pendingMap = currentStateOutput.getPendingStateMap(resourceName, partition); StateTransitionThrottleConfig.RebalanceType rebalanceType = RebalanceType.NONE; if (partitionsNeedRecovery.contains(partition)) { rebalanceType = StateTransitionThrottleConfig.RebalanceType.RECOVERY_BALANCE; } else if (partitionsNeedLoadbalance.contains(partition)) { rebalanceType = StateTransitionThrottleConfig.RebalanceType.LOAD_BALANCE; } if (pendingMap.size() > 0) { boolean shouldChargePartition = false; for (String instance : pendingMap.keySet()) { String currentState = currentStateMap.get(instance); String pendingState = pendingMap.get(instance); if (pendingState != null && !pendingState.equals(currentState) && !cache.getDisabledInstancesForPartition(resourceName, partition.getPartitionName()) .contains(instance)) { throttleController.chargeInstance(rebalanceType, instance); shouldChargePartition = true; handlePendingStateTransitionsForThrottling(partition, partitionsNeedRecovery, partitionsNeedLoadbalance, rebalanceType, bestPossiblePartitionStateMap, intermediatePartitionStateMap); } } if (shouldChargePartition) { throttleController.chargeCluster(rebalanceType); throttleController.chargeResource(rebalanceType, resourceName); } } } }