helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject [27/38] helix git commit: New DelayedAutoRebalancer featured with delayed partition movements during rebalancing.
Date Wed, 08 Feb 2017 18:00:02 GMT
http://git-wip-us.apache.org/repos/asf/helix/blob/b0d11228/helix-core/src/test/java/org/apache/helix/integration/TestRebalancerPersistAssignments.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestRebalancerPersistAssignments.java
b/helix-core/src/test/java/org/apache/helix/integration/TestRebalancerPersistAssignments.java
index 382ef1b..0474a10 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestRebalancerPersistAssignments.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestRebalancerPersistAssignments.java
@@ -19,16 +19,12 @@ package org.apache.helix.integration;
  * under the License.
  */
 
-import org.apache.helix.ConfigAccessor;
 import org.apache.helix.integration.manager.ClusterControllerManager;
 import org.apache.helix.integration.manager.MockParticipantManager;
 import org.apache.helix.model.BuiltInStateModelDefinitions;
-import org.apache.helix.model.ClusterConfig;
-import org.apache.helix.model.HelixConfigScope;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.model.IdealState.RebalanceMode;
 import org.apache.helix.model.MasterSlaveSMD;
-import org.apache.helix.model.builder.HelixConfigScopeBuilder;
 import org.apache.helix.tools.ClusterSetup;
 import org.apache.helix.tools.ClusterStateVerifier.BestPossibleExternalViewVerifier;
 import org.apache.helix.tools.ClusterStateVerifier.ClusterStateVerifier;
@@ -122,7 +118,7 @@ public class TestRebalancerPersistAssignments extends ZkStandAloneCMTestBase
{
   public void testEnablePersist(RebalanceMode rebalanceMode)
       throws Exception {
     String testDb = "TestDB1-" + rebalanceMode.name();
-    enablePersistAssignment(true);
+    enablePersistBestPossibleAssignment(_gZkClient, CLUSTER_NAME, true);
 
     _setupTool.addResourceToCluster(CLUSTER_NAME, testDb, 5,
         BuiltInStateModelDefinitions.LeaderStandby.name(), rebalanceMode.name());
@@ -166,7 +162,7 @@ public class TestRebalancerPersistAssignments extends ZkStandAloneCMTestBase
{
   @Test(dependsOnMethods = { "testDisablePersist" })
   public void testSemiAutoEnablePersistMasterSlave() throws Exception {
     String testDb = "TestDB1-MasterSlave";
-    enablePersistAssignment(true);
+    enablePersistBestPossibleAssignment(_gZkClient, CLUSTER_NAME, true);
 
     _setupTool.addResourceToCluster(CLUSTER_NAME, testDb, 5,
         BuiltInStateModelDefinitions.MasterSlave.name(), RebalanceMode.SEMI_AUTO.name());
@@ -223,17 +219,6 @@ public class TestRebalancerPersistAssignments extends ZkStandAloneCMTestBase
{
     }
   }
 
-  private void enablePersistAssignment(Boolean enable) {
-    ConfigAccessor configAccessor = new ConfigAccessor(_gZkClient);
-    HelixConfigScope clusterScope =
-        new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.CLUSTER)
-            .forCluster(CLUSTER_NAME).build();
-
-    configAccessor.set(clusterScope,
-        ClusterConfig.ClusterConfigProperty.PERSIST_BEST_POSSIBLE_ASSIGNMENT.name(),
-        enable.toString());
-  }
-
   // verify that the disabled or failed instance should not be included in bestPossible assignment.
   private void verifyAssignmentInIdealStateWithPersistEnabled(IdealState idealState,
       Set<String> excludedInstances) {

http://git-wip-us.apache.org/repos/asf/helix/blob/b0d11228/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java
b/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java
index 22696c3..9810f81 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java
@@ -23,7 +23,9 @@ import java.util.logging.Level;
 
 import org.I0Itec.zkclient.ZkServer;
 import org.apache.helix.ConfigAccessor;
+import org.apache.helix.model.ClusterConfig;
 import org.apache.helix.model.ConfigScope;
+import org.apache.helix.model.HelixConfigScope;
 import org.apache.helix.model.builder.ConfigScopeBuilder;
 import org.apache.helix.BaseDataAccessor;
 import org.apache.helix.TestHelper;
@@ -34,6 +36,7 @@ import org.apache.helix.manager.zk.ZNRecordSerializer;
 import org.apache.helix.manager.zk.ZkBaseDataAccessor;
 import org.apache.helix.manager.zk.ZkClient;
 import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.builder.HelixConfigScopeBuilder;
 import org.apache.helix.tools.ClusterSetup;
 import org.apache.helix.util.ZKClientPool;
 import org.apache.log4j.Logger;
@@ -100,4 +103,15 @@ public class ZkIntegrationTestBase {
     new ConfigAccessor(_gZkClient).set(scope, "healthChange" + ".enabled", "" + true);
   }
 
+  protected void enablePersistBestPossibleAssignment(ZkClient zkClient, String clusterName,
+      Boolean enable) {
+    ConfigAccessor configAccessor = new ConfigAccessor(zkClient);
+    HelixConfigScope clusterScope =
+        new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.CLUSTER)
+            .forCluster(clusterName).build();
+
+    configAccessor.set(clusterScope,
+        ClusterConfig.ClusterConfigProperty.PERSIST_BEST_POSSIBLE_ASSIGNMENT.name(),
+        enable.toString());
+  }
 }


Mime
View raw message