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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]