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/02 00:30:08 UTC

[GitHub] [helix] jiajunwang commented on a change in pull request #492: Load soft constraint weight from resources/properties file

jiajunwang commented on a change in pull request #492: Load soft constraint weight from resources/properties file
URL: https://github.com/apache/helix/pull/492#discussion_r330329924
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintBasedAlgorithmFactory.java
 ##########
 @@ -47,13 +62,17 @@ public static RebalanceAlgorithm getInstance(
     float evennessRatio = (float) evennessPreference / (evennessPreference + movementPreference);
     float movementRatio = (float) movementPreference / (evennessPreference + movementPreference);
 
-    Map<SoftConstraint, Float> softConstraints = ImmutableMap.<SoftConstraint, Float> builder()
-        .put(new PartitionMovementConstraint(), movementRatio)
-        .put(new InstancePartitionsCountConstraint(), 0.3f * evennessRatio)
-        .put(new ResourcePartitionAntiAffinityConstraint(), 0.1f * evennessRatio)
-        .put(new ResourceTopStateAntiAffinityConstraint(), 0.1f * evennessRatio)
-        .put(new MaxCapacityUsageInstanceConstraint(), 0.5f * evennessRatio).build();
+    List<SoftConstraint> l = ImmutableList.of(new PartitionMovementConstraint(),
+        new InstancePartitionsCountConstraint(), new ResourcePartitionAntiAffinityConstraint(),
+        new ResourceTopStateAntiAffinityConstraint(), new MaxCapacityUsageInstanceConstraint());
+    Map<SoftConstraint, Float> softConstraints = Maps.toMap(l, key -> {
+      String name = key.getClass().getSimpleName();
+      float weight = MODEL.get(name);
+      return name.equals(PARTITION_MOVEMENT_CONSTRAINT) ? movementRatio * weight
+          : evennessRatio * weight;
+    });
 
+    System.out.println(softConstraints);
 
 Review comment:
   System.out???

----------------------------------------------------------------
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