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 2019/10/24 19:10:29 UTC

[GitHub] [helix] jiajunwang commented on a change in pull request #520: Refactor soft constraints to simply the algorithm and fix potential issues.

jiajunwang commented on a change in pull request #520: Refactor soft constraints to simply the algorithm and fix potential issues.
URL: https://github.com/apache/helix/pull/520#discussion_r338744909
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ResourcePartitionAntiAffinityConstraint.java
 ##########
 @@ -29,24 +29,16 @@
  * the same resource be assigned to the same node to minimize the impact of node failure scenarios.
  * The score is higher the fewer the partitions are on the node belonging to the same resource.
  */
-class ResourcePartitionAntiAffinityConstraint extends SoftConstraint {
-  private static final float MAX_SCORE = 1f;
-  private static final float MIN_SCORE = 0f;
-
-  ResourcePartitionAntiAffinityConstraint() {
-    super(MAX_SCORE, MIN_SCORE);
-  }
+class ResourcePartitionAntiAffinityConstraint extends UsageSoftConstraint {
 
   @Override
   protected float getAssignmentScore(AssignableNode node, AssignableReplica replica,
       ClusterContext clusterContext) {
     String resource = replica.getResourceName();
     int curPartitionCountForResource = node.getAssignedPartitionsByResource(resource).size();
-    int doubleMaxPartitionCountForResource =
-        2 * clusterContext.getEstimatedMaxPartitionByResource(resource);
-    // The score measures the twice the max allowed count versus current counts
-    // The returned value is a measurement of remaining quota ratio, in the case of exceeding allowed counts, return 0
-    return Math.max(((float) doubleMaxPartitionCountForResource - curPartitionCountForResource)
-        / doubleMaxPartitionCountForResource, 0);
+    int estimatedMaxPartitionCountForResource =
+        clusterContext.getEstimatedMaxPartitionByResource(resource);
 
 Review comment:
   This is not really predicting future usage. So I feel "project" is not the right word.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org