helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject [03/38] helix git commit: Deprecated AutoModeISBuilder and AutoRebalanceModeIsBuilder and created SemiAutoISBuilder and FullAutoISBuilder instead.
Date Wed, 08 Feb 2017 17:59:38 GMT
Deprecated AutoModeISBuilder and AutoRebalanceModeIsBuilder and created SemiAutoISBuilder and
FullAutoISBuilder instead.


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/f1e91887
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/f1e91887
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/f1e91887

Branch: refs/heads/helix-0.6.x
Commit: f1e9188733ffa72cdc68643061ac367e21bdf460
Parents: eb33370
Author: Lei Xia <lxia@linkedin.com>
Authored: Tue Jun 7 16:25:36 2016 -0700
Committer: Lei Xia <lxia@linkedin.com>
Committed: Sun Feb 5 16:55:08 2017 -0800

----------------------------------------------------------------------
 .../examples/IdealStateBuilderExample.java      |  8 ++--
 .../helix/model/builder/AutoModeISBuilder.java  |  4 ++
 .../builder/AutoRebalanceModeISBuilder.java     |  5 ++-
 .../model/builder/FullAutoModeISBuilder.java    | 47 ++++++++++++++++++++
 .../model/builder/SemiAutoModeISBuilder.java    | 45 +++++++++++++++++++
 .../handling/TestResourceThreadpoolSize.java    |  5 ++-
 .../model/builder/TestIdealStateBuilder.java    |  8 ++--
 7 files changed, 111 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/f1e91887/helix-core/src/main/java/org/apache/helix/examples/IdealStateBuilderExample.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/examples/IdealStateBuilderExample.java
b/helix-core/src/main/java/org/apache/helix/examples/IdealStateBuilderExample.java
index 4f76352..b89d830 100644
--- a/helix-core/src/main/java/org/apache/helix/examples/IdealStateBuilderExample.java
+++ b/helix-core/src/main/java/org/apache/helix/examples/IdealStateBuilderExample.java
@@ -27,9 +27,9 @@ import org.apache.helix.model.IdealState;
 import org.apache.helix.model.IdealState.RebalanceMode;
 import org.apache.helix.model.InstanceConfig;
 import org.apache.helix.model.StateModelDefinition;
-import org.apache.helix.model.builder.AutoModeISBuilder;
-import org.apache.helix.model.builder.AutoRebalanceModeISBuilder;
 import org.apache.helix.model.builder.CustomModeISBuilder;
+import org.apache.helix.model.builder.FullAutoModeISBuilder;
+import org.apache.helix.model.builder.SemiAutoModeISBuilder;
 import org.apache.helix.tools.StateModelConfigGenerator;
 
 public class IdealStateBuilderExample {
@@ -79,7 +79,7 @@ public class IdealStateBuilderExample {
     IdealState idealState = null;
     switch (idealStateMode) {
     case SEMI_AUTO: {
-      AutoModeISBuilder builder = new AutoModeISBuilder(resourceName);
+      SemiAutoModeISBuilder builder = new SemiAutoModeISBuilder(resourceName);
       builder.setStateModel("MasterSlave").setNumPartitions(2).setNumReplica(2);
       builder.assignPreferenceList(buildPartitionName(resourceName, 0), "localhost_12918",
           "localhost_12919").assignPreferenceList(buildPartitionName(resourceName, 1),
@@ -89,7 +89,7 @@ public class IdealStateBuilderExample {
       break;
     }
     case FULL_AUTO: {
-      AutoRebalanceModeISBuilder builder = new AutoRebalanceModeISBuilder(resourceName);
+      FullAutoModeISBuilder builder = new FullAutoModeISBuilder(resourceName);
       builder.setStateModel("MasterSlave").setNumPartitions(2).setNumReplica(2)
           .setMaxPartitionsPerNode(2);
       builder.add(buildPartitionName(resourceName, 0)).add(buildPartitionName(resourceName,
1));

http://git-wip-us.apache.org/repos/asf/helix/blob/f1e91887/helix-core/src/main/java/org/apache/helix/model/builder/AutoModeISBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/builder/AutoModeISBuilder.java
b/helix-core/src/main/java/org/apache/helix/model/builder/AutoModeISBuilder.java
index 535f25b..cbd1387 100644
--- a/helix-core/src/main/java/org/apache/helix/model/builder/AutoModeISBuilder.java
+++ b/helix-core/src/main/java/org/apache/helix/model/builder/AutoModeISBuilder.java
@@ -24,6 +24,10 @@ import org.apache.helix.model.IdealState.RebalanceMode;
 import java.util.ArrayList;
 import java.util.Arrays;
 
+/**
+ * This is the deprecated IS builder for SEMI-AUTO rebalance mode. Please use SemiAutoISBuilder
instead.
+ */
+@Deprecated
 public class AutoModeISBuilder extends IdealStateBuilder {
   public AutoModeISBuilder(String resourceName) {
     super(resourceName);

http://git-wip-us.apache.org/repos/asf/helix/blob/f1e91887/helix-core/src/main/java/org/apache/helix/model/builder/AutoRebalanceModeISBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/builder/AutoRebalanceModeISBuilder.java
b/helix-core/src/main/java/org/apache/helix/model/builder/AutoRebalanceModeISBuilder.java
index 3368c87..2f58d0b 100644
--- a/helix-core/src/main/java/org/apache/helix/model/builder/AutoRebalanceModeISBuilder.java
+++ b/helix-core/src/main/java/org/apache/helix/model/builder/AutoRebalanceModeISBuilder.java
@@ -23,6 +23,10 @@ import org.apache.helix.model.IdealState.RebalanceMode;
 
 import java.util.ArrayList;
 
+/**
+ * Please use FullAutoModeISBuilder instead.
+ */
+@Deprecated
 public class AutoRebalanceModeISBuilder extends IdealStateBuilder {
   public AutoRebalanceModeISBuilder(String resourceName) {
     super(resourceName);
@@ -41,5 +45,4 @@ public class AutoRebalanceModeISBuilder extends IdealStateBuilder {
 
     return this;
   }
-
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/f1e91887/helix-core/src/main/java/org/apache/helix/model/builder/FullAutoModeISBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/builder/FullAutoModeISBuilder.java
b/helix-core/src/main/java/org/apache/helix/model/builder/FullAutoModeISBuilder.java
new file mode 100644
index 0000000..b83e000
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/model/builder/FullAutoModeISBuilder.java
@@ -0,0 +1,47 @@
+package org.apache.helix.model.builder;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.helix.model.IdealState.RebalanceMode;
+
+import java.util.ArrayList;
+
+/**
+ * IS Builder for resource in Full-Auto rebalance mode.
+ */
+public class FullAutoModeISBuilder extends IdealStateBuilder {
+  public FullAutoModeISBuilder(String resourceName) {
+    super(resourceName);
+    setRebalancerMode(RebalanceMode.FULL_AUTO);
+  }
+
+  /**
+   * Add a partition, Helix will automatically assign the placement and state
+   * for this partition at runtime.
+   * @param partitionName
+   */
+  public FullAutoModeISBuilder add(String partitionName) {
+    if (_record.getListField(partitionName) == null) {
+      _record.setListField(partitionName, new ArrayList<String>());
+    }
+
+    return this;
+  }
+}

http://git-wip-us.apache.org/repos/asf/helix/blob/f1e91887/helix-core/src/main/java/org/apache/helix/model/builder/SemiAutoModeISBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/builder/SemiAutoModeISBuilder.java
b/helix-core/src/main/java/org/apache/helix/model/builder/SemiAutoModeISBuilder.java
new file mode 100644
index 0000000..cb813a1
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/model/builder/SemiAutoModeISBuilder.java
@@ -0,0 +1,45 @@
+package org.apache.helix.model.builder;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.helix.model.IdealState.RebalanceMode;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class SemiAutoModeISBuilder extends IdealStateBuilder {
+  public SemiAutoModeISBuilder(String resourceName) {
+    super(resourceName);
+    setRebalancerMode(RebalanceMode.SEMI_AUTO);
+  }
+
+  public SemiAutoModeISBuilder add(String partitionName) {
+    if (_record.getListField(partitionName) == null) {
+      _record.setListField(partitionName, new ArrayList<String>());
+    }
+    return this;
+  }
+
+  public SemiAutoModeISBuilder assignPreferenceList(String partitionName, String... instanceNames)
{
+    add(partitionName);
+    _record.getListField(partitionName).addAll(Arrays.asList(instanceNames));
+    return this;
+  }
+}

http://git-wip-us.apache.org/repos/asf/helix/blob/f1e91887/helix-core/src/test/java/org/apache/helix/messaging/handling/TestResourceThreadpoolSize.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/messaging/handling/TestResourceThreadpoolSize.java
b/helix-core/src/test/java/org/apache/helix/messaging/handling/TestResourceThreadpoolSize.java
index 20d9178..0ad4e9d 100644
--- a/helix-core/src/test/java/org/apache/helix/messaging/handling/TestResourceThreadpoolSize.java
+++ b/helix-core/src/test/java/org/apache/helix/messaging/handling/TestResourceThreadpoolSize.java
@@ -33,6 +33,7 @@ import org.apache.helix.HelixManager;
 import org.apache.helix.integration.ZkStandAloneCMTestBase;
 import org.apache.helix.messaging.DefaultMessagingService;
 import org.apache.helix.model.Message.MessageType;
+import org.apache.helix.model.builder.FullAutoModeISBuilder;
 import org.apache.helix.model.builder.HelixConfigScopeBuilder;
 import org.apache.helix.tools.ClusterStateVerifier;
 import org.testng.Assert;
@@ -79,13 +80,13 @@ public class TestResourceThreadpoolSize extends ZkStandAloneCMTestBase
{
     _setupTool.rebalanceStorageCluster(CLUSTER_NAME, "TestDB1", 3);
 
     // add db with customized thread pool
-    IdealState idealState = new AutoRebalanceModeISBuilder("TestDB2").setStateModel("OnlineOffline")
+    IdealState idealState = new FullAutoModeISBuilder("TestDB2").setStateModel("OnlineOffline")
         .setStateModelFactoryName("TestFactory").setNumPartitions(10).setNumReplica(1).build();
     _setupTool.getClusterManagementTool().addResource(CLUSTER_NAME, "TestDB2", idealState);
     _setupTool.rebalanceStorageCluster(CLUSTER_NAME, "TestDB2", 1);
 
     // add db with configured pool size
-    idealState = new AutoRebalanceModeISBuilder("TestDB3").setStateModel("OnlineOffline")
+    idealState = new FullAutoModeISBuilder("TestDB3").setStateModel("OnlineOffline")
         .setStateModelFactoryName("TestFactory").setNumPartitions(10).setNumReplica(1).build();
     _setupTool.getClusterManagementTool().addResource(CLUSTER_NAME, "TestDB3", idealState);
     setResourceThreadPoolSize("TestDB3", configuredPoolSize);

http://git-wip-us.apache.org/repos/asf/helix/blob/f1e91887/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 6eddcf5..3dbf522 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
@@ -25,8 +25,8 @@ import org.testng.annotations.Test;
 
 public class TestIdealStateBuilder {
   @Test
-  public void testAutoISBuilder() {
-    AutoModeISBuilder builder = new AutoModeISBuilder("test-db");
+  public void testSemiAutoISBuilder() {
+    SemiAutoModeISBuilder builder = new SemiAutoModeISBuilder("test-db");
     builder.setStateModel("MasterSlave").setNumPartitions(2).setNumReplica(2);
     builder.assignPreferenceList("test-db_0", "node_0", "node_1").assignPreferenceList("test-db_1",
         "node_1", "node_0");
@@ -43,8 +43,8 @@ public class TestIdealStateBuilder {
   }
 
   @Test
-  public void testAutoRebalanceISModeBuilder() {
-    AutoRebalanceModeISBuilder builder = new AutoRebalanceModeISBuilder("test-db");
+  public void testFullAutoModeISModeBuilder() {
+    FullAutoModeISBuilder builder = new FullAutoModeISBuilder("test-db");
     builder.setStateModel("MasterSlave").setNumPartitions(2).setNumReplica(2);
     builder.add("test-db_0").add("test-db_1");
 


Mime
View raw message