Updated Branches: refs/heads/master f38b3da29 -> 13d19e914
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/13d19e91/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java b/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java index 89b02ad..120ab94 100644 --- a/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java +++ b/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java @@ -23,10 +23,11 @@ import java.util.*; import org.apache.helix.TestHelper; import org.apache.helix.model.IdealState.IdealStateModeProperty; +import org.apache.helix.model.IdealState.RebalanceMode; import org.testng.Assert; import org.testng.annotations.Test; - +@SuppressWarnings("deprecation") public class TestIdealState { @Test @@ -46,8 +47,8 @@ public class TestIdealState instanceState.put("node_4", "SLAVE"); idealState.getRecord().setMapField("TestDB_1", instanceState); - // test AUTO mode - idealState.setIdealStateMode(IdealStateModeProperty.AUTO.toString()); + // test SEMI_AUTO mode + idealState.setRebalanceMode(RebalanceMode.SEMI_AUTO); Set<String> instances = idealState.getInstanceSet("TestDB_0"); // System.out.println("instances: " + instances); Assert.assertEquals(instances.size(), 2, "Should contain node_1 and node_2"); @@ -58,7 +59,7 @@ public class TestIdealState Assert.assertEquals(instances, Collections.emptySet(), "Should get empty set"); // test CUSTOMIZED mode - idealState.setIdealStateMode(IdealStateModeProperty.CUSTOMIZED.toString()); + idealState.setRebalanceMode(RebalanceMode.CUSTOMIZED); instances = idealState.getInstanceSet("TestDB_1"); // System.out.println("instances: " + instances); Assert.assertEquals(instances.size(), 2, "Should contain node_3 and node_4"); @@ -74,21 +75,59 @@ public class TestIdealState @Test public void testReplicas() { - IdealState idealState = new IdealState("test-db"); - idealState.setIdealStateMode(IdealStateModeProperty.AUTO.toString()); - idealState.setNumPartitions(4); - idealState.setStateModelDefRef("MasterSlave"); + IdealState idealState = new IdealState("test-db"); + idealState.setRebalanceMode(RebalanceMode.SEMI_AUTO); + idealState.setNumPartitions(4); + idealState.setStateModelDefRef("MasterSlave"); + + idealState.setReplicas("" + 2); + + List<String> preferenceList = new ArrayList<String>(); + preferenceList.add("node_0"); + idealState.getRecord().setListField("test-db_0", preferenceList); + Assert.assertFalse(idealState.isValid(), "should fail since replicas not equals to preference-list size"); + + preferenceList.add("node_1"); + idealState.getRecord().setListField("test-db_0", preferenceList); + Assert.assertTrue(idealState.isValid(), "should pass since replicas equals to preference-list size"); + } + + @Test + public void testFullAutoModeCompatibility() { + IdealState idealStateOld = new IdealState("old-test-db"); + idealStateOld.setIdealStateMode(IdealStateModeProperty.AUTO_REBALANCE.toString()); + Assert.assertEquals(idealStateOld.getRebalanceMode(), RebalanceMode.FULL_AUTO); + Assert.assertEquals(idealStateOld.getIdealStateMode(), IdealStateModeProperty.AUTO_REBALANCE); + + IdealState idealStateNew = new IdealState("new-test-db"); + idealStateNew.setRebalanceMode(RebalanceMode.FULL_AUTO); + Assert.assertEquals(idealStateNew.getIdealStateMode(), IdealStateModeProperty.AUTO_REBALANCE); + Assert.assertEquals(idealStateNew.getRebalanceMode(), RebalanceMode.FULL_AUTO); + } - idealState.setReplicas("" + 2); + @Test + public void testSemiAutoModeCompatibility() { + IdealState idealStateOld = new IdealState("old-test-db"); + idealStateOld.setIdealStateMode(IdealStateModeProperty.AUTO.toString()); + Assert.assertEquals(idealStateOld.getRebalanceMode(), RebalanceMode.SEMI_AUTO); + Assert.assertEquals(idealStateOld.getIdealStateMode(), IdealStateModeProperty.AUTO); - List<String> preferenceList = new ArrayList<String>(); - preferenceList.add("node_0"); - idealState.getRecord().setListField("test-db_0", preferenceList); - Assert.assertFalse(idealState.isValid(), "should fail since replicas not equals to preference-list size"); + IdealState idealStateNew = new IdealState("new-test-db"); + idealStateNew.setRebalanceMode(RebalanceMode.SEMI_AUTO); + Assert.assertEquals(idealStateNew.getIdealStateMode(), IdealStateModeProperty.AUTO); + Assert.assertEquals(idealStateNew.getRebalanceMode(), RebalanceMode.SEMI_AUTO); + } - preferenceList.add("node_1"); - idealState.getRecord().setListField("test-db_0", preferenceList); - Assert.assertTrue(idealState.isValid(), "should pass since replicas equals to preference-list size"); + @Test + public void testCustomizedModeCompatibility() { + IdealState idealStateOld = new IdealState("old-test-db"); + idealStateOld.setIdealStateMode(IdealStateModeProperty.CUSTOMIZED.toString()); + Assert.assertEquals(idealStateOld.getRebalanceMode(), RebalanceMode.CUSTOMIZED); + Assert.assertEquals(idealStateOld.getIdealStateMode(), IdealStateModeProperty.CUSTOMIZED); + IdealState idealStateNew = new IdealState("new-test-db"); + idealStateNew.setRebalanceMode(RebalanceMode.CUSTOMIZED); + Assert.assertEquals(idealStateNew.getIdealStateMode(), IdealStateModeProperty.CUSTOMIZED); + Assert.assertEquals(idealStateNew.getRebalanceMode(), RebalanceMode.CUSTOMIZED); } } http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/13d19e91/helix-core/src/test/java/org/apache/helix/model/builder/TestIdealStateBuilder.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/model/builder/TestIdealStateBuilder.java b/helix-core/src/test/java/org/apache/helix/model/builder/TestIdealStateBuilder.java index cdb7867..1b5ba63 100644 --- a/helix-core/src/test/java/org/apache/helix/model/builder/TestIdealStateBuilder.java +++ b/helix-core/src/test/java/org/apache/helix/model/builder/TestIdealStateBuilder.java @@ -40,8 +40,9 @@ public class TestIdealStateBuilder { Assert.fail("fail to build an auto mode ideal-state.", e); } // System.out.println("ideal-state: " + idealState); - Assert.assertEquals(idealState.getIdealStateMode(), IdealState.IdealStateModeProperty.AUTO, - "ideal-state mode should be auto"); + Assert.assertEquals(idealState.getRebalanceMode(), + IdealState.RebalanceMode.SEMI_AUTO, + "rebalancer mode should be semi-auto"); } @Test @@ -60,8 +61,9 @@ public class TestIdealStateBuilder { Assert.fail("fail to build an auto-rebalance mode ideal-state.", e); } // System.out.println("ideal-state: " + idealState); - Assert.assertEquals(idealState.getIdealStateMode(), IdealState.IdealStateModeProperty.AUTO_REBALANCE, - "ideal-state mode should be auto-rebalance"); + Assert.assertEquals(idealState.getRebalanceMode(), + IdealState.RebalanceMode.FULL_AUTO, + "rebalancer mode should be auto"); } @@ -83,8 +85,9 @@ public class TestIdealStateBuilder { Assert.fail("fail to build a custom mode ideal-state.", e); } // System.out.println("ideal-state: " + idealState); - Assert.assertEquals(idealState.getIdealStateMode(), IdealState.IdealStateModeProperty.CUSTOMIZED, - "ideal-state mode should be customized"); + Assert.assertEquals(idealState.getRebalanceMode(), + IdealState.RebalanceMode.CUSTOMIZED, + "rebalancer mode should be customized"); } } http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/13d19e91/recipes/distributed-lock-manager/README.md ---------------------------------------------------------------------- diff --git a/recipes/distributed-lock-manager/README.md b/recipes/distributed-lock-manager/README.md index fdba382..f3b2fbe 100644 --- a/recipes/distributed-lock-manager/README.md +++ b/recipes/distributed-lock-manager/README.md @@ -137,7 +137,7 @@ This provides more details on how to setup the cluster and where to plugin appli Create a lock group and specify the number of locks in the lock group. ``` -./helix-admin --zkSvr localhost:2199 --addResource lock-manager-demo lock-group 6 OnlineOffline AUTO_REBALANCE +./helix-admin --zkSvr localhost:2199 --addResource lock-manager-demo lock-group 6 OnlineOffline FULL_AUTO ``` ##### Start the nodes http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/13d19e91/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockManagerDemo.java ---------------------------------------------------------------------- diff --git a/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockManagerDemo.java b/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockManagerDemo.java index 11cfdaf..ac08274 100644 --- a/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockManagerDemo.java +++ b/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockManagerDemo.java @@ -32,8 +32,8 @@ import org.apache.helix.HelixManager; import org.apache.helix.controller.HelixControllerMain; import org.apache.helix.manager.zk.ZKHelixAdmin; import org.apache.helix.model.ExternalView; +import org.apache.helix.model.IdealState.RebalanceMode; import org.apache.helix.model.StateModelDefinition; -import org.apache.helix.model.IdealState.IdealStateModeProperty; import org.apache.helix.tools.StateModelConfigGenerator; public class LockManagerDemo @@ -64,7 +64,7 @@ public class LockManagerDemo admin.addStateModelDef(clusterName, "OnlineOffline", new StateModelDefinition(generator.generateConfigForOnlineOffline())); admin.addResource(clusterName, lockGroupName, numPartitions, - "OnlineOffline", IdealStateModeProperty.AUTO_REBALANCE.toString()); + "OnlineOffline", RebalanceMode.FULL_AUTO.toString()); admin.rebalance(clusterName, lockGroupName, 1); for (int i = 0; i < numInstances; i++) { http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/13d19e91/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/SetupConsumerCluster.java ---------------------------------------------------------------------- diff --git a/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/SetupConsumerCluster.java b/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/SetupConsumerCluster.java index 93aadb4..8bc0a0d 100644 --- a/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/SetupConsumerCluster.java +++ b/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/SetupConsumerCluster.java @@ -22,7 +22,7 @@ package org.apache.helix.recipes.rabbitmq; import org.apache.helix.manager.zk.ZKHelixAdmin; import org.apache.helix.manager.zk.ZNRecordSerializer; import org.apache.helix.manager.zk.ZkClient; -import org.apache.helix.model.IdealState.IdealStateModeProperty; +import org.apache.helix.model.IdealState.RebalanceMode; import org.apache.helix.model.StateModelDefinition; import org.apache.helix.tools.StateModelConfigGenerator; @@ -62,7 +62,7 @@ public class SetupConsumerCluster // add resource "topic" which has 6 partitions String resourceName = DEFAULT_RESOURCE_NAME; admin.addResource(clusterName, resourceName, DEFAULT_PARTITION_NUMBER, DEFAULT_STATE_MODEL, - IdealStateModeProperty.AUTO_REBALANCE.toString()); + RebalanceMode.FULL_AUTO.toString()); admin.rebalance(clusterName, resourceName, 1); http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/13d19e91/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/SetupCluster.java ---------------------------------------------------------------------- diff --git a/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/SetupCluster.java b/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/SetupCluster.java index 77cc2f9..097d27b 100644 --- a/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/SetupCluster.java +++ b/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/SetupCluster.java @@ -22,7 +22,7 @@ package org.apache.helix.filestore; import org.apache.helix.manager.zk.ZKHelixAdmin; import org.apache.helix.manager.zk.ZNRecordSerializer; import org.apache.helix.manager.zk.ZkClient; -import org.apache.helix.model.IdealState.IdealStateModeProperty; +import org.apache.helix.model.IdealState.RebalanceMode; import org.apache.helix.model.InstanceConfig; import org.apache.helix.model.StateModelDefinition; import org.apache.helix.tools.StateModelConfigGenerator; @@ -75,7 +75,7 @@ public class SetupCluster // add resource "repository" which has 1 partition String resourceName = DEFAULT_RESOURCE_NAME; admin.addResource(clusterName, resourceName, DEFAULT_PARTITION_NUMBER, - DEFAULT_STATE_MODEL, IdealStateModeProperty.AUTO.toString()); + DEFAULT_STATE_MODEL, RebalanceMode.SEMI_AUTO.toString()); admin.rebalance(clusterName, resourceName, 1); } finally http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/13d19e91/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskCluster.java ---------------------------------------------------------------------- diff --git a/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskCluster.java b/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskCluster.java index c49659e..de462f0 100644 --- a/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskCluster.java +++ b/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskCluster.java @@ -24,9 +24,9 @@ import org.apache.helix.manager.zk.ZKHelixAdmin; import org.apache.helix.manager.zk.ZNRecordSerializer; import org.apache.helix.manager.zk.ZkClient; import org.apache.helix.model.HelixConfigScope; +import org.apache.helix.model.IdealState.RebalanceMode; import org.apache.helix.model.StateModelDefinition; import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty; -import org.apache.helix.model.IdealState.IdealStateModeProperty; import org.apache.helix.model.builder.HelixConfigScopeBuilder; import org.apache.helix.tools.StateModelConfigGenerator; @@ -78,7 +78,7 @@ public class TaskCluster { clusterConfig.set(clusterScope, node.getId(), node.toJson()); _admin.addResource(_clusterName, node.getId(), node.getNumPartitions(), DEFAULT_STATE_MODEL, - IdealStateModeProperty.AUTO_REBALANCE.toString()); + RebalanceMode.FULL_AUTO.toString()); }
