You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2022/02/15 18:01:49 UTC
[GitHub] [helix] qqu0127 commented on a change in pull request #1961: Use final remaining capacity when computing weighted score
qqu0127 commented on a change in pull request #1961:
URL: https://github.com/apache/helix/pull/1961#discussion_r807133408
##########
File path: helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintBasedAlgorithm.java
##########
@@ -275,6 +262,43 @@ public int compareTo(AssignableReplicaWithScore replica2) {
}
}
+ /**
+ * Update the overallClusterUtilMap with newly placed replica
+ */
+ private Map<String, Integer> computeFinalClusterRemainingCapacity(ClusterModel clusterModel)
Review comment:
Could you please clarify the meaning of "final"?
##########
File path: helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintBasedAlgorithm.java
##########
@@ -275,6 +262,43 @@ public int compareTo(AssignableReplicaWithScore replica2) {
}
}
+ /**
+ * Update the overallClusterUtilMap with newly placed replica
+ */
+ private Map<String, Integer> computeFinalClusterRemainingCapacity(ClusterModel clusterModel)
+ throws HelixRebalanceException {
+
+ // compute current remaining capacity.
+ Map<String, Integer> utilizationMap = new HashMap<>();
+ for (AssignableNode node : clusterModel.getAssignableNodes().values()) {
+ for (String capacityKey : node.getMaxCapacity().keySet()) {
+ utilizationMap.compute(capacityKey,
+ (k, v) -> v == null ? node.getRemainingCapacity().get(capacityKey)
+ : v + node.getRemainingCapacity().get(capacityKey));
+ }
+ }
+ // compute final remaining capacity after all replicas are assigned.
+ for (Map.Entry<String, Set<AssignableReplica>> replicasByResource : clusterModel
+ .getAssignableReplicaMap().entrySet()) {
+ for (AssignableReplica replica : replicasByResource.getValue()) {
+ for (Map.Entry<String, Integer> resourceUsage : replica.getCapacity().entrySet()) {
Review comment:
Correct me if I'm wrong, I feel it actually computes the current state of all resource usage for all replicas, it's not necessarily after all replicas are assigned?
##########
File path: helix-core/src/test/java/org/apache/helix/controller/rebalancer/waged/model/AbstractTestClusterModel.java
##########
@@ -237,8 +276,7 @@ protected ResourceControllerDataProvider setupClusterDataCacheForNearFullUtil()
for (CurrentState cs : currentStatemap.values()) {
ResourceConfig resourceConfig = dataProvider.getResourceConfig(cs.getResourceName());
// Construct one AssignableReplica for each partition in the current state.
- cs.getPartitionStateMap().entrySet().stream()
- .forEach(entry -> assignmentSet
+ cs.getPartitionStateMap().entrySet().stream().forEach(entry -> assignmentSet
.add(new AssignableReplica(dataProvider.getClusterConfig(), resourceConfig,
Review comment:
nit: update indentation
--
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-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org