junkaixue commented on code in PR #2546:
URL: https://github.com/apache/helix/pull/2546#discussion_r1244433767


##########
helix-core/src/main/java/org/apache/helix/controller/dataproviders/ResourceControllerDataProvider.java:
##########
@@ -475,4 +481,24 @@ final void refreshStablePartitionList(Map<String, 
IdealState> idealStateMap) {
       }
     }
   }
+
+  public void setWagedCapacityProviders(WagedInstanceCapacity 
capacityProvider, WagedResourceWeightsProvider resourceWeightProvider) {

Review Comment:
   NIT: java doc.



##########
helix-core/src/main/java/org/apache/helix/controller/dataproviders/ResourceControllerDataProvider.java:
##########
@@ -475,4 +481,24 @@ final void refreshStablePartitionList(Map<String, 
IdealState> idealStateMap) {
       }
     }
   }
+
+  public void setWagedCapacityProviders(WagedInstanceCapacity 
capacityProvider, WagedResourceWeightsProvider resourceWeightProvider) {
+    // WAGED specific capacity / weight provider
+    _wagedInstanceCapacity = capacityProvider;
+    _wagedPartitionWeightProvider = resourceWeightProvider;
+  }
+
+  public boolean checkAndReduceCapacity(String instance, String resourceName, 
String partition) {

Review Comment:
   NIT: java doc.



##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/DelayedAutoRebalancer.java:
##########
@@ -274,59 +276,208 @@ public ResourceAssignment 
computeBestPossiblePartitionState(ResourceControllerDa
     return partitionMapping;
   }
 
+
   @Override
   protected Map<String, String> 
computeBestPossibleStateForPartition(Set<String> liveInstances,

Review Comment:
   Since this is not public API, can we directly change liveInstances to cache? 
And refactor the abstract rebalancer part?
   
   If not, I would suggest to add cache as the last argument to form a new 
function. Then we can have old function call pass null value to cache to skip 
the WAGED check. That can reduce more redundant code.



##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/AbstractRebalancer.java:
##########
@@ -106,15 +106,26 @@ public ResourceAssignment 
computeBestPossiblePartitionState(
       List<String> preferenceList = getPreferenceList(partition, idealState,
           Collections.unmodifiableSet(cache.getLiveInstances().keySet()));
       Map<String, String> bestStateForPartition =
-          
computeBestPossibleStateForPartition(cache.getLiveInstances().keySet(), 
stateModelDef,
-              preferenceList, currentStateOutput, 
disabledInstancesForPartition, idealState,
-              cache.getClusterConfig(), partition,
-              cache.getAbnormalStateResolver(stateModelDefName));
+          computeBestPossibleStateForPartition(cache, stateModelDef, 
preferenceList,
+              currentStateOutput, disabledInstancesForPartition, idealState,
+              partition);
       partitionMapping.addReplicaMap(partition, bestStateForPartition);
     }
     return partitionMapping;
   }
 
+  protected Map<String, String> computeBestPossibleStateForPartition(T cache,
+      StateModelDefinition stateModelDef, List<String> preferenceList,
+      CurrentStateOutput currentStateOutput, Set<String> 
disabledInstancesForPartition,
+      IdealState idealState, Partition partition) {
+
+    String stateModelDefName = idealState.getStateModelDefRef();

Review Comment:
   NIT: this variable just used one, can you make it inline call instead of 
defining a variable.



-- 
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: [email protected]

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