You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ji...@apache.org on 2020/12/01 02:33:06 UTC

[helix] branch topStatePOC updated: bug fixes

This is an automated email from the ASF dual-hosted git repository.

jiajunwang pushed a commit to branch topStatePOC
in repository https://gitbox.apache.org/repos/asf/helix.git


The following commit(s) were added to refs/heads/topStatePOC by this push:
     new 702cf43  bug fixes
702cf43 is described below

commit 702cf43c250afa432eaf41c57bf1ccbf610901af
Author: Jiajun Wang <jj...@linkedin.com>
AuthorDate: Mon Nov 30 18:32:07 2020 -0800

    bug fixes
---
 .../rebalancer/waged/constraints/ConstraintBasedAlgorithmFactory.java | 4 +++-
 .../helix/controller/rebalancer/waged/model/AssignableNode.java       | 2 +-
 .../integration/rebalancer/WagedRebalancer/TestWagedRebalance.java    | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintBasedAlgorithmFactory.java b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintBasedAlgorithmFactory.java
index b0da403..afeeb4b 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintBasedAlgorithmFactory.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/constraints/ConstraintBasedAlgorithmFactory.java
@@ -41,6 +41,7 @@ public class ConstraintBasedAlgorithmFactory {
       put(PartitionMovementConstraint.class.getSimpleName(), 2f);
       put(InstancePartitionsCountConstraint.class.getSimpleName(), 1f);
       put(ResourcePartitionAntiAffinityConstraint.class.getSimpleName(), 1f);
+      put(ResourceTopStateAntiAffinityConstraint.class.getSimpleName(), 0f);
       put(ResourceTopStateUsageConstraint.class.getSimpleName(), 3f);
       put(MaxCapacityUsageInstanceConstraint.class.getSimpleName(), 5f);
     }
@@ -69,7 +70,8 @@ public class ConstraintBasedAlgorithmFactory {
     List<SoftConstraint> softConstraints = ImmutableList
         .of(new PartitionMovementConstraint(), new InstancePartitionsCountConstraint(),
             new ResourcePartitionAntiAffinityConstraint(),
-            new ResourceTopStateUsageConstraint(), new MaxCapacityUsageInstanceConstraint());
+            new ResourceTopStateAntiAffinityConstraint(), new ResourceTopStateUsageConstraint(),
+            new MaxCapacityUsageInstanceConstraint());
     Map<SoftConstraint, Float> softConstraintsWithWeight = Maps.toMap(softConstraints, key -> {
       String name = key.getClass().getSimpleName();
       float weight = MODEL.get(name);
diff --git a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/model/AssignableNode.java b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/model/AssignableNode.java
index f8307fe..9e6bcf2 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/model/AssignableNode.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/model/AssignableNode.java
@@ -115,7 +115,7 @@ public class AssignableNode implements Comparable<AssignableNode> {
     // Update the global state after all single replications' calculation is done.
     for (String capacityKey : totalPartitionCapacity.keySet()) {
       updateRemainingCapacity(capacityKey, totalPartitionCapacity.get(capacityKey));
-      updateRemainingTopStateCapacity(capacityKey, totalTopStatePartitionCapacity.get(capacityKey));
+      updateRemainingTopStateCapacity(capacityKey, totalTopStatePartitionCapacity.getOrDefault(capacityKey, 0));
     }
   }
 
diff --git a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/WagedRebalancer/TestWagedRebalance.java b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/WagedRebalancer/TestWagedRebalance.java
index 0e3e354..02fe326 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/rebalancer/WagedRebalancer/TestWagedRebalance.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/rebalancer/WagedRebalancer/TestWagedRebalance.java
@@ -761,7 +761,7 @@ public class TestWagedRebalance extends ZkTestBase {
   public static void main(String[] args)
       throws IOException, IllegalAccessException, InstantiationException, ClassNotFoundException {
     String clusterName = "test";
-    String zkAddr = "localhost:2181";
+    String zkAddr = "localhost:12913";
 
     HelixZkClient.ZkClientConfig clientConfig = new HelixZkClient.ZkClientConfig();
     clientConfig.setZkSerializer(new ZNRecordSerializer());
@@ -795,7 +795,7 @@ public class TestWagedRebalance extends ZkTestBase {
     Map<String, Integer> defaultInstanceCapacityMap = clusterConfig.getDefaultInstanceCapacityMap();
     for (String key : clusterConfig.getInstanceCapacityKeys()) {
       defaultInstanceCapacityMap
-          .put(key, clusterConfig.getDefaultInstanceCapacityMap().getOrDefault(key, 0) * 2);
+          .put(key, clusterConfig.getDefaultInstanceCapacityMap().getOrDefault(key, 0));
     }
     clusterConfig.setDefaultInstanceCapacityMap(defaultInstanceCapacityMap);