You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by lx...@apache.org on 2017/02/02 17:53:21 UTC
[1/9] helix git commit: Make synchronized for
AsyncCallback.startTimer to avoid race condition
Repository: helix
Updated Branches:
refs/heads/helix-0.6.x 594d94aca -> 5ee5e59ba
Make synchronized for AsyncCallback.startTimer to avoid race condition
Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/cff462f8
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/cff462f8
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/cff462f8
Branch: refs/heads/helix-0.6.x
Commit: cff462f8277464a2de9479adec5f8f0617bdc7cc
Parents: 594d94a
Author: Junkai Xue <jx...@linkedin.com>
Authored: Sat Jan 28 16:31:55 2017 -0800
Committer: Junkai Xue <jx...@linkedin.com>
Committed: Sat Jan 28 16:31:55 2017 -0800
----------------------------------------------------------------------
.../src/main/java/org/apache/helix/messaging/AsyncCallback.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/helix/blob/cff462f8/helix-core/src/main/java/org/apache/helix/messaging/AsyncCallback.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/messaging/AsyncCallback.java b/helix-core/src/main/java/org/apache/helix/messaging/AsyncCallback.java
index f9743a4..b5d4bb1 100644
--- a/helix-core/src/main/java/org/apache/helix/messaging/AsyncCallback.java
+++ b/helix-core/src/main/java/org/apache/helix/messaging/AsyncCallback.java
@@ -104,7 +104,7 @@ public abstract class AsyncCallback {
_messagesSent = generatedMessage;
}
- final void startTimer() {
+ final synchronized void startTimer() {
if (_timer == null && _timeout > 0) {
if (_startTimeStamp == 0) {
_startTimeStamp = new Date().getTime();
[3/9] helix git commit: More specific log message when verification
is in progress
Posted by lx...@apache.org.
More specific log message when verification is in progress
Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/e0f9f96c
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/e0f9f96c
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/e0f9f96c
Branch: refs/heads/helix-0.6.x
Commit: e0f9f96c47693bcaaf01fc0c84a9177d8f5b9547
Parents: fb7496f
Author: Junkai Xue <jx...@linkedin.com>
Authored: Sat Jan 28 16:34:53 2017 -0800
Committer: Junkai Xue <jx...@linkedin.com>
Committed: Sat Jan 28 16:34:53 2017 -0800
----------------------------------------------------------------------
.../apache/helix/tools/ClusterStateVerifier.java | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/helix/blob/e0f9f96c/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java b/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
index b5b864c..a87740e 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
@@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit;
import org.I0Itec.zkclient.IZkChildListener;
import org.I0Itec.zkclient.IZkDataListener;
+import org.I0Itec.zkclient.exception.ZkNodeExistsException;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
@@ -262,9 +263,9 @@ public class ClusterStateVerifier {
}
// filter out all resources that use Task state model
- Iterator it = idealStates.entrySet().iterator();
+ Iterator<Map.Entry<String, IdealState>> it = idealStates.entrySet().iterator();
while (it.hasNext()) {
- Map.Entry<String, IdealState> pair = (Map.Entry<String, IdealState>)it.next();
+ Map.Entry<String, IdealState> pair = it.next();
if (pair.getValue().getStateModelDefRef().equals(TaskConstants.STATE_MODEL_NAME)) {
it.remove();
}
@@ -554,6 +555,13 @@ public class ClusterStateVerifier {
return verifyByZkCallback(verifier, 30000);
}
+ /**
+ * This function should be always single threaded
+ *
+ * @param verifier
+ * @param timeout
+ * @return
+ */
public static boolean verifyByZkCallback(ZkVerifier verifier, long timeout) {
long startTime = System.currentTimeMillis();
CountDownLatch countDown = new CountDownLatch(1);
@@ -562,7 +570,12 @@ public class ClusterStateVerifier {
// add an ephemeral node to /{clusterName}/CONFIGS/CLUSTER/verify
// so when analyze zk log, we know when a test ends
- zkClient.createEphemeral("/" + clusterName + "/CONFIGS/CLUSTER/verify");
+ try {
+ zkClient.createEphemeral("/" + clusterName + "/CONFIGS/CLUSTER/verify");
+ } catch (ZkNodeExistsException ex) {
+ LOG.error("There is already a verification in progress", ex);
+ throw ex;
+ }
ExtViewVeriferZkListener listener = new ExtViewVeriferZkListener(countDown, zkClient, verifier);
[6/9] helix git commit: Rename PropertyPathConfig to
PropertyPathBuilder
Posted by lx...@apache.org.
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/manager/zk/TestZKUtil.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZKUtil.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZKUtil.java
index f7dcb85..ed604fa 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZKUtil.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZKUtil.java
@@ -23,7 +23,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
@@ -80,7 +80,7 @@ public class TestZKUtil extends ZkUnitTestBase {
list.add(new ZNRecord("id1"));
list.add(new ZNRecord("id2"));
String path =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString());
ZKUtil.createChildren(_zkClient, path, list);
list = ZKUtil.getChildren(_zkClient, path);
@@ -97,7 +97,7 @@ public class TestZKUtil extends ZkUnitTestBase {
@Test()
public void testUpdateIfExists() {
String path =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString(), "id3");
ZNRecord record = new ZNRecord("id4");
ZKUtil.updateIfExists(_zkClient, path, record, false);
@@ -112,7 +112,7 @@ public class TestZKUtil extends ZkUnitTestBase {
@Test()
public void testSubtract() {
String path =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString(), "id5");
ZNRecord record = new ZNRecord("id5");
record.setSimpleField("key1", "value1");
@@ -125,7 +125,7 @@ public class TestZKUtil extends ZkUnitTestBase {
@Test()
public void testNullChildren() {
String path =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString(), "id6");
ZKUtil.createChildren(_zkClient, path, (List<ZNRecord>) null);
}
@@ -133,7 +133,7 @@ public class TestZKUtil extends ZkUnitTestBase {
@Test()
public void testCreateOrUpdate() {
String path =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString(), "id7");
ZNRecord record = new ZNRecord("id7");
ZKUtil.createOrUpdate(_zkClient, path, record, true, true);
@@ -144,7 +144,7 @@ public class TestZKUtil extends ZkUnitTestBase {
@Test()
public void testCreateOrReplace() {
String path =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString(), "id8");
ZNRecord record = new ZNRecord("id8");
ZKUtil.createOrReplace(_zkClient, path, record, true);
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkBaseDataAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkBaseDataAccessor.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkBaseDataAccessor.java
index 133fb4e..7b81437 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkBaseDataAccessor.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkBaseDataAccessor.java
@@ -26,17 +26,14 @@ import java.util.List;
import org.I0Itec.zkclient.DataUpdater;
import org.apache.helix.AccessOption;
import org.apache.helix.BaseDataAccessor;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
import org.apache.helix.ZNRecordUpdater;
import org.apache.helix.ZkUnitTestBase;
-import org.apache.helix.manager.zk.ZNRecordSerializer;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.manager.zk.ZkBaseDataAccessor.AccessResult;
import org.apache.helix.manager.zk.ZkBaseDataAccessor.RetCode;
-import org.apache.helix.manager.zk.ZkClient;
import org.apache.zookeeper.data.Stat;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -374,12 +371,12 @@ public class TestZkBaseDataAccessor extends ZkUnitTestBase {
ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<ZNRecord>(zkClient);
// test async createChildren
- String parentPath = PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1");
+ String parentPath = PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1");
List<ZNRecord> records = new ArrayList<ZNRecord>();
List<String> paths = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
- paths.add(PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1", msgId));
+ paths.add(PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1", msgId));
records.add(new ZNRecord(msgId));
}
boolean[] success = accessor.createChildren(paths, records, AccessOption.PERSISTENT);
@@ -391,18 +388,18 @@ public class TestZkBaseDataAccessor extends ZkUnitTestBase {
// test get what we created
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
- String path = PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1", msgId);
+ String path = PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1", msgId);
ZNRecord record = zkClient.readData(path);
Assert.assertEquals(record.getId(), msgId, "Should get what we created");
}
// test async setChildren
- parentPath = PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1");
+ parentPath = PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1");
records = new ArrayList<ZNRecord>();
paths = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
- paths.add(PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1", msgId));
+ paths.add(PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1", msgId));
ZNRecord newRecord = new ZNRecord(msgId);
newRecord.setSimpleField("key1", "value1");
records.add(newRecord);
@@ -416,20 +413,20 @@ public class TestZkBaseDataAccessor extends ZkUnitTestBase {
// test get what we set
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
- String path = PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1", msgId);
+ String path = PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1", msgId);
ZNRecord record = zkClient.readData(path);
Assert.assertEquals(record.getSimpleFields().size(), 1, "Should have 1 simple field set");
Assert.assertEquals(record.getSimpleField("key1"), "value1", "Should have value1 set");
}
// test async updateChildren
- parentPath = PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1");
+ parentPath = PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1");
// records = new ArrayList<ZNRecord>();
List<DataUpdater<ZNRecord>> znrecordUpdaters = new ArrayList<DataUpdater<ZNRecord>>();
paths = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
- paths.add(PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1", msgId));
+ paths.add(PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1", msgId));
ZNRecord newRecord = new ZNRecord(msgId);
newRecord.setSimpleField("key2", "value2");
// records.add(newRecord);
@@ -444,14 +441,14 @@ public class TestZkBaseDataAccessor extends ZkUnitTestBase {
// test get what we updated
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
- String path = PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1", msgId);
+ String path = PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1", msgId);
ZNRecord record = zkClient.readData(path);
Assert.assertEquals(record.getSimpleFields().size(), 2, "Should have 2 simple fields set");
Assert.assertEquals(record.getSimpleField("key2"), "value2", "Should have value2 set");
}
// test async getChildren
- parentPath = PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1");
+ parentPath = PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1");
records = accessor.getChildren(parentPath, null, 0);
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
@@ -462,11 +459,11 @@ public class TestZkBaseDataAccessor extends ZkUnitTestBase {
}
// test async exists
- parentPath = PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1");
+ parentPath = PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1");
paths = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
- paths.add(PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1", msgId));
+ paths.add(PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1", msgId));
}
boolean[] exists = accessor.exists(paths, 0);
for (int i = 0; i < 10; i++) {
@@ -475,11 +472,11 @@ public class TestZkBaseDataAccessor extends ZkUnitTestBase {
}
// test async getStats
- parentPath = PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1");
+ parentPath = PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1");
paths = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
- paths.add(PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1", msgId));
+ paths.add(PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1", msgId));
}
Stat[] stats = accessor.getStats(paths, 0);
for (int i = 0; i < 10; i++) {
@@ -490,11 +487,11 @@ public class TestZkBaseDataAccessor extends ZkUnitTestBase {
}
// test async remove
- parentPath = PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1");
+ parentPath = PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1");
paths = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
- paths.add(PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1", msgId));
+ paths.add(PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1", msgId));
}
success = accessor.remove(paths, 0);
for (int i = 0; i < 10; i++) {
@@ -505,7 +502,7 @@ public class TestZkBaseDataAccessor extends ZkUnitTestBase {
// test get what we removed
for (int i = 0; i < 10; i++) {
String msgId = "msg_" + i;
- String path = PropertyPathConfig.getPath(PropertyType.MESSAGES, root, "host_1", msgId);
+ String path = PropertyPathBuilder.getPath(PropertyType.MESSAGES, root, "host_1", msgId);
boolean pathExists = zkClient.exists(path);
Assert.assertFalse(pathExists, "Should be removed " + msgId);
}
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheAsyncOpSingleThread.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheAsyncOpSingleThread.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheAsyncOpSingleThread.java
index e2c503b..b35c7e0 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheAsyncOpSingleThread.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheAsyncOpSingleThread.java
@@ -26,16 +26,12 @@ import java.util.List;
import org.I0Itec.zkclient.DataUpdater;
import org.apache.helix.AccessOption;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
import org.apache.helix.ZNRecordUpdater;
import org.apache.helix.ZkUnitTestBase;
-import org.apache.helix.manager.zk.ZNRecordSerializer;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.manager.zk.ZkCacheBaseDataAccessor;
-import org.apache.helix.manager.zk.ZkClient;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -54,8 +50,8 @@ public class TestZkCacheAsyncOpSingleThread extends ZkUnitTestBase {
// init zkCacheBaseDataAccessor
String curStatePath =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
- String extViewPath = PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName);
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
+ String extViewPath = PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName);
ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
@@ -75,7 +71,7 @@ public class TestZkCacheAsyncOpSingleThread extends ZkUnitTestBase {
List<ZNRecord> records = new ArrayList<ZNRecord>();
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
"session_0", "TestDB" + i);
ZNRecord record = new ZNRecord("TestDB" + i);
@@ -134,7 +130,7 @@ public class TestZkCacheAsyncOpSingleThread extends ZkUnitTestBase {
records.clear();
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName, "TestDB" + i);
+ PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName, "TestDB" + i);
ZNRecord record = new ZNRecord("TestDB" + i);
paths.add(path);
@@ -157,7 +153,7 @@ public class TestZkCacheAsyncOpSingleThread extends ZkUnitTestBase {
paths.clear();
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName, "TestDB" + i);
+ PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName, "TestDB" + i);
paths.add(path);
}
@@ -189,8 +185,8 @@ public class TestZkCacheAsyncOpSingleThread extends ZkUnitTestBase {
// init zkCacheDataAccessor
String curStatePath =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
- String extViewPath = PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName);
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
+ String extViewPath = PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName);
ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
@@ -210,7 +206,7 @@ public class TestZkCacheAsyncOpSingleThread extends ZkUnitTestBase {
List<ZNRecord> records = new ArrayList<ZNRecord>();
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
"session_0", "TestDB" + i);
ZNRecord record = new ZNRecord("TestDB" + i);
@@ -263,7 +259,7 @@ public class TestZkCacheAsyncOpSingleThread extends ZkUnitTestBase {
for (int j = 0; j < 10; j++) {
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName, "TestDB" + i);
+ PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName, "TestDB" + i);
ZNRecord record = new ZNRecord("TestDB" + i);
record.setSimpleField("setKey", "" + j);
@@ -306,7 +302,7 @@ public class TestZkCacheAsyncOpSingleThread extends ZkUnitTestBase {
paths.clear();
for (int i = 0; i < 10; i++) {
String path = curStatePath + "/session_0/TestDB" + i;
- // // PropertyPathConfig.getPath(PropertyType.CURRENTSTATES,
+ // // PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES,
// // clusterName,
// // "localhost_8901",
// // "session_0",
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheSyncOpSingleThread.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheSyncOpSingleThread.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheSyncOpSingleThread.java
index 3c0f4bf..273725a 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheSyncOpSingleThread.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheSyncOpSingleThread.java
@@ -29,16 +29,12 @@ import java.util.TreeSet;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.apache.helix.AccessOption;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
import org.apache.helix.ZNRecordUpdater;
import org.apache.helix.ZkUnitTestBase;
-import org.apache.helix.manager.zk.ZNRecordSerializer;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.manager.zk.ZkCacheBaseDataAccessor;
-import org.apache.helix.manager.zk.ZkClient;
import org.apache.helix.store.HelixPropertyListener;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -88,8 +84,8 @@ public class TestZkCacheSyncOpSingleThread extends ZkUnitTestBase {
// init zkCacheDataAccessor
String curStatePath =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
- String extViewPath = PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName);
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
+ String extViewPath = PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName);
ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
index c2e53ea..e8f8f56 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
@@ -29,7 +29,7 @@ import org.apache.helix.HelixAdmin;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixException;
import org.apache.helix.PropertyKey;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
@@ -96,7 +96,7 @@ public class TestZkHelixAdmin extends ZkUnitTestBase {
config.getRecord().setListField("dummy", dummyList);
tool.addInstance(clusterName, config);
tool.enableInstance(clusterName, instanceName, true);
- String path = PropertyPathConfig.getPath(PropertyType.INSTANCES, clusterName, instanceName);
+ String path = PropertyPathBuilder.getPath(PropertyType.INSTANCES, clusterName, instanceName);
AssertJUnit.assertTrue(_gZkClient.exists(path));
try {
@@ -163,7 +163,7 @@ public class TestZkHelixAdmin extends ZkUnitTestBase {
ZNRecord stateModelRecord = new ZNRecord("id1");
try {
tool.addStateModelDef(clusterName, "id1", new StateModelDefinition(stateModelRecord));
- path = PropertyPathConfig.getPath(PropertyType.STATEMODELDEFS, clusterName, "id1");
+ path = PropertyPathBuilder.getPath(PropertyType.STATEMODELDEFS, clusterName, "id1");
AssertJUnit.assertTrue(_gZkClient.exists(path));
Assert.fail("should fail");
} catch (HelixException e) {
@@ -384,7 +384,7 @@ public class TestZkHelixAdmin extends ZkUnitTestBase {
}
tool.addInstance(clusterName, config);
tool.enableInstance(clusterName, instanceName, true);
- String path = PropertyPathConfig.getPath(PropertyType.INSTANCES, clusterName, instanceName);
+ String path = PropertyPathBuilder.getPath(PropertyType.INSTANCES, clusterName, instanceName);
AssertJUnit.assertTrue(_gZkClient.exists(path));
}
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerElection.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerElection.java b/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerElection.java
index 2e175d5..5ae90bb 100644
--- a/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerElection.java
+++ b/helix-core/src/test/java/org/apache/helix/participant/TestDistControllerElection.java
@@ -28,7 +28,7 @@ import org.apache.helix.HelixTimerTask;
import org.apache.helix.InstanceType;
import org.apache.helix.NotificationContext;
import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
@@ -75,7 +75,7 @@ public class TestDistControllerElection extends ZkUnitTestBase {
context.setType(NotificationContext.Type.INIT);
election.onControllerChange(context);
- // path = PropertyPathConfig.getPath(PropertyType.LEADER, clusterName);
+ // path = PropertyPathBuilder.getPath(PropertyType.LEADER, clusterName);
// ZNRecord leaderRecord = _gZkClient.<ZNRecord> readData(path);
LiveInstance liveInstance = accessor.getProperty(keyBuilder.controllerLeader());
AssertJUnit.assertEquals(controllerName, liveInstance.getInstanceName());
@@ -132,7 +132,7 @@ public class TestDistControllerElection extends ZkUnitTestBase {
LiveInstance liveInstance = accessor.getProperty(keyBuilder.controllerLeader());
AssertJUnit.assertEquals(controllerName, liveInstance.getInstanceName());
- // path = PropertyPathConfig.getPath(PropertyType.LEADER, clusterName);
+ // path = PropertyPathBuilder.getPath(PropertyType.LEADER, clusterName);
// ZNRecord leaderRecord = _gZkClient.<ZNRecord> readData(path);
// AssertJUnit.assertEquals(controllerName, leaderRecord.getSimpleField("LEADER"));
// AssertJUnit.assertNotNull(election.getController());
@@ -182,7 +182,7 @@ public class TestDistControllerElection extends ZkUnitTestBase {
context.setType(NotificationContext.Type.INIT);
election.onControllerChange(context);
- path = PropertyPathConfig.getPath(PropertyType.LEADER, clusterName);
+ path = PropertyPathBuilder.getPath(PropertyType.LEADER, clusterName);
ZNRecord leaderRecord = _gZkClient.<ZNRecord> readData(path, true);
AssertJUnit.assertNull(leaderRecord);
// AssertJUnit.assertNull(election.getController());
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java b/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java
index 1802c1a..fcead14 100644
--- a/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java
+++ b/helix-core/src/test/java/org/apache/helix/tools/TestClusterSetup.java
@@ -27,7 +27,7 @@ import org.apache.helix.BaseDataAccessor;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixException;
import org.apache.helix.PropertyKey;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
@@ -41,7 +41,6 @@ import org.apache.helix.manager.zk.ZkClient;
import org.apache.helix.model.IdealState;
import org.apache.helix.model.LiveInstance;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
-import org.apache.helix.tools.ClusterSetup;
import org.apache.log4j.Logger;
import org.testng.Assert;
import org.testng.AssertJUnit;
@@ -435,7 +434,7 @@ public class TestClusterSetup extends ZkUnitTestBase {
Assert.assertNull(accessor.getProperty(keyBuilder.instanceConfig("localhost_12918")),
"Instance config should be dropped");
- Assert.assertFalse(_gZkClient.exists(PropertyPathConfig.getPath(PropertyType.INSTANCES,
+ Assert.assertFalse(_gZkClient.exists(PropertyPathBuilder.getPath(PropertyType.INSTANCES,
clusterName, "localhost_12918")), "Instance/host should be dropped");
System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
[4/9] helix git commit: Move HelixUtil.get*Path to PropertyPathBuilder
Posted by lx...@apache.org.
Move HelixUtil.get*Path to PropertyPathBuilder
Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/1b3c5c28
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/1b3c5c28
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/1b3c5c28
Branch: refs/heads/helix-0.6.x
Commit: 1b3c5c286c3656c141e8449570bad63fc4b30a8f
Parents: 0b7a1a0
Author: Junkai Xue <jx...@linkedin.com>
Authored: Sat Jan 28 17:06:46 2017 -0800
Committer: Junkai Xue <jx...@linkedin.com>
Committed: Wed Feb 1 20:19:43 2017 -0800
----------------------------------------------------------------------
.../resources/ClusterRepresentationUtil.java | 10 +-
.../org/apache/helix/PropertyPathBuilder.java | 109 +++++++++++++++++++
.../apache/helix/manager/zk/ZKHelixAdmin.java | 35 +++---
.../helix/monitoring/ZKPathDataDumpTask.java | 22 +---
.../org/apache/helix/tools/MessagePoster.java | 9 +-
.../java/org/apache/helix/util/HelixUtil.java | 89 ---------------
.../java/org/apache/helix/ZkUnitTestBase.java | 9 +-
.../helix/integration/TestClusterStartsup.java | 11 +-
.../helix/integration/TestSchedulerMessage.java | 11 +-
.../helix/mock/controller/MockController.java | 6 +-
.../mock/spectator/MockSpectatorProcess.java | 9 +-
11 files changed, 157 insertions(+), 163 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/helix/blob/1b3c5c28/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterRepresentationUtil.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterRepresentationUtil.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterRepresentationUtil.java
index 35b1f7a..2710684 100644
--- a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterRepresentationUtil.java
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterRepresentationUtil.java
@@ -32,6 +32,7 @@ import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixProperty;
import org.apache.helix.PropertyKey;
import org.apache.helix.PropertyKey.Builder;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.ZNRecord;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
@@ -39,7 +40,6 @@ 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.LiveInstanceProperty;
-import org.apache.helix.util.HelixUtil;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
@@ -74,8 +74,7 @@ public class ClusterRepresentationUtil {
public static String getInstancePropertyNameListAsString(ZkClient zkClient, String clusterName,
String instanceName, PropertyType instanceProperty, String key, MediaType mediaType)
throws JsonGenerationException, JsonMappingException, IOException {
- String path =
- HelixUtil.getInstancePropertyPath(clusterName, instanceName, instanceProperty) + "/" + key;
+ String path = PropertyPathBuilder.instanceProperty(clusterName, instanceName, instanceProperty, key);
if (zkClient.exists(path)) {
List<String> recordNames = zkClient.getChildren(path);
return ObjectToJson(recordNames);
@@ -212,10 +211,7 @@ public class ClusterRepresentationUtil {
public static List<String> getInstancePropertyList(ZkClient zkClient, String clusterName,
String instanceName, PropertyType property, String key) {
- String propertyPath =
- HelixUtil.getInstancePropertyPath(clusterName, instanceName, property) + "/" + key;
-
+ String propertyPath = PropertyPathBuilder.instanceProperty(clusterName, instanceName, property, key);
return zkClient.getChildren(propertyPath);
-
}
}
http://git-wip-us.apache.org/repos/asf/helix/blob/1b3c5c28/helix-core/src/main/java/org/apache/helix/PropertyPathBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/PropertyPathBuilder.java b/helix-core/src/main/java/org/apache/helix/PropertyPathBuilder.java
index 5773c60..13ddb08 100644
--- a/helix-core/src/main/java/org/apache/helix/PropertyPathBuilder.java
+++ b/helix-core/src/main/java/org/apache/helix/PropertyPathBuilder.java
@@ -201,4 +201,113 @@ public class PropertyPathBuilder {
}
return null;
}
+
+ public static String idealState(String clusterName) {
+ return String.format("/%s/IDEALSTATES", clusterName);
+ }
+
+ public static String idealState(String clusterName, String resourceName) {
+ return String.format("/%s/IDEALSTATES/%s", clusterName, resourceName);
+ }
+
+ public static String stateModelDef(String clusterName) {
+ return String.format("/%s/STATEMODELDEFS", clusterName);
+ }
+
+ public static String stateModelDef(String clusterName, String stateModelName) {
+ return String.format("/%s/STATEMODELDEFS/%s", clusterName, stateModelName);
+ }
+
+ public static String externalView(String clusterName) {
+ return String.format("/%s/EXTERNALVIEW", clusterName);
+ }
+
+ public static String externalView(String clusterName, String resourceName) {
+ return String.format("/%s/EXTERNALVIEW/%s", clusterName, resourceName);
+ }
+
+ public static String liveInstance(String clusterName) {
+ return String.format("/%s/LIVEINSTANCES", clusterName);
+ }
+
+ public static String liveInstance(String clusterName, String instanceName) {
+ return String.format("/%s/LIVEINSTANCES/%s", clusterName, instanceName);
+ }
+
+ public static String instance(String clusterName) {
+ return String.format("/%s/INSTANCES", clusterName);
+ }
+
+ @Deprecated
+ public static String instanceProperty(String clusterName, String instanceName, PropertyType type, String key) {
+ return String.format("/%s/INSTANCES/%s/%s/%s", clusterName, instanceName, type, key);
+ }
+
+ public static String instance(String clusterName, String instanceName) {
+ return String.format("/%s/INSTANCES/%s", clusterName, instanceName);
+ }
+
+ public static String instanceMessage(String clusterName, String instanceName) {
+ return String.format("/%s/INSTANCES/%s/MESSAGES", clusterName, instanceName);
+ }
+
+ public static String instanceMessage(String clusterName, String instanceName, String messageId) {
+ return String.format("/%s/INSTANCES/%s/MESSAGES/%s", clusterName, instanceName, messageId);
+ }
+
+ public static String instanceCurrentState(String clusterName, String instanceName) {
+ return String.format("/%s/INSTANCES/%s/CURRENTSTATES", clusterName, instanceName);
+ }
+
+ public static String instanceCurrentState(String clusterName, String instanceName, String sessionId) {
+ return String.format("/%s/INSTANCES/%s/CURRENTSTATES/%s", clusterName, instanceName, sessionId);
+ }
+
+ public static String instanceError(String clusterName, String instanceName) {
+ return String.format("/%s/INSTANCES/%s/ERRORS", clusterName, instanceName);
+ }
+
+ public static String instanceStatusUpdate(String clusterName, String instanceName) {
+ return String.format("/%s/INSTANCES/%s/STATUSUPDATES", clusterName, instanceName);
+ }
+
+ public static String propertyStore(String clusterName) {
+ return String.format("/%s/PROPERTYSTORE", clusterName);
+ }
+
+ public static String instanceConfig(String clusterName) {
+ return String.format("/%s/CONFIGS/PARTICIPANT", clusterName);
+ }
+
+ public static String instanceConfig(String clusterName, String instanceName) {
+ return String.format("/%s/CONFIGS/PARTICIPANT/%s", clusterName, instanceName);
+ }
+
+ public static String controller(String clusterName) {
+ return String.format("/%s/CONTROLLER", clusterName);
+ }
+
+ public static String controllerLeader(String clusterName) {
+ return String.format("/%s/CONTROLLER/LEADER", clusterName);
+ }
+
+ public static String controllerMessage(String clusterName) {
+ return String.format("/%s/CONTROLLER/MESSAGES", clusterName);
+ }
+
+ public static String controllerStatusUpdate(String clusterName) {
+ return String.format("/%s/CONTROLLER/STATUSUPDATES", clusterName);
+ }
+
+ public static String controllerStatusUpdate(String clusterName, String subPath, String recordName) {
+ return String.format("/%s/CONTROLLER/STATUSUPDATES/%s/%s", clusterName, subPath, recordName);
+ }
+
+ public static String controllerError(String clusterName) {
+ return String.format("/%s/CONTROLLER/ERRORS", clusterName);
+ }
+
+ public static String pause(String clusterName) {
+ return String.format("/%s/CONTROLLER/PAUSE", clusterName);
+ }
}
http://git-wip-us.apache.org/repos/asf/helix/blob/1b3c5c28/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
index 2e2f3dd..1eaa3c6 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
@@ -70,7 +70,6 @@ import org.apache.helix.model.Message.MessageType;
import org.apache.helix.model.PauseSignal;
import org.apache.helix.model.StateModelDefinition;
import org.apache.helix.tools.DefaultIdealStateCalculator;
-import org.apache.helix.util.HelixUtil;
import org.apache.helix.util.RebalanceUtil;
import org.apache.log4j.Logger;
@@ -111,10 +110,10 @@ public class ZKHelixAdmin implements HelixAdmin {
ZKUtil.createChildren(_zkClient, instanceConfigsPath, instanceConfig.getRecord());
- _zkClient.createPersistent(HelixUtil.getMessagePath(clusterName, nodeId), true);
- _zkClient.createPersistent(HelixUtil.getCurrentStateBasePath(clusterName, nodeId), true);
- _zkClient.createPersistent(HelixUtil.getErrorsPath(clusterName, nodeId), true);
- _zkClient.createPersistent(HelixUtil.getStatusUpdatesPath(clusterName, nodeId), true);
+ _zkClient.createPersistent(PropertyPathBuilder.instanceMessage(clusterName, nodeId), true);
+ _zkClient.createPersistent(PropertyPathBuilder.instanceCurrentState(clusterName, nodeId), true);
+ _zkClient.createPersistent(PropertyPathBuilder.instanceError(clusterName, nodeId), true);
+ _zkClient.createPersistent(PropertyPathBuilder.instanceStatusUpdate(clusterName, nodeId), true);
}
@Override
@@ -124,7 +123,7 @@ public class ZKHelixAdmin implements HelixAdmin {
ConfigScopeProperty.PARTICIPANT.toString());
String nodeId = instanceConfig.getId();
String instanceConfigPath = instanceConfigsPath + "/" + nodeId;
- String instancePath = HelixUtil.getInstancePath(clusterName, nodeId);
+ String instancePath = PropertyPathBuilder.instance(clusterName, nodeId);
if (!_zkClient.exists(instanceConfigPath)) {
throw new HelixException("Node " + nodeId + " does not exist in config for cluster "
@@ -549,7 +548,7 @@ public class ZKHelixAdmin implements HelixAdmin {
String path;
// IDEAL STATE
- _zkClient.createPersistent(HelixUtil.getIdealStatePath(clusterName));
+ _zkClient.createPersistent(PropertyPathBuilder.idealState(clusterName));
// CONFIGURATIONS
path =
PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
@@ -568,16 +567,16 @@ public class ZKHelixAdmin implements HelixAdmin {
path = PropertyPathBuilder.getPath(PropertyType.PROPERTYSTORE, clusterName);
_zkClient.createPersistent(path);
// LIVE INSTANCES
- _zkClient.createPersistent(HelixUtil.getLiveInstancesPath(clusterName));
+ _zkClient.createPersistent(PropertyPathBuilder.liveInstance(clusterName));
// MEMBER INSTANCES
- _zkClient.createPersistent(HelixUtil.getMemberInstancesPath(clusterName));
+ _zkClient.createPersistent(PropertyPathBuilder.instance(clusterName));
// External view
- _zkClient.createPersistent(HelixUtil.getExternalViewPath(clusterName));
+ _zkClient.createPersistent(PropertyPathBuilder.externalView(clusterName));
// State model definition
- _zkClient.createPersistent(HelixUtil.getStateModelDefinitionPath(clusterName));
+ _zkClient.createPersistent(PropertyPathBuilder.stateModelDef(clusterName));
// controller
- _zkClient.createPersistent(HelixUtil.getControllerPath(clusterName));
+ _zkClient.createPersistent(PropertyPathBuilder.controller(clusterName));
path = PropertyPathBuilder.getPath(PropertyType.HISTORY, clusterName);
final ZNRecord emptyHistory = new ZNRecord(PropertyType.HISTORY.toString());
final List<String> emptyList = new ArrayList<String>();
@@ -596,13 +595,13 @@ public class ZKHelixAdmin implements HelixAdmin {
@Override
public List<String> getInstancesInCluster(String clusterName) {
- String memberInstancesPath = HelixUtil.getMemberInstancesPath(clusterName);
+ String memberInstancesPath = PropertyPathBuilder.instance(clusterName);
return _zkClient.getChildren(memberInstancesPath);
}
@Override
public List<String> getInstancesInClusterWithTag(String clusterName, String tag) {
- String memberInstancesPath = HelixUtil.getMemberInstancesPath(clusterName);
+ String memberInstancesPath = PropertyPathBuilder.instance(clusterName);
List<String> instances = _zkClient.getChildren(memberInstancesPath);
List<String> result = new ArrayList<String>();
@@ -649,7 +648,7 @@ public class ZKHelixAdmin implements HelixAdmin {
+ " not found in the cluster STATEMODELDEFS path");
}
- String idealStatePath = HelixUtil.getIdealStatePath(clusterName);
+ String idealStatePath = PropertyPathBuilder.idealState(clusterName);
String resourceIdealStatePath = idealStatePath + "/" + resourceName;
if (_zkClient.exists(resourceIdealStatePath)) {
throw new HelixException("Skip the operation. Resource ideal state directory already exists:"
@@ -713,7 +712,7 @@ public class ZKHelixAdmin implements HelixAdmin {
@Override
public List<String> getResourcesInCluster(String clusterName) {
- return _zkClient.getChildren(HelixUtil.getIdealStatePath(clusterName));
+ return _zkClient.getChildren(PropertyPathBuilder.idealState(clusterName));
}
@Override
@@ -772,7 +771,7 @@ public class ZKHelixAdmin implements HelixAdmin {
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
throw new HelixException("cluster " + clusterName + " is not setup yet");
}
- String stateModelDefPath = HelixUtil.getStateModelDefinitionPath(clusterName);
+ String stateModelDefPath = PropertyPathBuilder.stateModelDef(clusterName);
String stateModelPath = stateModelDefPath + "/" + stateModelDef;
if (_zkClient.exists(stateModelPath)) {
if (recreateIfExists) {
@@ -803,7 +802,7 @@ public class ZKHelixAdmin implements HelixAdmin {
@Override
public List<String> getStateModelDefs(String clusterName) {
- return _zkClient.getChildren(HelixUtil.getStateModelDefinitionPath(clusterName));
+ return _zkClient.getChildren(PropertyPathBuilder.stateModelDef(clusterName));
}
@Override
http://git-wip-us.apache.org/repos/asf/helix/blob/1b3c5c28/helix-core/src/main/java/org/apache/helix/monitoring/ZKPathDataDumpTask.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/ZKPathDataDumpTask.java b/helix-core/src/main/java/org/apache/helix/monitoring/ZKPathDataDumpTask.java
index 0a91256..2406a03 100644
--- a/helix-core/src/main/java/org/apache/helix/monitoring/ZKPathDataDumpTask.java
+++ b/helix-core/src/main/java/org/apache/helix/monitoring/ZKPathDataDumpTask.java
@@ -26,10 +26,9 @@ import org.apache.helix.BaseDataAccessor;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixManager;
import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.PropertyType;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.ZNRecord;
import org.apache.helix.manager.zk.ZNRecordSerializer;
-import org.apache.helix.util.HelixUtil;
import org.apache.log4j.Logger;
import org.apache.zookeeper.data.Stat;
@@ -74,28 +73,19 @@ public class ZKPathDataDumpTask extends TimerTask {
List<String> instances = accessor.getChildNames(keyBuilder.instanceConfigs());
for (String instance : instances) {
// dump participant status updates
- String statusUpdatePath =
- HelixUtil.getInstancePropertyPath(_manager.getClusterName(), instance,
- PropertyType.STATUSUPDATES);
+ String statusUpdatePath = PropertyPathBuilder.instanceStatusUpdate(_manager.getClusterName(), instance);
dump(baseAccessor, statusUpdatePath, _thresholdNoChangeMsForStatusUpdates, _maxLeafCount);
// dump participant errors
- String errorPath =
- HelixUtil.getInstancePropertyPath(_manager.getClusterName(), instance,
- PropertyType.ERRORS);
+ String errorPath = PropertyPathBuilder.instanceError(_manager.getClusterName(), instance);
dump(baseAccessor, errorPath, _thresholdNoChangeMsForErrors, _maxLeafCount);
}
// dump controller status updates
- String controllerStatusUpdatePath =
- HelixUtil.getControllerPropertyPath(_manager.getClusterName(),
- PropertyType.STATUSUPDATES_CONTROLLER);
- dump(baseAccessor, controllerStatusUpdatePath, _thresholdNoChangeMsForStatusUpdates,
- _maxLeafCount);
+ String controllerStatusUpdatePath = PropertyPathBuilder.controllerStatusUpdate(_manager.getClusterName());
+ dump(baseAccessor, controllerStatusUpdatePath, _thresholdNoChangeMsForStatusUpdates, _maxLeafCount);
// dump controller errors
- String controllerErrorPath =
- HelixUtil.getControllerPropertyPath(_manager.getClusterName(),
- PropertyType.ERRORS_CONTROLLER);
+ String controllerErrorPath = PropertyPathBuilder.controllerError(_manager.getClusterName());
dump(baseAccessor, controllerErrorPath, _thresholdNoChangeMsForErrors, _maxLeafCount);
}
http://git-wip-us.apache.org/repos/asf/helix/blob/1b3c5c28/helix-core/src/main/java/org/apache/helix/tools/MessagePoster.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/tools/MessagePoster.java b/helix-core/src/main/java/org/apache/helix/tools/MessagePoster.java
index f0114d0..80a7820 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/MessagePoster.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/MessagePoster.java
@@ -21,6 +21,7 @@ package org.apache.helix.tools;
import java.util.UUID;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.ZNRecord;
import org.apache.helix.manager.zk.ZNRecordSerializer;
import org.apache.helix.manager.zk.ZkClient;
@@ -28,17 +29,15 @@ import org.apache.helix.model.Message;
import org.apache.helix.model.LiveInstance.LiveInstanceProperty;
import org.apache.helix.model.Message.MessageState;
import org.apache.helix.model.Message.MessageType;
-import org.apache.helix.util.HelixUtil;
public class MessagePoster {
public void post(String zkServer, Message message, String clusterName, String instanceName) {
ZkClient client = new ZkClient(zkServer);
client.setZkSerializer(new ZNRecordSerializer());
- String path = HelixUtil.getMessagePath(clusterName, instanceName) + "/" + message.getId();
+ String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId());
client.delete(path);
- ZNRecord record = client.readData(HelixUtil.getLiveInstancePath(clusterName, instanceName));
- message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString())
- .toString());
+ ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName));
+ message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString()));
message.setTgtName(record.getId());
// System.out.println(message);
client.createPersistent(path, message.getRecord());
http://git-wip-us.apache.org/repos/asf/helix/blob/1b3c5c28/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java b/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
index 6422875..15d2f7b 100644
--- a/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
+++ b/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
@@ -32,86 +32,6 @@ public final class HelixUtil {
private HelixUtil() {
}
- public static String getPropertyPath(String clusterName, PropertyType type) {
- return "/" + clusterName + "/" + type.toString();
- }
-
- public static String getInstancePropertyPath(String clusterName, String instanceName,
- PropertyType type) {
- return getPropertyPath(clusterName, PropertyType.INSTANCES) + "/" + instanceName + "/"
- + type.toString();
- }
-
- public static String getInstancePath(String clusterName, String instanceName) {
- return getPropertyPath(clusterName, PropertyType.INSTANCES) + "/" + instanceName;
- }
-
- public static String getIdealStatePath(String clusterName, String resourceName) {
- return getPropertyPath(clusterName, PropertyType.IDEALSTATES) + "/" + resourceName;
- }
-
- public static String getIdealStatePath(String clusterName) {
- return getPropertyPath(clusterName, PropertyType.IDEALSTATES);
- }
-
- public static String getLiveInstancesPath(String clusterName) {
- return getPropertyPath(clusterName, PropertyType.LIVEINSTANCES);
- }
-
- public static String getMessagePath(String clusterName, String instanceName) {
- return getInstancePropertyPath(clusterName, instanceName, PropertyType.MESSAGES);
- }
-
- public static String getCurrentStateBasePath(String clusterName, String instanceName) {
- return getInstancePropertyPath(clusterName, instanceName, PropertyType.CURRENTSTATES);
- }
-
- /**
- * Even though this is simple we want to have the mechanism of bucketing the
- * partitions. If we have P partitions and N nodes with K replication factor
- * and D databases. Then on each node we will have (P/N)*K*D partitions. And
- * cluster manager neeeds to maintain watch on each of these nodes for every
- * node. So over all cluster manager will have P*K*D watches which can be
- * quite large given that we over partition.
- * The other extreme is having one znode per storage per database. This will
- * result in N*D watches which is good. But data in every node might become
- * really big since it has to save partition
- * Ideally we want to balance between the two models
- */
- public static String getCurrentStatePath(String clusterName, String instanceName,
- String sessionId, String stateUnitKey) {
- return getInstancePropertyPath(clusterName, instanceName, PropertyType.CURRENTSTATES) + "/"
- + sessionId + "/" + stateUnitKey;
- }
-
- public static String getExternalViewPath(String clusterName) {
- return getPropertyPath(clusterName, PropertyType.EXTERNALVIEW);
- }
-
- public static String getStateModelDefinitionPath(String clusterName) {
- return getPropertyPath(clusterName, PropertyType.STATEMODELDEFS);
- }
-
- public static String getExternalViewPath(String clusterName, String resourceName) {
- return getPropertyPath(clusterName, PropertyType.EXTERNALVIEW) + "/" + resourceName;
- }
-
- public static String getLiveInstancePath(String clusterName, String instanceName) {
- return getPropertyPath(clusterName, PropertyType.LIVEINSTANCES) + "/" + instanceName;
- }
-
- public static String getMemberInstancesPath(String clusterName) {
- return getPropertyPath(clusterName, PropertyType.INSTANCES);
- }
-
- public static String getErrorsPath(String clusterName, String instanceName) {
- return getInstancePropertyPath(clusterName, instanceName, PropertyType.ERRORS);
- }
-
- public static String getStatusUpdatesPath(String clusterName, String instanceName) {
- return getInstancePropertyPath(clusterName, instanceName, PropertyType.STATUSUPDATES);
- }
-
public static String getInstanceNameFromPath(String path) {
// path structure
// /<cluster_name>/instances/<instance_name>/[currentStates/messages]
@@ -124,15 +44,6 @@ public final class HelixUtil {
return null;
}
- // distributed cluster controller
- public static String getControllerPath(String clusterName) {
- return getPropertyPath(clusterName, PropertyType.CONTROLLER);
- }
-
- public static String getControllerPropertyPath(String clusterName, PropertyType type) {
- return PropertyPathBuilder.getPath(type, clusterName);
- }
-
/**
* get the parent-path of given path
* return "/" string if path = "/xxx", null if path = "/"
http://git-wip-us.apache.org/repos/asf/helix/blob/1b3c5c28/helix-core/src/test/java/org/apache/helix/ZkUnitTestBase.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/ZkUnitTestBase.java b/helix-core/src/test/java/org/apache/helix/ZkUnitTestBase.java
index 2fd9796..cd26d8a 100644
--- a/helix-core/src/test/java/org/apache/helix/ZkUnitTestBase.java
+++ b/helix-core/src/test/java/org/apache/helix/ZkUnitTestBase.java
@@ -50,7 +50,6 @@ import org.apache.helix.model.Message.MessageType;
import org.apache.helix.model.StateModelDefinition;
import org.apache.helix.tools.ClusterStateVerifier.ZkVerifier;
import org.apache.helix.tools.StateModelConfigGenerator;
-import org.apache.helix.util.HelixUtil;
import org.apache.helix.util.ZKClientPool;
import org.apache.log4j.Logger;
import org.apache.zookeeper.WatchedEvent;
@@ -102,7 +101,7 @@ public class ZkUnitTestBase {
}
protected String getCurrentLeader(ZkClient zkClient, String clusterName) {
- String leaderPath = HelixUtil.getControllerPropertyPath(clusterName, PropertyType.LEADER);
+ String leaderPath = PropertyPathBuilder.controllerLeader(clusterName);
ZNRecord leaderRecord = zkClient.<ZNRecord> readData(leaderPath);
if (leaderRecord == null) {
return null;
@@ -150,19 +149,19 @@ public class ZkUnitTestBase {
public void verifyInstance(ZkClient zkClient, String clusterName, String instance,
boolean wantExists) {
- // String instanceConfigsPath = HelixUtil.getConfigPath(clusterName);
+ // String instanceConfigsPath = PropertyPathBuilder.getConfigPath(clusterName);
String instanceConfigsPath =
PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString());
String instanceConfigPath = instanceConfigsPath + "/" + instance;
- String instancePath = HelixUtil.getInstancePath(clusterName, instance);
+ String instancePath = PropertyPathBuilder.instance(clusterName, instance);
AssertJUnit.assertEquals(wantExists, zkClient.exists(instanceConfigPath));
AssertJUnit.assertEquals(wantExists, zkClient.exists(instancePath));
}
public void verifyResource(ZkClient zkClient, String clusterName, String resource,
boolean wantExists) {
- String resourcePath = HelixUtil.getIdealStatePath(clusterName) + "/" + resource;
+ String resourcePath = PropertyPathBuilder.idealState(clusterName) + "/" + resource;
AssertJUnit.assertEquals(wantExists, zkClient.exists(resourcePath));
}
http://git-wip-us.apache.org/repos/asf/helix/blob/1b3c5c28/helix-core/src/test/java/org/apache/helix/integration/TestClusterStartsup.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestClusterStartsup.java b/helix-core/src/test/java/org/apache/helix/integration/TestClusterStartsup.java
index e844a27..51068c6 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestClusterStartsup.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestClusterStartsup.java
@@ -25,9 +25,8 @@ import org.apache.helix.HelixException;
import org.apache.helix.HelixManager;
import org.apache.helix.HelixManagerFactory;
import org.apache.helix.InstanceType;
-import org.apache.helix.PropertyType;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.tools.ClusterSetup;
-import org.apache.helix.util.HelixUtil;
import org.testng.Assert;
import org.testng.AssertJUnit;
import org.testng.annotations.AfterClass;
@@ -68,8 +67,7 @@ public class TestClusterStartsup extends ZkStandAloneCMTestBase {
@Test()
public void testParticipantStartUp() throws Exception {
setupCluster();
- String controllerMsgPath =
- HelixUtil.getControllerPropertyPath(CLUSTER_NAME, PropertyType.MESSAGES_CONTROLLER);
+ String controllerMsgPath = PropertyPathBuilder.controllerMessage(CLUSTER_NAME);
_gZkClient.deleteRecursive(controllerMsgPath);
HelixManager manager = null;
@@ -102,7 +100,7 @@ public class TestClusterStartsup extends ZkStandAloneCMTestBase {
}
setupCluster();
- String stateModelPath = HelixUtil.getStateModelDefinitionPath(CLUSTER_NAME);
+ String stateModelPath = PropertyPathBuilder.stateModelDef(CLUSTER_NAME);
_gZkClient.deleteRecursive(stateModelPath);
try {
@@ -120,8 +118,7 @@ public class TestClusterStartsup extends ZkStandAloneCMTestBase {
setupCluster();
String instanceStatusUpdatePath =
- HelixUtil.getInstancePropertyPath(CLUSTER_NAME, "localhost_" + (START_PORT + 1),
- PropertyType.STATUSUPDATES);
+ PropertyPathBuilder.instanceStatusUpdate(CLUSTER_NAME, "localhost_" + (START_PORT + 1));
_gZkClient.deleteRecursive(instanceStatusUpdatePath);
try {
http://git-wip-us.apache.org/repos/asf/helix/blob/1b3c5c28/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java b/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java
index c31e60b..17c5d62 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java
@@ -37,7 +37,7 @@ import org.apache.helix.InstanceType;
import org.apache.helix.NotificationContext;
import org.apache.helix.PropertyKey;
import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.PropertyType;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.ZNRecord;
import org.apache.helix.manager.zk.DefaultSchedulerMessageHandlerFactory;
import org.apache.helix.messaging.AsyncCallback;
@@ -51,7 +51,6 @@ import org.apache.helix.model.Message.MessageState;
import org.apache.helix.model.Message.MessageType;
import org.apache.helix.model.StatusUpdate;
import org.apache.helix.monitoring.ZKPathDataDumpTask;
-import org.apache.helix.util.HelixUtil;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
@@ -274,9 +273,7 @@ public class TestSchedulerMessage extends ZkStandAloneCMTestBase {
Assert.assertEquals(count, _PARTITIONS * 3);
// test the ZkPathDataDumpTask
- String controllerStatusPath =
- HelixUtil.getControllerPropertyPath(manager.getClusterName(),
- PropertyType.STATUSUPDATES_CONTROLLER);
+ String controllerStatusPath = PropertyPathBuilder.controllerStatusUpdate(manager.getClusterName());
List<String> subPaths = _gZkClient.getChildren(controllerStatusPath);
Assert.assertTrue(subPaths.size() > 0);
for (String subPath : subPaths) {
@@ -286,9 +283,7 @@ public class TestSchedulerMessage extends ZkStandAloneCMTestBase {
}
String instanceStatusPath =
- HelixUtil.getInstancePropertyPath(manager.getClusterName(), "localhost_" + (START_PORT),
- PropertyType.STATUSUPDATES);
-
+ PropertyPathBuilder.instanceStatusUpdate(manager.getClusterName(), "localhost_" + (START_PORT));
subPaths = _gZkClient.getChildren(instanceStatusPath);
Assert.assertTrue(subPaths.size() == 0);
for (String subPath : subPaths) {
http://git-wip-us.apache.org/repos/asf/helix/blob/1b3c5c28/helix-core/src/test/java/org/apache/helix/mock/controller/MockController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/controller/MockController.java b/helix-core/src/test/java/org/apache/helix/mock/controller/MockController.java
index 6ea3e36..6024b5c 100644
--- a/helix-core/src/test/java/org/apache/helix/mock/controller/MockController.java
+++ b/helix-core/src/test/java/org/apache/helix/mock/controller/MockController.java
@@ -28,6 +28,7 @@ import java.util.Map;
import java.util.Random;
import java.util.TreeMap;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.ZNRecord;
import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.manager.zk.ZKHelixDataAccessor;
@@ -40,7 +41,6 @@ import org.apache.helix.model.IdealState.IdealStateProperty;
import org.apache.helix.model.LiveInstance.LiveInstanceProperty;
import org.apache.helix.model.Message.MessageState;
import org.apache.helix.model.Message.MessageType;
-import org.apache.helix.util.HelixUtil;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
@@ -70,7 +70,7 @@ public class MockController {
// message.setPartitionId(partitionId);
message.setPartitionName(partitionKey);
- String path = HelixUtil.getMessagePath(clusterName, instanceName) + "/" + message.getId();
+ String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId());
ObjectMapper mapper = new ObjectMapper();
StringWriter sw = new StringWriter();
mapper.writeValueUsingView(sw, message, Message.class);
@@ -78,7 +78,7 @@ public class MockController {
client.delete(path);
Thread.sleep(10000);
- ZNRecord record = client.readData(HelixUtil.getLiveInstancePath(clusterName, instanceName));
+ ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName));
message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString())
.toString());
client.createPersistent(path, message);
http://git-wip-us.apache.org/repos/asf/helix/blob/1b3c5c28/helix-core/src/test/java/org/apache/helix/mock/spectator/MockSpectatorProcess.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/spectator/MockSpectatorProcess.java b/helix-core/src/test/java/org/apache/helix/mock/spectator/MockSpectatorProcess.java
index dd696f9..60c0003 100644
--- a/helix-core/src/test/java/org/apache/helix/mock/spectator/MockSpectatorProcess.java
+++ b/helix-core/src/test/java/org/apache/helix/mock/spectator/MockSpectatorProcess.java
@@ -26,12 +26,13 @@ import org.I0Itec.zkclient.ZkServer;
import org.apache.helix.HelixManager;
import org.apache.helix.HelixManagerFactory;
import org.apache.helix.InstanceType;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.ZNRecord;
import org.apache.helix.manager.zk.ZNRecordSerializer;
import org.apache.helix.model.InstanceConfig;
import org.apache.helix.spectator.RoutingTableProvider;
import org.apache.helix.tools.ClusterSetup;
-import org.apache.helix.util.HelixUtil;
+
/**
* A MockSpectatorProcess to demonstrate the integration with cluster manager.
@@ -58,10 +59,8 @@ public class MockSpectatorProcess {
public static void main(String[] args) throws Exception {
setup();
zkServer.getZkClient().setZkSerializer(new ZNRecordSerializer());
- ZNRecord record =
- zkServer.getZkClient().readData(HelixUtil.getIdealStatePath(clusterName, "TestDB"));
-
- String externalViewPath = HelixUtil.getExternalViewPath(clusterName, "TestDB");
+ ZNRecord record = zkServer.getZkClient().readData(PropertyPathBuilder.idealState(clusterName, "TestDB"));
+ String externalViewPath = PropertyPathBuilder.externalView(clusterName, "TestDB");
MockSpectatorProcess process = new MockSpectatorProcess();
process.start();
[9/9] helix git commit: Replace HelixDataAccessor.createProperty with
more specific methods
Posted by lx...@apache.org.
Replace HelixDataAccessor.createProperty with more specific methods
Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/9ebf3e9c
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/9ebf3e9c
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/9ebf3e9c
Branch: refs/heads/helix-0.6.x
Commit: 9ebf3e9c93cf59a0244553ba3a84df140de8699c
Parents: 1b3c5c2
Author: Junkai Xue <jx...@linkedin.com>
Authored: Sat Jan 28 17:20:55 2017 -0800
Committer: Junkai Xue <jx...@linkedin.com>
Committed: Wed Feb 1 20:19:43 2017 -0800
----------------------------------------------------------------------
.../org/apache/helix/HelixDataAccessor.java | 18 +++----
.../org/apache/helix/PropertyPathBuilder.java | 4 ++
.../manager/zk/DistributedLeaderElection.java | 3 +-
.../apache/helix/manager/zk/ZKHelixAdmin.java | 4 +-
.../helix/manager/zk/ZKHelixDataAccessor.java | 56 ++++++++++++++------
.../apache/helix/manager/zk/ZKHelixManager.java | 19 +------
.../src/test/java/org/apache/helix/Mocks.java | 30 ++++++++---
.../helix/integration/TestSchedulerMessage.java | 4 +-
.../integration/TestSchedulerMsgUsingQueue.java | 4 +-
9 files changed, 87 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/helix/blob/9ebf3e9c/helix-core/src/main/java/org/apache/helix/HelixDataAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixDataAccessor.java b/helix-core/src/main/java/org/apache/helix/HelixDataAccessor.java
index ad2c4bc..0f48539 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixDataAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixDataAccessor.java
@@ -23,6 +23,11 @@ import java.util.List;
import java.util.Map;
import org.I0Itec.zkclient.DataUpdater;
+import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.Message;
+import org.apache.helix.model.PauseSignal;
+import org.apache.helix.model.StateModelDefinition;
+
/**
* Interface used to interact with Helix Data Types like IdealState, Config,
@@ -30,15 +35,10 @@ import org.I0Itec.zkclient.DataUpdater;
* type. See {@link PropertyKey.Builder} to get more information on building a propertyKey.
*/
public interface HelixDataAccessor {
- /**
- * Create a helix property only if it does not exist.
- * @param key
- * @param value
- * @return true if creation was successful. False if already exists or if it
- * failed to create
- */
-
- <T extends HelixProperty> boolean createProperty(PropertyKey key, T value);
+ boolean createStateModelDef(StateModelDefinition stateModelDef);
+ boolean createControllerMessage(Message message);
+ boolean createControllerLeader(LiveInstance leader);
+ boolean createPause(PauseSignal pauseSignal);
/**
* Set a property, overwrite if it exists and creates if not exists. This api
http://git-wip-us.apache.org/repos/asf/helix/blob/9ebf3e9c/helix-core/src/main/java/org/apache/helix/PropertyPathBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/PropertyPathBuilder.java b/helix-core/src/main/java/org/apache/helix/PropertyPathBuilder.java
index 13ddb08..30fc0a9 100644
--- a/helix-core/src/main/java/org/apache/helix/PropertyPathBuilder.java
+++ b/helix-core/src/main/java/org/apache/helix/PropertyPathBuilder.java
@@ -295,6 +295,10 @@ public class PropertyPathBuilder {
return String.format("/%s/CONTROLLER/MESSAGES", clusterName);
}
+ public static String controllerMessage(String clusterName, String messageId) {
+ return String.format("/%s/CONTROLLER/MESSAGES/%s", clusterName, messageId);
+ }
+
public static String controllerStatusUpdate(String clusterName) {
return String.format("/%s/CONTROLLER/STATUSUPDATES", clusterName);
}
http://git-wip-us.apache.org/repos/asf/helix/blob/9ebf3e9c/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java b/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java
index d281ae4..51fdc42 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/DistributedLeaderElection.java
@@ -35,6 +35,7 @@ import org.apache.helix.model.LeaderHistory;
import org.apache.helix.model.LiveInstance;
import org.apache.log4j.Logger;
+
/**
* do distributed leader election
*/
@@ -121,7 +122,7 @@ public class DistributedLeaderElection implements ControllerChangeListener {
leader.setLiveInstance(ManagementFactory.getRuntimeMXBean().getName());
leader.setSessionId(manager.getSessionId());
leader.setHelixVersion(manager.getVersion());
- boolean success = accessor.createProperty(keyBuilder.controllerLeader(), leader);
+ boolean success = accessor.createControllerLeader(leader);
if (success) {
return true;
} else {
http://git-wip-us.apache.org/repos/asf/helix/blob/9ebf3e9c/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
index 1eaa3c6..b7cb6d4 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
@@ -58,7 +58,6 @@ import org.apache.helix.model.ConstraintItem;
import org.apache.helix.model.CurrentState;
import org.apache.helix.model.ExternalView;
import org.apache.helix.model.HelixConfigScope;
-import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
import org.apache.helix.model.IdealState;
import org.apache.helix.model.IdealState.RebalanceMode;
import org.apache.helix.model.InstanceConfig;
@@ -73,6 +72,7 @@ import org.apache.helix.tools.DefaultIdealStateCalculator;
import org.apache.helix.util.RebalanceUtil;
import org.apache.log4j.Logger;
+
public class ZKHelixAdmin implements HelixAdmin {
public static final String CONNECTION_TIMEOUT = "helixAdmin.timeOutInSec";
private final ZkClient _zkClient;
@@ -329,7 +329,7 @@ public class ZKHelixAdmin implements HelixAdmin {
if (enabled) {
accessor.removeProperty(keyBuilder.pause());
} else {
- accessor.createProperty(keyBuilder.pause(), new PauseSignal("pause"));
+ accessor.createPause(new PauseSignal("pause"));
}
}
http://git-wip-us.apache.org/repos/asf/helix/blob/9ebf3e9c/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixDataAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixDataAccessor.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixDataAccessor.java
index ed434a1..791c6d8 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixDataAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixDataAccessor.java
@@ -36,14 +36,20 @@ import org.apache.helix.HelixProperty;
import org.apache.helix.InstanceType;
import org.apache.helix.PropertyKey;
import org.apache.helix.PropertyKey.Builder;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.ZNRecord;
import org.apache.helix.ZNRecordAssembler;
import org.apache.helix.ZNRecordBucketizer;
import org.apache.helix.ZNRecordUpdater;
+import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.Message;
+import org.apache.helix.model.PauseSignal;
+import org.apache.helix.model.StateModelDefinition;
import org.apache.log4j.Logger;
import org.apache.zookeeper.data.Stat;
+
public class ZKHelixDataAccessor implements HelixDataAccessor {
private static Logger LOG = Logger.getLogger(ZKHelixDataAccessor.class);
private final BaseDataAccessor<ZNRecord> _baseDataAccessor;
@@ -65,23 +71,43 @@ public class ZKHelixDataAccessor implements HelixDataAccessor {
_propertyKeyBuilder = new PropertyKey.Builder(_clusterName);
}
- @Override
- public <T extends HelixProperty> boolean createProperty(PropertyKey key, T value) {
- PropertyType type = key.getType();
- String path = key.getPath();
- int options = constructOptions(type);
- boolean success = false;
- switch (type) {
- case STATEMODELDEFS:
- if (value.isValid()) {
- success = _baseDataAccessor.create(path, value.getRecord(), options);
+ @Override public boolean createStateModelDef(StateModelDefinition stateModelDef) {
+ String path = PropertyPathBuilder.stateModelDef(_clusterName, stateModelDef.getId());
+ HelixProperty property =
+ getProperty(new PropertyKey.Builder(_clusterName).stateModelDef(stateModelDef.getId()));
+
+ // Set new StateModelDefinition if it is different from old one.
+ if (property != null) {
+ // StateModelDefinition need to be updated
+ if (!new StateModelDefinition(property.getRecord()).equals(stateModelDef)) {
+ return stateModelDef.isValid() && _baseDataAccessor
+ .set(path, stateModelDef.getRecord(), AccessOption.PERSISTENT);
}
- break;
- default:
- success = _baseDataAccessor.create(path, value.getRecord(), options);
- break;
+ } else {
+ // StateModeDefinition does not exist
+ return stateModelDef.isValid() && _baseDataAccessor
+ .create(path, stateModelDef.getRecord(), AccessOption.PERSISTENT);
}
- return success;
+ // StateModelDefinition exists but not need to be updated
+ return true;
+ }
+
+ @Override
+ public boolean createControllerMessage(Message message) {
+ return _baseDataAccessor.create(PropertyPathBuilder.controllerMessage(_clusterName, message.getMsgId()),
+ message.getRecord(), AccessOption.PERSISTENT);
+ }
+
+ @Override
+ public boolean createControllerLeader(LiveInstance leader) {
+ return _baseDataAccessor.create(PropertyPathBuilder.controllerLeader(_clusterName), leader.getRecord(),
+ AccessOption.EPHEMERAL);
+ }
+
+ @Override
+ public boolean createPause(PauseSignal pauseSignal) {
+ return _baseDataAccessor.create(
+ PropertyPathBuilder.pause(_clusterName), pauseSignal.getRecord(), AccessOption.PERSISTENT);
}
@Override
http://git-wip-us.apache.org/repos/asf/helix/blob/9ebf3e9c/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
index 25eb653..bef2eac 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
@@ -462,24 +462,7 @@ public class ZKHelixManager implements HelixManager, IZkStateListener {
*/
private void addBuiltInStateModelDefinitions() {
for (BuiltInStateModelDefinitions def : BuiltInStateModelDefinitions.values()) {
- String path = String
- .format("/%s/STATEMODELDEFS/%s", _clusterName, def.getStateModelDefinition().getId());
-
- HelixProperty property = _dataAccessor.getProperty(new PropertyKey.Builder(_clusterName)
- .stateModelDef(def.getStateModelDefinition().getId()));
-
- // Set new StateModelDefinition if it is different from old one.
- if (property != null) {
- // StateModelDefinition need to be updated
- if (!new StateModelDefinition(property.getRecord()).equals(def.getStateModelDefinition())) {
- _baseDataAccessor
- .set(path, def.getStateModelDefinition().getRecord(), AccessOption.PERSISTENT);
- }
- } else {
- // StateModeDefinition does not exist
- _baseDataAccessor
- .create(path, def.getStateModelDefinition().getRecord(), AccessOption.PERSISTENT);
- }
+ _dataAccessor.createStateModelDef(def.getStateModelDefinition());
}
}
http://git-wip-us.apache.org/repos/asf/helix/blob/9ebf3e9c/helix-core/src/test/java/org/apache/helix/Mocks.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/Mocks.java b/helix-core/src/test/java/org/apache/helix/Mocks.java
index 0fb7d9e..7d27693 100644
--- a/helix-core/src/test/java/org/apache/helix/Mocks.java
+++ b/helix-core/src/test/java/org/apache/helix/Mocks.java
@@ -38,7 +38,10 @@ import org.apache.helix.messaging.handling.HelixTaskResult;
import org.apache.helix.messaging.handling.MessageHandlerFactory;
import org.apache.helix.messaging.handling.MessageTask;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.LiveInstance;
import org.apache.helix.model.Message;
+import org.apache.helix.model.PauseSignal;
+import org.apache.helix.model.StateModelDefinition;
import org.apache.helix.participant.StateMachineEngine;
import org.apache.helix.participant.statemachine.StateModel;
import org.apache.helix.participant.statemachine.StateModelInfo;
@@ -46,6 +49,7 @@ import org.apache.helix.participant.statemachine.Transition;
import org.apache.helix.store.zk.ZkHelixPropertyStore;
import org.apache.zookeeper.data.Stat;
+
public class Mocks {
public static class MockBaseDataAccessor implements BaseDataAccessor<ZNRecord> {
Map<String, ZNRecord> map = new HashMap<String, ZNRecord>();
@@ -471,6 +475,26 @@ public class Mocks {
Map<String, ZNRecord> map = new HashMap<String, ZNRecord>();
@Override
+ public boolean createStateModelDef(StateModelDefinition stateModelDef) {
+ return false;
+ }
+
+ @Override
+ public boolean createControllerMessage(Message message) {
+ return false;
+ }
+
+ @Override
+ public boolean createControllerLeader(LiveInstance leader) {
+ return false;
+ }
+
+ @Override
+ public boolean createPause(PauseSignal pauseSignal) {
+ return false;
+ }
+
+ @Override
public boolean setProperty(PropertyKey key, HelixProperty value) {
String path = key.getPath();
data.put(path, value.getRecord());
@@ -570,12 +594,6 @@ public class Mocks {
}
@Override
- public <T extends HelixProperty> boolean createProperty(PropertyKey key, T value) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
public <T extends HelixProperty> boolean[] createChildren(List<PropertyKey> keys,
List<T> children) {
// TODO Auto-generated method stub
http://git-wip-us.apache.org/repos/asf/helix/blob/9ebf3e9c/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java b/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java
index 17c5d62..8c239f5 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java
@@ -58,6 +58,7 @@ import org.codehaus.jackson.map.SerializationConfig;
import org.testng.Assert;
import org.testng.annotations.Test;
+
public class TestSchedulerMessage extends ZkStandAloneCMTestBase {
public static class MockAsyncCallback extends AsyncCallback {
@@ -232,8 +233,7 @@ public class TestSchedulerMessage extends ZkStandAloneCMTestBase {
HelixDataAccessor helixDataAccessor = manager.getHelixDataAccessor();
Builder keyBuilder = helixDataAccessor.keyBuilder();
- helixDataAccessor.createProperty(keyBuilder.controllerMessage(schedulerMessage.getMsgId()),
- schedulerMessage);
+ helixDataAccessor.createControllerMessage(schedulerMessage);
for (int i = 0; i < 30; i++) {
Thread.sleep(2000);
http://git-wip-us.apache.org/repos/asf/helix/blob/9ebf3e9c/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMsgUsingQueue.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMsgUsingQueue.java b/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMsgUsingQueue.java
index d5b5680..e7deefa 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMsgUsingQueue.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMsgUsingQueue.java
@@ -38,6 +38,7 @@ import org.codehaus.jackson.map.SerializationConfig;
import org.testng.Assert;
import org.testng.annotations.Test;
+
public class TestSchedulerMsgUsingQueue extends ZkStandAloneCMTestBase {
TestSchedulerMessage.TestMessagingHandlerFactory _factory =
new TestSchedulerMessage.TestMessagingHandlerFactory();
@@ -91,8 +92,7 @@ public class TestSchedulerMsgUsingQueue extends ZkStandAloneCMTestBase {
HelixDataAccessor helixDataAccessor = manager.getHelixDataAccessor();
PropertyKey.Builder keyBuilder = helixDataAccessor.keyBuilder();
- helixDataAccessor.createProperty(keyBuilder.controllerMessage(schedulerMessage.getMsgId()),
- schedulerMessage);
+ helixDataAccessor.createControllerMessage(schedulerMessage);
for (int i = 0; i < 30; i++) {
Thread.sleep(2000);
[2/9] helix git commit: Add test for SEMI_AUTO
Posted by lx...@apache.org.
Add test for SEMI_AUTO
Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/fb7496f0
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/fb7496f0
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/fb7496f0
Branch: refs/heads/helix-0.6.x
Commit: fb7496f0a176f8b645563809fc7035f3acc1b102
Parents: cff462f
Author: Junkai Xue <jx...@linkedin.com>
Authored: Sat Jan 28 16:33:17 2017 -0800
Committer: Junkai Xue <jx...@linkedin.com>
Committed: Sat Jan 28 16:33:17 2017 -0800
----------------------------------------------------------------------
.../integration/TestSemiAutoRebalance.java | 228 +++++++++++++++++++
1 file changed, 228 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/helix/blob/fb7496f0/helix-core/src/test/java/org/apache/helix/integration/TestSemiAutoRebalance.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestSemiAutoRebalance.java b/helix-core/src/test/java/org/apache/helix/integration/TestSemiAutoRebalance.java
new file mode 100644
index 0000000..9a7ebdb
--- /dev/null
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestSemiAutoRebalance.java
@@ -0,0 +1,228 @@
+package org.apache.helix.integration;
+
+/*
+ * 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 java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.integration.manager.ClusterControllerManager;
+import org.apache.helix.integration.manager.MockParticipantManager;
+import org.apache.helix.manager.zk.ZKHelixDataAccessor;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
+import org.apache.helix.model.MasterSlaveSMD;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class TestSemiAutoRebalance extends ZkIntegrationTestBase {
+ protected final String CLASS_NAME = getShortClassName();
+ protected final String CLUSTER_NAME = CLUSTER_PREFIX + "_" + CLASS_NAME;
+
+ protected static final int PARTICIPANT_NUMBER = 5;
+ protected static final int PARTICIPANT_START_PORT = 12918;
+
+ protected static final String DB_NAME = "TestDB";
+ protected static final int PARTITION_NUMBER = 20;
+ protected static final int REPLICA_NUMBER = 3;
+ protected static final String STATE_MODEL = "MasterSlave";
+
+ protected List<MockParticipantManager> _participants = new ArrayList<MockParticipantManager>();
+ protected ClusterControllerManager _controller;
+
+ protected HelixDataAccessor _accessor;
+ protected PropertyKey.Builder _keyBuilder;
+
+ @BeforeClass
+ public void beforeClass()
+ throws InterruptedException {
+ System.out.println(
+ "START " + getShortClassName() + " at " + new Date(System.currentTimeMillis()));
+
+ String namespace = "/" + CLUSTER_NAME;
+ if (_gZkClient.exists(namespace)) {
+ _gZkClient.deleteRecursive(namespace);
+ }
+
+ // setup storage cluster
+ _gSetupTool.addCluster(CLUSTER_NAME, true);
+ _gSetupTool.addResourceToCluster(CLUSTER_NAME, DB_NAME, PARTITION_NUMBER, STATE_MODEL,
+ IdealState.RebalanceMode.SEMI_AUTO.toString());
+
+ _accessor = new ZKHelixDataAccessor(CLUSTER_NAME, _baseAccessor);
+ _keyBuilder = _accessor.keyBuilder();
+
+ List<String> instances = new ArrayList<String>();
+ for (int i = 0; i < PARTICIPANT_NUMBER; i++) {
+ String instance = PARTICIPANT_PREFIX + "_" + (PARTICIPANT_START_PORT + i);
+ _gSetupTool.addInstanceToCluster(CLUSTER_NAME, instance);
+ instances.add(instance);
+ }
+
+ _gSetupTool.rebalanceStorageCluster(CLUSTER_NAME, DB_NAME, REPLICA_NUMBER);
+
+ // start dummy participants
+ for (int i = 0; i < PARTICIPANT_NUMBER; i++) {
+ MockParticipantManager participant =
+ new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instances.get(i));
+ participant.syncStart();
+ _participants.add(participant);
+ }
+
+ // start controller
+ String controllerName = CONTROLLER_PREFIX + "_0";
+ _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
+ _controller.syncStart();
+
+ Thread.sleep(1000);
+
+ // verify ideal state and external view
+ IdealState idealState = _accessor.getProperty(_keyBuilder.idealStates(DB_NAME));
+ Assert.assertNotNull(idealState);
+ Assert.assertEquals(idealState.getNumPartitions(), PARTITION_NUMBER);
+ for (String partition : idealState.getPartitionSet()) {
+ List<String> preferenceList = idealState.getPreferenceList(partition);
+ Assert.assertNotNull(preferenceList);
+ Assert.assertEquals(preferenceList.size(), REPLICA_NUMBER);
+ }
+
+ ExternalView externalView = _accessor.getProperty(_keyBuilder.externalView(DB_NAME));
+ Assert.assertNotNull(externalView);
+ Assert.assertEquals(externalView.getPartitionSet().size(), PARTITION_NUMBER);
+ for (String partition : externalView.getPartitionSet()) {
+ Map<String, String> stateMap = externalView.getStateMap(partition);
+ Assert.assertEquals(stateMap.size(), REPLICA_NUMBER);
+
+ int masters = 0;
+ for (String state : stateMap.values()) {
+ if (state.equals(MasterSlaveSMD.States.MASTER.name())) {
+ ++masters;
+ }
+ }
+ Assert.assertEquals(masters, 1);
+ }
+ }
+
+ @Test
+ public void testAddParticipant()
+ throws InterruptedException {
+ String newInstance = PARTICIPANT_PREFIX + "_" + (PARTICIPANT_START_PORT + _participants.size());
+ _gSetupTool.addInstanceToCluster(CLUSTER_NAME, newInstance);
+
+ MockParticipantManager newParticipant =
+ new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, newInstance);
+ newParticipant.syncStart();
+
+ Thread.sleep(1000);
+
+ List<String> instances = _accessor.getChildNames(_keyBuilder.instanceConfigs());
+ Assert.assertEquals(instances.size(), _participants.size() + 1);
+ Assert.assertTrue(instances.contains(newInstance));
+
+ List<String> liveInstances = _accessor.getChildNames(_keyBuilder.liveInstances());
+ Assert.assertEquals(liveInstances.size(), _participants.size() + 1);
+ Assert.assertTrue(liveInstances.contains(newInstance));
+
+ // nothing for new participant
+ ExternalView externalView = _accessor.getProperty(_keyBuilder.externalView(DB_NAME));
+ Assert.assertNotNull(externalView);
+ for (String partition : externalView.getPartitionSet()) {
+ Map<String, String> stateMap = externalView.getStateMap(partition);
+ Assert.assertFalse(stateMap.containsKey(newInstance));
+ }
+
+ // clear
+ newParticipant.syncStop();
+ _gSetupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME, newInstance, false);
+ _gSetupTool.dropInstanceFromCluster(CLUSTER_NAME, newInstance);
+
+ instances = _accessor.getChildNames(_keyBuilder.instanceConfigs());
+ Assert.assertEquals(instances.size(), _participants.size());
+
+ liveInstances = _accessor.getChildNames(_keyBuilder.liveInstances());
+ Assert.assertEquals(liveInstances.size(), _participants.size());
+ }
+
+ @Test(dependsOnMethods = "testAddParticipant")
+ public void testStopAndReStartParticipant()
+ throws InterruptedException {
+ MockParticipantManager participant = _participants.get(0);
+ String instance = participant.getInstanceName();
+
+ Map<String, MasterSlaveSMD.States> affectedPartitions =
+ new HashMap<String, MasterSlaveSMD.States>();
+
+ ExternalView externalView = _accessor.getProperty(_keyBuilder.externalView(DB_NAME));
+
+ for (String partition : externalView.getPartitionSet()) {
+ Map<String, String> stateMap = externalView.getStateMap(partition);
+ if (stateMap.containsKey(instance)) {
+ affectedPartitions.put(partition, MasterSlaveSMD.States.valueOf(stateMap.get(instance)));
+ }
+ }
+
+ stopParticipant(participant, affectedPartitions);
+
+ // create a new participant
+ participant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instance);
+ _participants.set(0, participant);
+ startParticipant(participant, affectedPartitions);
+ }
+
+ private void stopParticipant(
+ MockParticipantManager participant, Map<String, MasterSlaveSMD.States> affectedPartitions)
+ throws InterruptedException {
+ participant.syncStop();
+
+ Thread.sleep(1000);
+
+ ExternalView externalView = _accessor.getProperty(_keyBuilder.externalView(DB_NAME));
+ // No re-assignment of partition, if a MASTER is removed, one of SLAVE would be prompted
+ for (Map.Entry<String, MasterSlaveSMD.States> entry : affectedPartitions.entrySet()) {
+ Map<String, String> stateMap = externalView.getStateMap(entry.getKey());
+ Assert.assertEquals(stateMap.size(), REPLICA_NUMBER - 1);
+ Assert.assertTrue(stateMap.values().contains(MasterSlaveSMD.States.MASTER.toString()));
+ }
+ }
+
+ private void startParticipant(
+ MockParticipantManager participant, Map<String, MasterSlaveSMD.States> affectedPartitions)
+ throws InterruptedException {
+ String instance = participant.getInstanceName();
+ participant.syncStart();
+
+ Thread.sleep(1000);
+
+ ExternalView externalView = _accessor.getProperty(_keyBuilder.externalView(DB_NAME));
+ // Everything back to the initial state
+ for (Map.Entry<String, MasterSlaveSMD.States> entry : affectedPartitions.entrySet()) {
+ Map<String, String> stateMap = externalView.getStateMap(entry.getKey());
+ Assert.assertEquals(stateMap.size(), REPLICA_NUMBER);
+
+ Assert.assertTrue(stateMap.containsKey(instance));
+ Assert.assertEquals(stateMap.get(instance), entry.getValue().toString());
+ }
+ }
+}
[8/9] helix git commit: Assign orders for tests in
TestSchedulerMessage
Posted by lx...@apache.org.
Assign orders for tests in TestSchedulerMessage
Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/e9b4f6a1
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/e9b4f6a1
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/e9b4f6a1
Branch: refs/heads/helix-0.6.x
Commit: e9b4f6a1c13c28ce725f265e13ccfc7b860e33a5
Parents: e0f9f96
Author: Junkai Xue <jx...@linkedin.com>
Authored: Sat Jan 28 16:46:01 2017 -0800
Committer: Junkai Xue <jx...@linkedin.com>
Committed: Wed Feb 1 20:19:43 2017 -0800
----------------------------------------------------------------------
.../helix/integration/TestSchedulerMessage.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/helix/blob/e9b4f6a1/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java b/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java
index ef2e18d..c31e60b 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestSchedulerMessage.java
@@ -185,7 +185,7 @@ public class TestSchedulerMessage extends ZkStandAloneCMTestBase {
}
}
- @Test()
+ @Test(dependsOnMethods = "testSchedulerZeroMsg")
public void testSchedulerMsg() throws Exception {
Logger.getRootLogger().setLevel(Level.INFO);
_factory._results.clear();
@@ -325,13 +325,13 @@ public class TestSchedulerMessage extends ZkStandAloneCMTestBase {
}
}
- @Test()
+ @Test
public void testSchedulerZeroMsg() throws Exception {
- TestMessagingHandlerFactory factory = new TestMessagingHandlerFactory();
+ _factory._results.clear();
HelixManager manager = null;
for (int i = 0; i < NODE_NR; i++) {
_participants[i].getMessagingService().registerMessageHandlerFactory(
- factory.getMessageType(), factory);
+ _factory.getMessageType(), _factory);
manager = _participants[i]; // _startCMResultMap.get(hostDest)._manager;
}
@@ -344,7 +344,7 @@ public class TestSchedulerMessage extends ZkStandAloneCMTestBase {
schedulerMessage.setSrcName("CONTROLLER");
// Template for the individual message sent to each participant
- Message msg = new Message(factory.getMessageType(), "Template");
+ Message msg = new Message(_factory.getMessageType(), "Template");
msg.setTgtSessionId("*");
msg.setMsgState(MessageState.NEW);
@@ -376,7 +376,7 @@ public class TestSchedulerMessage extends ZkStandAloneCMTestBase {
Thread.sleep(3000);
- Assert.assertEquals(0, factory._results.size());
+ Assert.assertEquals(0, _factory._results.size());
PropertyKey controllerTaskStatus =
keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.toString(),
schedulerMessage.getMsgId());
@@ -389,13 +389,13 @@ public class TestSchedulerMessage extends ZkStandAloneCMTestBase {
ZNRecord statusUpdate = helixDataAccessor.getProperty(controllerTaskStatus).getRecord();
Assert.assertTrue(statusUpdate.getMapField("SentMessageCount").get("MessageCount").equals("0"));
int count = 0;
- for (Set<String> val : factory._results.values()) {
+ for (Set<String> val : _factory._results.values()) {
count += val.size();
}
Assert.assertEquals(count, 0);
}
- @Test()
+ @Test(dependsOnMethods = "testSchedulerMsg")
public void testSchedulerMsg3() throws Exception {
_factory._results.clear();
Thread.sleep(2000);
@@ -517,7 +517,7 @@ public class TestSchedulerMessage extends ZkStandAloneCMTestBase {
}
}
- @Test()
+ @Test(dependsOnMethods = "testSchedulerMsg3")
public void testSchedulerMsg4() throws Exception {
_factory._results.clear();
HelixManager manager = null;
[5/9] helix git commit: Refactor isClusterSetup log structure for
debugging purpose
Posted by lx...@apache.org.
Refactor isClusterSetup log structure for debugging purpose
Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/5ee5e59b
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/5ee5e59b
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/5ee5e59b
Branch: refs/heads/helix-0.6.x
Commit: 5ee5e59ba2eb86019fbef69e10f02d7bd73eedd5
Parents: 9ebf3e9
Author: Junkai Xue <jx...@linkedin.com>
Authored: Sat Jan 28 17:38:41 2017 -0800
Committer: Junkai Xue <jx...@linkedin.com>
Committed: Wed Feb 1 20:19:43 2017 -0800
----------------------------------------------------------------------
.../org/apache/helix/manager/zk/ZKUtil.java | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/helix/blob/5ee5e59b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java
index 2e19484..2840dbb 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java
@@ -42,7 +42,13 @@ public final class ZKUtil {
}
public static boolean isClusterSetup(String clusterName, ZkClient zkClient) {
- if (clusterName == null || zkClient == null) {
+ if (clusterName == null) {
+ logger.info("Fail to check cluster setup : cluster name is null!");
+ return false;
+ }
+
+ if (zkClient == null) {
+ logger.info("Fail to check cluster setup : zookeeper client is null!");
return false;
}
ArrayList<String> requiredPaths = new ArrayList<String>();
@@ -68,14 +74,20 @@ public final class ZKUtil {
BaseDataAccessor<Object> baseAccessor = new ZkBaseDataAccessor<Object>(zkClient);
boolean[] ret = baseAccessor.exists(requiredPaths, 0);
+ StringBuilder errorMsg = new StringBuilder();
+
for (int i = 0; i < ret.length; i++) {
if (!ret[i]) {
isValid = false;
- if (logger.isDebugEnabled()) {
- logger.debug("Invalid cluster setup, missing znode path: " + requiredPaths.get(i));
- }
+ errorMsg
+ .append(("Invalid cluster setup, missing znode path: " + requiredPaths.get(i)) + "\n");
}
}
+
+ if (!isValid) {
+ logger.info(errorMsg.toString());
+ }
+
return isValid;
}
[7/9] helix git commit: Rename PropertyPathConfig to
PropertyPathBuilder
Posted by lx...@apache.org.
Rename PropertyPathConfig to PropertyPathBuilder
Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/0b7a1a0f
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/0b7a1a0f
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/0b7a1a0f
Branch: refs/heads/helix-0.6.x
Commit: 0b7a1a0fc93bf1f4699c45b7427663a17e94fc99
Parents: e9b4f6a
Author: Junkai Xue <jx...@linkedin.com>
Authored: Sat Jan 28 16:55:24 2017 -0800
Committer: Junkai Xue <jx...@linkedin.com>
Committed: Wed Feb 1 20:19:43 2017 -0800
----------------------------------------------------------------------
.../helix/webapp/resources/JobResource.java | 2 -
.../resources/SchedulerTasksResource.java | 4 +-
.../webapp/TestClusterManagementWebapp.java | 4 +-
.../main/java/org/apache/helix/PropertyKey.java | 3 +-
.../org/apache/helix/PropertyPathBuilder.java | 204 +++++++++++++++++++
.../org/apache/helix/PropertyPathConfig.java | 204 -------------------
.../helix/manager/zk/CallbackHandler.java | 6 +-
.../apache/helix/manager/zk/ZKHelixAdmin.java | 36 ++--
.../apache/helix/manager/zk/ZKHelixManager.java | 4 +-
.../org/apache/helix/manager/zk/ZKUtil.java | 40 ++--
.../java/org/apache/helix/task/TaskDriver.java | 4 +-
.../helix/tools/ClusterStateVerifier.java | 4 +-
.../java/org/apache/helix/util/HelixUtil.java | 4 +-
.../src/test/java/org/apache/helix/Mocks.java | 4 +-
.../apache/helix/TestPropertyPathBuilder.java | 53 +++++
.../apache/helix/TestPropertyPathConfig.java | 53 -----
.../java/org/apache/helix/ZkUnitTestBase.java | 2 +-
.../TestAddNodeAfterControllerStart.java | 10 +-
.../integration/TestAutoIsWithEmptyMap.java | 4 +-
.../integration/TestCarryOverBadCurState.java | 4 +-
.../apache/helix/integration/TestDriver.java | 4 +-
.../integration/TestEnableCompression.java | 7 +-
.../helix/integration/TestMessageThrottle.java | 4 +-
.../helix/integration/TestNullReplica.java | 4 +-
...estStartMultipleControllersWithSameName.java | 4 +-
.../manager/TestParticipantManager.java | 4 +-
.../task/TestTaskRebalancerStopResume.java | 4 +-
.../zk/TestWtCacheAsyncOpMultiThread.java | 14 +-
.../zk/TestWtCacheAsyncOpSingleThread.java | 22 +-
.../zk/TestWtCacheSyncOpSingleThread.java | 20 +-
.../org/apache/helix/manager/zk/TestZKUtil.java | 14 +-
.../manager/zk/TestZkBaseDataAccessor.java | 39 ++--
.../zk/TestZkCacheAsyncOpSingleThread.java | 26 +--
.../zk/TestZkCacheSyncOpSingleThread.java | 10 +-
.../helix/manager/zk/TestZkHelixAdmin.java | 8 +-
.../participant/TestDistControllerElection.java | 8 +-
.../apache/helix/tools/TestClusterSetup.java | 5 +-
37 files changed, 412 insertions(+), 434 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/JobResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/JobResource.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/JobResource.java
index d31c81b..42f700a 100644
--- a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/JobResource.java
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/JobResource.java
@@ -22,8 +22,6 @@ package org.apache.helix.webapp.resources;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixProperty;
import org.apache.helix.PropertyKey;
-import org.apache.helix.PropertyPathConfig;
-import org.apache.helix.PropertyType;
import org.apache.helix.ZNRecord;
import org.apache.helix.manager.zk.ZkClient;
import org.apache.helix.task.JobContext;
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java
index b9083bb..76cb7a6 100644
--- a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java
@@ -29,7 +29,7 @@ import java.util.UUID;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixException;
import org.apache.helix.InstanceType;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.manager.zk.DefaultSchedulerMessageHandlerFactory;
import org.apache.helix.manager.zk.ZkClient;
@@ -148,7 +148,7 @@ public class SchedulerTasksResource extends ServerResource {
schedulerMessage);
Map<String, String> resultMap = new HashMap<String, String>();
- resultMap.put("StatusUpdatePath", PropertyPathConfig.getPath(
+ resultMap.put("StatusUpdatePath", PropertyPathBuilder.getPath(
PropertyType.STATUSUPDATES_CONTROLLER, clusterName, MessageType.SCHEDULER_MSG.toString(),
schedulerMessage.getMsgId()));
resultMap.put("MessageType", Message.MessageType.SCHEDULER_MSG.toString());
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java
index b645dfd..3ee3fde 100644
--- a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java
+++ b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java
@@ -26,7 +26,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.ZNRecord;
import org.apache.helix.model.InstanceConfig.InstanceConfigProperty;
@@ -562,7 +562,7 @@ public class TestClusterManagementWebapp extends AdminTestBase {
System.out.println(sw.toString());
// verify pause znode exists
- String pausePath = PropertyPathConfig.getPath(PropertyType.PAUSE, clusterName);
+ String pausePath = PropertyPathBuilder.getPath(PropertyType.PAUSE, clusterName);
System.out.println("pausePath: " + pausePath);
boolean exists = _gZkClient.exists(pausePath);
Assert.assertTrue(exists, pausePath + " should exist");
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/main/java/org/apache/helix/PropertyKey.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/PropertyKey.java b/helix-core/src/main/java/org/apache/helix/PropertyKey.java
index 0125902..7265a7e 100644
--- a/helix-core/src/main/java/org/apache/helix/PropertyKey.java
+++ b/helix-core/src/main/java/org/apache/helix/PropertyKey.java
@@ -54,7 +54,6 @@ import org.apache.helix.model.PauseSignal;
import org.apache.helix.model.ResourceConfig;
import org.apache.helix.model.StateModelDefinition;
import org.apache.helix.model.StatusUpdate;
-import org.apache.helix.tools.YAMLClusterSetup;
import org.apache.log4j.Logger;
/**
@@ -116,7 +115,7 @@ public class PropertyKey {
public String getPath() {
String clusterName = _params[0];
String[] subKeys = Arrays.copyOfRange(_params, 1, _params.length);
- String path = PropertyPathConfig.getPath(_type, clusterName, subKeys);
+ String path = PropertyPathBuilder.getPath(_type, clusterName, subKeys);
if (path == null) {
LOG.error("Invalid property key with type:" + _type + "subKeys:" + Arrays.toString(_params));
}
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/main/java/org/apache/helix/PropertyPathBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/PropertyPathBuilder.java b/helix-core/src/main/java/org/apache/helix/PropertyPathBuilder.java
new file mode 100644
index 0000000..5773c60
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/PropertyPathBuilder.java
@@ -0,0 +1,204 @@
+package org.apache.helix;
+
+/*
+ * 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 static org.apache.helix.PropertyType.CONFIGS;
+import static org.apache.helix.PropertyType.CURRENTSTATES;
+import static org.apache.helix.PropertyType.EXTERNALVIEW;
+import static org.apache.helix.PropertyType.HISTORY;
+import static org.apache.helix.PropertyType.IDEALSTATES;
+import static org.apache.helix.PropertyType.LIVEINSTANCES;
+import static org.apache.helix.PropertyType.MESSAGES;
+import static org.apache.helix.PropertyType.PAUSE;
+import static org.apache.helix.PropertyType.STATEMODELDEFS;
+import static org.apache.helix.PropertyType.STATUSUPDATES;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.helix.model.CurrentState;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
+import org.apache.helix.model.InstanceConfig;
+import org.apache.helix.model.LeaderHistory;
+import org.apache.helix.model.LiveInstance;
+import org.apache.helix.model.Message;
+import org.apache.helix.model.PauseSignal;
+import org.apache.helix.model.StateModelDefinition;
+import org.apache.helix.model.StatusUpdate;
+import org.apache.log4j.Logger;
+
+/**
+ * Utility mapping properties to their Zookeeper locations
+ */
+public class PropertyPathBuilder {
+ private static Logger logger = Logger.getLogger(PropertyPathBuilder.class);
+
+ static final Map<PropertyType, Map<Integer, String>> templateMap =
+ new HashMap<PropertyType, Map<Integer, String>>();
+ static final Map<PropertyType, Class<? extends HelixProperty>> typeToClassMapping =
+ new HashMap<PropertyType, Class<? extends HelixProperty>>();
+ static {
+ typeToClassMapping.put(LIVEINSTANCES, LiveInstance.class);
+ typeToClassMapping.put(IDEALSTATES, IdealState.class);
+ typeToClassMapping.put(CONFIGS, InstanceConfig.class);
+ typeToClassMapping.put(EXTERNALVIEW, ExternalView.class);
+ typeToClassMapping.put(STATEMODELDEFS, StateModelDefinition.class);
+ typeToClassMapping.put(MESSAGES, Message.class);
+ typeToClassMapping.put(CURRENTSTATES, CurrentState.class);
+ typeToClassMapping.put(STATUSUPDATES, StatusUpdate.class);
+ typeToClassMapping.put(HISTORY, LeaderHistory.class);
+ typeToClassMapping.put(PAUSE, PauseSignal.class);
+
+ // @formatter:off
+ addEntry(PropertyType.CONFIGS, 1, "/{clusterName}/CONFIGS");
+ addEntry(PropertyType.CONFIGS, 2, "/{clusterName}/CONFIGS/{scope}");
+ addEntry(PropertyType.CONFIGS, 3, "/{clusterName}/CONFIGS/{scope}/{scopeKey}");
+ // addEntry(PropertyType.CONFIGS,2,"/{clusterName}/CONFIGS/{instanceName}");
+ addEntry(PropertyType.LIVEINSTANCES, 1, "/{clusterName}/LIVEINSTANCES");
+ addEntry(PropertyType.LIVEINSTANCES, 2, "/{clusterName}/LIVEINSTANCES/{instanceName}");
+ addEntry(PropertyType.INSTANCES, 1, "/{clusterName}/INSTANCES");
+ addEntry(PropertyType.INSTANCES, 2, "/{clusterName}/INSTANCES/{instanceName}");
+ addEntry(PropertyType.IDEALSTATES, 1, "/{clusterName}/IDEALSTATES");
+ addEntry(PropertyType.IDEALSTATES, 2, "/{clusterName}/IDEALSTATES/{resourceName}");
+ addEntry(PropertyType.EXTERNALVIEW, 1, "/{clusterName}/EXTERNALVIEW");
+ addEntry(PropertyType.EXTERNALVIEW, 2, "/{clusterName}/EXTERNALVIEW/{resourceName}");
+ addEntry(PropertyType.STATEMODELDEFS, 1, "/{clusterName}/STATEMODELDEFS");
+ addEntry(PropertyType.STATEMODELDEFS, 2, "/{clusterName}/STATEMODELDEFS/{stateModelName}");
+ addEntry(PropertyType.CONTROLLER, 1, "/{clusterName}/CONTROLLER");
+ addEntry(PropertyType.PROPERTYSTORE, 1, "/{clusterName}/PROPERTYSTORE");
+
+ // INSTANCE
+ addEntry(PropertyType.MESSAGES, 2, "/{clusterName}/INSTANCES/{instanceName}/MESSAGES");
+ addEntry(PropertyType.MESSAGES, 3, "/{clusterName}/INSTANCES/{instanceName}/MESSAGES/{msgId}");
+ addEntry(PropertyType.CURRENTSTATES, 2, "/{clusterName}/INSTANCES/{instanceName}/CURRENTSTATES");
+ addEntry(PropertyType.CURRENTSTATES, 3,
+ "/{clusterName}/INSTANCES/{instanceName}/CURRENTSTATES/{sessionId}");
+ addEntry(PropertyType.CURRENTSTATES, 4,
+ "/{clusterName}/INSTANCES/{instanceName}/CURRENTSTATES/{sessionId}/{resourceName}");
+ addEntry(PropertyType.CURRENTSTATES, 5,
+ "/{clusterName}/INSTANCES/{instanceName}/CURRENTSTATES/{sessionId}/{resourceName}/{bucketName}");
+ addEntry(PropertyType.STATUSUPDATES, 2, "/{clusterName}/INSTANCES/{instanceName}/STATUSUPDATES");
+ addEntry(PropertyType.STATUSUPDATES, 3,
+ "/{clusterName}/INSTANCES/{instanceName}/STATUSUPDATES/{sessionId}");
+ addEntry(PropertyType.STATUSUPDATES, 4,
+ "/{clusterName}/INSTANCES/{instanceName}/STATUSUPDATES/{sessionId}/{subPath}");
+ addEntry(PropertyType.STATUSUPDATES, 5,
+ "/{clusterName}/INSTANCES/{instanceName}/STATUSUPDATES/{sessionId}/{subPath}/{recordName}");
+ addEntry(PropertyType.ERRORS, 2, "/{clusterName}/INSTANCES/{instanceName}/ERRORS");
+ addEntry(PropertyType.ERRORS, 3, "/{clusterName}/INSTANCES/{instanceName}/ERRORS/{sessionId}");
+ addEntry(PropertyType.ERRORS, 4,
+ "/{clusterName}/INSTANCES/{instanceName}/ERRORS/{sessionId}/{subPath}");
+ addEntry(PropertyType.ERRORS, 5,
+ "/{clusterName}/INSTANCES/{instanceName}/ERRORS/{sessionId}/{subPath}/{recordName}");
+ addEntry(PropertyType.HEALTHREPORT, 2, "/{clusterName}/INSTANCES/{instanceName}/HEALTHREPORT");
+ addEntry(PropertyType.HEALTHREPORT, 3,
+ "/{clusterName}/INSTANCES/{instanceName}/HEALTHREPORT/{reportName}");
+ // CONTROLLER
+ addEntry(PropertyType.MESSAGES_CONTROLLER, 1, "/{clusterName}/CONTROLLER/MESSAGES");
+ addEntry(PropertyType.MESSAGES_CONTROLLER, 2, "/{clusterName}/CONTROLLER/MESSAGES/{msgId}");
+ addEntry(PropertyType.ERRORS_CONTROLLER, 1, "/{clusterName}/CONTROLLER/ERRORS");
+ addEntry(PropertyType.ERRORS_CONTROLLER, 2, "/{clusterName}/CONTROLLER/ERRORS/{errorId}");
+ addEntry(PropertyType.STATUSUPDATES_CONTROLLER, 1, "/{clusterName}/CONTROLLER/STATUSUPDATES");
+ addEntry(PropertyType.STATUSUPDATES_CONTROLLER, 2,
+ "/{clusterName}/CONTROLLER/STATUSUPDATES/{subPath}");
+ addEntry(PropertyType.STATUSUPDATES_CONTROLLER, 3,
+ "/{clusterName}/CONTROLLER/STATUSUPDATES/{subPath}/{recordName}");
+ addEntry(PropertyType.LEADER, 1, "/{clusterName}/CONTROLLER/LEADER");
+ addEntry(PropertyType.HISTORY, 1, "/{clusterName}/CONTROLLER/HISTORY");
+ addEntry(PropertyType.PAUSE, 1, "/{clusterName}/CONTROLLER/PAUSE");
+ // @formatter:on
+
+ }
+ static Pattern pattern = Pattern.compile("(\\{.+?\\})");
+
+ private static void addEntry(PropertyType type, int numKeys, String template) {
+ if (!templateMap.containsKey(type)) {
+ templateMap.put(type, new HashMap<Integer, String>());
+ }
+ logger.trace("Adding template for type:" + type.getType() + " arguments:" + numKeys
+ + " template:" + template);
+ templateMap.get(type).put(numKeys, template);
+ }
+
+ /**
+ * Get the Zookeeper path given the property type, cluster, and parameters
+ * @param type
+ * @param clusterName
+ * @param keys
+ * @return a valid path, or null if none exists
+ */
+ public static String getPath(PropertyType type, String clusterName, String... keys) {
+ if (clusterName == null) {
+ logger.warn("ClusterName can't be null for type:" + type);
+ return null;
+ }
+ if (keys == null) {
+ keys = new String[] {};
+ }
+ String template = null;
+ if (templateMap.containsKey(type)) {
+ // keys.length+1 since we add clusterName
+ template = templateMap.get(type).get(keys.length + 1);
+ }
+
+ String result = null;
+
+ if (template != null) {
+ result = template;
+ Matcher matcher = pattern.matcher(template);
+ int count = 0;
+ while (matcher.find()) {
+ count = count + 1;
+ String var = matcher.group();
+ if (count == 1) {
+ result = result.replace(var, clusterName);
+ } else {
+ result = result.replace(var, keys[count - 2]);
+ }
+ }
+ }
+ if (result == null || result.indexOf('{') > -1 || result.indexOf('}') > -1) {
+ logger.warn("Unable to instantiate template:" + template + " using clusterName:"
+ + clusterName + " and keys:" + Arrays.toString(keys));
+ }
+ return result;
+ }
+
+ /**
+ * Given a path, find the name of an instance at that path
+ * @param path
+ * @return a valid instance name, or null if none exists
+ */
+ public static String getInstanceNameFromPath(String path) {
+ // path structure
+ // /<cluster_name>/instances/<instance_name>/[currentStates/messages]
+ if (path.contains("/" + PropertyType.INSTANCES + "/")) {
+ String[] split = path.split("\\/");
+ if (split.length > 3) {
+ return split[3];
+ }
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/main/java/org/apache/helix/PropertyPathConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/PropertyPathConfig.java b/helix-core/src/main/java/org/apache/helix/PropertyPathConfig.java
deleted file mode 100644
index 97beb47..0000000
--- a/helix-core/src/main/java/org/apache/helix/PropertyPathConfig.java
+++ /dev/null
@@ -1,204 +0,0 @@
-package org.apache.helix;
-
-/*
- * 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 static org.apache.helix.PropertyType.CONFIGS;
-import static org.apache.helix.PropertyType.CURRENTSTATES;
-import static org.apache.helix.PropertyType.EXTERNALVIEW;
-import static org.apache.helix.PropertyType.HISTORY;
-import static org.apache.helix.PropertyType.IDEALSTATES;
-import static org.apache.helix.PropertyType.LIVEINSTANCES;
-import static org.apache.helix.PropertyType.MESSAGES;
-import static org.apache.helix.PropertyType.PAUSE;
-import static org.apache.helix.PropertyType.STATEMODELDEFS;
-import static org.apache.helix.PropertyType.STATUSUPDATES;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.helix.model.CurrentState;
-import org.apache.helix.model.ExternalView;
-import org.apache.helix.model.IdealState;
-import org.apache.helix.model.InstanceConfig;
-import org.apache.helix.model.LeaderHistory;
-import org.apache.helix.model.LiveInstance;
-import org.apache.helix.model.Message;
-import org.apache.helix.model.PauseSignal;
-import org.apache.helix.model.StateModelDefinition;
-import org.apache.helix.model.StatusUpdate;
-import org.apache.log4j.Logger;
-
-/**
- * Utility mapping properties to their Zookeeper locations
- */
-public class PropertyPathConfig {
- private static Logger logger = Logger.getLogger(PropertyPathConfig.class);
-
- static final Map<PropertyType, Map<Integer, String>> templateMap =
- new HashMap<PropertyType, Map<Integer, String>>();
- static final Map<PropertyType, Class<? extends HelixProperty>> typeToClassMapping =
- new HashMap<PropertyType, Class<? extends HelixProperty>>();
- static {
- typeToClassMapping.put(LIVEINSTANCES, LiveInstance.class);
- typeToClassMapping.put(IDEALSTATES, IdealState.class);
- typeToClassMapping.put(CONFIGS, InstanceConfig.class);
- typeToClassMapping.put(EXTERNALVIEW, ExternalView.class);
- typeToClassMapping.put(STATEMODELDEFS, StateModelDefinition.class);
- typeToClassMapping.put(MESSAGES, Message.class);
- typeToClassMapping.put(CURRENTSTATES, CurrentState.class);
- typeToClassMapping.put(STATUSUPDATES, StatusUpdate.class);
- typeToClassMapping.put(HISTORY, LeaderHistory.class);
- typeToClassMapping.put(PAUSE, PauseSignal.class);
-
- // @formatter:off
- addEntry(PropertyType.CONFIGS, 1, "/{clusterName}/CONFIGS");
- addEntry(PropertyType.CONFIGS, 2, "/{clusterName}/CONFIGS/{scope}");
- addEntry(PropertyType.CONFIGS, 3, "/{clusterName}/CONFIGS/{scope}/{scopeKey}");
- // addEntry(PropertyType.CONFIGS,2,"/{clusterName}/CONFIGS/{instanceName}");
- addEntry(PropertyType.LIVEINSTANCES, 1, "/{clusterName}/LIVEINSTANCES");
- addEntry(PropertyType.LIVEINSTANCES, 2, "/{clusterName}/LIVEINSTANCES/{instanceName}");
- addEntry(PropertyType.INSTANCES, 1, "/{clusterName}/INSTANCES");
- addEntry(PropertyType.INSTANCES, 2, "/{clusterName}/INSTANCES/{instanceName}");
- addEntry(PropertyType.IDEALSTATES, 1, "/{clusterName}/IDEALSTATES");
- addEntry(PropertyType.IDEALSTATES, 2, "/{clusterName}/IDEALSTATES/{resourceName}");
- addEntry(PropertyType.EXTERNALVIEW, 1, "/{clusterName}/EXTERNALVIEW");
- addEntry(PropertyType.EXTERNALVIEW, 2, "/{clusterName}/EXTERNALVIEW/{resourceName}");
- addEntry(PropertyType.STATEMODELDEFS, 1, "/{clusterName}/STATEMODELDEFS");
- addEntry(PropertyType.STATEMODELDEFS, 2, "/{clusterName}/STATEMODELDEFS/{stateModelName}");
- addEntry(PropertyType.CONTROLLER, 1, "/{clusterName}/CONTROLLER");
- addEntry(PropertyType.PROPERTYSTORE, 1, "/{clusterName}/PROPERTYSTORE");
-
- // INSTANCE
- addEntry(PropertyType.MESSAGES, 2, "/{clusterName}/INSTANCES/{instanceName}/MESSAGES");
- addEntry(PropertyType.MESSAGES, 3, "/{clusterName}/INSTANCES/{instanceName}/MESSAGES/{msgId}");
- addEntry(PropertyType.CURRENTSTATES, 2, "/{clusterName}/INSTANCES/{instanceName}/CURRENTSTATES");
- addEntry(PropertyType.CURRENTSTATES, 3,
- "/{clusterName}/INSTANCES/{instanceName}/CURRENTSTATES/{sessionId}");
- addEntry(PropertyType.CURRENTSTATES, 4,
- "/{clusterName}/INSTANCES/{instanceName}/CURRENTSTATES/{sessionId}/{resourceName}");
- addEntry(PropertyType.CURRENTSTATES, 5,
- "/{clusterName}/INSTANCES/{instanceName}/CURRENTSTATES/{sessionId}/{resourceName}/{bucketName}");
- addEntry(PropertyType.STATUSUPDATES, 2, "/{clusterName}/INSTANCES/{instanceName}/STATUSUPDATES");
- addEntry(PropertyType.STATUSUPDATES, 3,
- "/{clusterName}/INSTANCES/{instanceName}/STATUSUPDATES/{sessionId}");
- addEntry(PropertyType.STATUSUPDATES, 4,
- "/{clusterName}/INSTANCES/{instanceName}/STATUSUPDATES/{sessionId}/{subPath}");
- addEntry(PropertyType.STATUSUPDATES, 5,
- "/{clusterName}/INSTANCES/{instanceName}/STATUSUPDATES/{sessionId}/{subPath}/{recordName}");
- addEntry(PropertyType.ERRORS, 2, "/{clusterName}/INSTANCES/{instanceName}/ERRORS");
- addEntry(PropertyType.ERRORS, 3, "/{clusterName}/INSTANCES/{instanceName}/ERRORS/{sessionId}");
- addEntry(PropertyType.ERRORS, 4,
- "/{clusterName}/INSTANCES/{instanceName}/ERRORS/{sessionId}/{subPath}");
- addEntry(PropertyType.ERRORS, 5,
- "/{clusterName}/INSTANCES/{instanceName}/ERRORS/{sessionId}/{subPath}/{recordName}");
- addEntry(PropertyType.HEALTHREPORT, 2, "/{clusterName}/INSTANCES/{instanceName}/HEALTHREPORT");
- addEntry(PropertyType.HEALTHREPORT, 3,
- "/{clusterName}/INSTANCES/{instanceName}/HEALTHREPORT/{reportName}");
- // CONTROLLER
- addEntry(PropertyType.MESSAGES_CONTROLLER, 1, "/{clusterName}/CONTROLLER/MESSAGES");
- addEntry(PropertyType.MESSAGES_CONTROLLER, 2, "/{clusterName}/CONTROLLER/MESSAGES/{msgId}");
- addEntry(PropertyType.ERRORS_CONTROLLER, 1, "/{clusterName}/CONTROLLER/ERRORS");
- addEntry(PropertyType.ERRORS_CONTROLLER, 2, "/{clusterName}/CONTROLLER/ERRORS/{errorId}");
- addEntry(PropertyType.STATUSUPDATES_CONTROLLER, 1, "/{clusterName}/CONTROLLER/STATUSUPDATES");
- addEntry(PropertyType.STATUSUPDATES_CONTROLLER, 2,
- "/{clusterName}/CONTROLLER/STATUSUPDATES/{subPath}");
- addEntry(PropertyType.STATUSUPDATES_CONTROLLER, 3,
- "/{clusterName}/CONTROLLER/STATUSUPDATES/{subPath}/{recordName}");
- addEntry(PropertyType.LEADER, 1, "/{clusterName}/CONTROLLER/LEADER");
- addEntry(PropertyType.HISTORY, 1, "/{clusterName}/CONTROLLER/HISTORY");
- addEntry(PropertyType.PAUSE, 1, "/{clusterName}/CONTROLLER/PAUSE");
- // @formatter:on
-
- }
- static Pattern pattern = Pattern.compile("(\\{.+?\\})");
-
- private static void addEntry(PropertyType type, int numKeys, String template) {
- if (!templateMap.containsKey(type)) {
- templateMap.put(type, new HashMap<Integer, String>());
- }
- logger.trace("Adding template for type:" + type.getType() + " arguments:" + numKeys
- + " template:" + template);
- templateMap.get(type).put(numKeys, template);
- }
-
- /**
- * Get the Zookeeper path given the property type, cluster, and parameters
- * @param type
- * @param clusterName
- * @param keys
- * @return a valid path, or null if none exists
- */
- public static String getPath(PropertyType type, String clusterName, String... keys) {
- if (clusterName == null) {
- logger.warn("ClusterName can't be null for type:" + type);
- return null;
- }
- if (keys == null) {
- keys = new String[] {};
- }
- String template = null;
- if (templateMap.containsKey(type)) {
- // keys.length+1 since we add clusterName
- template = templateMap.get(type).get(keys.length + 1);
- }
-
- String result = null;
-
- if (template != null) {
- result = template;
- Matcher matcher = pattern.matcher(template);
- int count = 0;
- while (matcher.find()) {
- count = count + 1;
- String var = matcher.group();
- if (count == 1) {
- result = result.replace(var, clusterName);
- } else {
- result = result.replace(var, keys[count - 2]);
- }
- }
- }
- if (result == null || result.indexOf('{') > -1 || result.indexOf('}') > -1) {
- logger.warn("Unable to instantiate template:" + template + " using clusterName:"
- + clusterName + " and keys:" + Arrays.toString(keys));
- }
- return result;
- }
-
- /**
- * Given a path, find the name of an instance at that path
- * @param path
- * @return a valid instance name, or null if none exists
- */
- public static String getInstanceNameFromPath(String path) {
- // path structure
- // /<cluster_name>/instances/<instance_name>/[currentStates/messages]
- if (path.contains("/" + PropertyType.INSTANCES + "/")) {
- String[] split = path.split("\\/");
- if (split.length > 3) {
- return split[3];
- }
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java b/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
index fd59ecc..c3e8206 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
@@ -53,7 +53,7 @@ import org.apache.helix.MessageListener;
import org.apache.helix.NotificationContext;
import org.apache.helix.NotificationContext.Type;
import org.apache.helix.PropertyKey;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.ScopedConfigChangeListener;
import org.apache.helix.ZNRecord;
import org.apache.helix.model.CurrentState;
@@ -176,7 +176,7 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener
CurrentStateChangeListener currentStateChangeListener =
(CurrentStateChangeListener) _listener;
subscribeForChanges(changeContext, _path, true, true);
- String instanceName = PropertyPathConfig.getInstanceNameFromPath(_path);
+ String instanceName = PropertyPathBuilder.getInstanceNameFromPath(_path);
List<CurrentState> currentStates = _accessor.getChildValues(_propertyKey);
@@ -185,7 +185,7 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener
} else if (_changeType == MESSAGE) {
MessageListener messageListener = (MessageListener) _listener;
subscribeForChanges(changeContext, _path, true, false);
- String instanceName = PropertyPathConfig.getInstanceNameFromPath(_path);
+ String instanceName = PropertyPathBuilder.getInstanceNameFromPath(_path);
List<Message> messages = _accessor.getChildValues(_propertyKey);
messageListener.onMessage(instanceName, messages, changeContext);
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
index b58b344..2e2f3dd 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
@@ -48,7 +48,7 @@ import org.apache.helix.HelixException;
import org.apache.helix.InstanceType;
import org.apache.helix.PropertyKey;
import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.ZNRecord;
import org.apache.helix.controller.rebalancer.strategy.RebalanceStrategy;
@@ -100,7 +100,7 @@ public class ZKHelixAdmin implements HelixAdmin {
throw new HelixException("cluster " + clusterName + " is not setup yet");
}
String instanceConfigsPath =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString());
String nodeId = instanceConfig.getId();
String instanceConfigPath = instanceConfigsPath + "/" + nodeId;
@@ -120,7 +120,7 @@ public class ZKHelixAdmin implements HelixAdmin {
@Override
public void dropInstance(String clusterName, InstanceConfig instanceConfig) {
String instanceConfigsPath =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString());
String nodeId = instanceConfig.getId();
String instanceConfigPath = instanceConfigsPath + "/" + nodeId;
@@ -146,7 +146,7 @@ public class ZKHelixAdmin implements HelixAdmin {
@Override
public InstanceConfig getInstanceConfig(String clusterName, String instanceName) {
String instanceConfigPath =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString(), instanceName);
if (!_zkClient.exists(instanceConfigPath)) {
throw new HelixException("instance" + instanceName + " does not exist in cluster "
@@ -163,7 +163,7 @@ public class ZKHelixAdmin implements HelixAdmin {
@Override
public boolean setInstanceConfig(String clusterName, String instanceName,
InstanceConfig newInstanceConfig) {
- String instanceConfigPath = PropertyPathConfig
+ String instanceConfigPath = PropertyPathBuilder
.getPath(PropertyType.CONFIGS, clusterName, ConfigScopeProperty.PARTICIPANT.toString(),
instanceName);
if (!_zkClient.exists(instanceConfigPath)) {
@@ -190,7 +190,7 @@ public class ZKHelixAdmin implements HelixAdmin {
public void enableInstance(final String clusterName, final String instanceName,
final boolean enabled) {
String path =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString(), instanceName);
BaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_zkClient);
@@ -217,7 +217,7 @@ public class ZKHelixAdmin implements HelixAdmin {
@Override
public void enableResource(final String clusterName, final String resourceName,
final boolean enabled) {
- String path = PropertyPathConfig.getPath(PropertyType.IDEALSTATES, clusterName, resourceName);
+ String path = PropertyPathBuilder.getPath(PropertyType.IDEALSTATES, clusterName, resourceName);
BaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_zkClient);
if (!baseAccessor.exists(path, 0)) {
throw new HelixException("Cluster " + clusterName + ", resource: " + resourceName
@@ -241,7 +241,7 @@ public class ZKHelixAdmin implements HelixAdmin {
public void enablePartition(final boolean enabled, final String clusterName,
final String instanceName, final String resourceName, final List<String> partitionNames) {
String path =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString(), instanceName);
BaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_zkClient);
@@ -254,7 +254,7 @@ public class ZKHelixAdmin implements HelixAdmin {
// check resource exists
String idealStatePath =
- PropertyPathConfig.getPath(PropertyType.IDEALSTATES, clusterName, resourceName);
+ PropertyPathBuilder.getPath(PropertyType.IDEALSTATES, clusterName, resourceName);
ZNRecord idealStateRecord = null;
try {
@@ -552,20 +552,20 @@ public class ZKHelixAdmin implements HelixAdmin {
_zkClient.createPersistent(HelixUtil.getIdealStatePath(clusterName));
// CONFIGURATIONS
path =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.CLUSTER.toString(), clusterName);
_zkClient.createPersistent(path, true);
_zkClient.writeData(path, new ZNRecord(clusterName));
path =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString());
_zkClient.createPersistent(path);
path =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.RESOURCE.toString());
_zkClient.createPersistent(path);
// PROPERTY STORE
- path = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, clusterName);
+ path = PropertyPathBuilder.getPath(PropertyType.PROPERTYSTORE, clusterName);
_zkClient.createPersistent(path);
// LIVE INSTANCES
_zkClient.createPersistent(HelixUtil.getLiveInstancesPath(clusterName));
@@ -578,19 +578,19 @@ public class ZKHelixAdmin implements HelixAdmin {
// controller
_zkClient.createPersistent(HelixUtil.getControllerPath(clusterName));
- path = PropertyPathConfig.getPath(PropertyType.HISTORY, clusterName);
+ path = PropertyPathBuilder.getPath(PropertyType.HISTORY, clusterName);
final ZNRecord emptyHistory = new ZNRecord(PropertyType.HISTORY.toString());
final List<String> emptyList = new ArrayList<String>();
emptyHistory.setListField(clusterName, emptyList);
_zkClient.createPersistent(path, emptyHistory);
- path = PropertyPathConfig.getPath(PropertyType.MESSAGES_CONTROLLER, clusterName);
+ path = PropertyPathBuilder.getPath(PropertyType.MESSAGES_CONTROLLER, clusterName);
_zkClient.createPersistent(path);
- path = PropertyPathConfig.getPath(PropertyType.STATUSUPDATES_CONTROLLER, clusterName);
+ path = PropertyPathBuilder.getPath(PropertyType.STATUSUPDATES_CONTROLLER, clusterName);
_zkClient.createPersistent(path);
- path = PropertyPathConfig.getPath(PropertyType.ERRORS_CONTROLLER, clusterName);
+ path = PropertyPathBuilder.getPath(PropertyType.ERRORS_CONTROLLER, clusterName);
_zkClient.createPersistent(path);
}
@@ -643,7 +643,7 @@ public class ZKHelixAdmin implements HelixAdmin {
public void addResource(String clusterName, String resourceName, IdealState idealstate) {
String stateModelRef = idealstate.getStateModelDefRef();
String stateModelDefPath =
- PropertyPathConfig.getPath(PropertyType.STATEMODELDEFS, clusterName, stateModelRef);
+ PropertyPathBuilder.getPath(PropertyType.STATEMODELDEFS, clusterName, stateModelRef);
if (!_zkClient.exists(stateModelDefPath)) {
throw new HelixException("State model " + stateModelRef
+ " not found in the cluster STATEMODELDEFS path");
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
index 6f4a874..25eb653 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
@@ -53,7 +53,7 @@ import org.apache.helix.MessageListener;
import org.apache.helix.PreConnectCallback;
import org.apache.helix.PropertyKey;
import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.ScopedConfigChangeListener;
import org.apache.helix.ZNRecord;
@@ -661,7 +661,7 @@ public class ZKHelixManager implements HelixManager, IZkStateListener {
checkConnected();
if (_helixPropertyStore == null) {
- String path = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, _clusterName);
+ String path = PropertyPathBuilder.getPath(PropertyType.PROPERTYSTORE, _clusterName);
String fallbackPath = String.format("/%s/%s", _clusterName, "HELIX_PROPERTYSTORE");
_helixPropertyStore =
new AutoFallbackPropertyStore<ZNRecord>(new ZkBaseDataAccessor<ZNRecord>(_zkclient),
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java
index d243a50..2e19484 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java
@@ -26,7 +26,7 @@ import java.util.List;
import org.I0Itec.zkclient.DataUpdater;
import org.apache.helix.BaseDataAccessor;
import org.apache.helix.InstanceType;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.ZNRecord;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
@@ -46,24 +46,24 @@ public final class ZKUtil {
return false;
}
ArrayList<String> requiredPaths = new ArrayList<String>();
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.IDEALSTATES, clusterName));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.IDEALSTATES, clusterName));
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.CLUSTER.toString(), clusterName));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString()));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.RESOURCE.toString()));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, clusterName));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.LIVEINSTANCES, clusterName));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.INSTANCES, clusterName));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.CONTROLLER, clusterName));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.STATEMODELDEFS, clusterName));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.MESSAGES_CONTROLLER, clusterName));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.ERRORS_CONTROLLER, clusterName));
- requiredPaths.add(PropertyPathConfig
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.PROPERTYSTORE, clusterName));
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.LIVEINSTANCES, clusterName));
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.INSTANCES, clusterName));
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName));
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.CONTROLLER, clusterName));
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.STATEMODELDEFS, clusterName));
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.MESSAGES_CONTROLLER, clusterName));
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.ERRORS_CONTROLLER, clusterName));
+ requiredPaths.add(PropertyPathBuilder
.getPath(PropertyType.STATUSUPDATES_CONTROLLER, clusterName));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.HISTORY, clusterName));
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.HISTORY, clusterName));
boolean isValid = true;
BaseDataAccessor<Object> baseAccessor = new ZkBaseDataAccessor<Object>(zkClient);
@@ -83,15 +83,15 @@ public final class ZKUtil {
InstanceType type) {
if (type == InstanceType.PARTICIPANT || type == InstanceType.CONTROLLER_PARTICIPANT) {
ArrayList<String> requiredPaths = new ArrayList<String>();
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString(), instanceName));
- requiredPaths.add(PropertyPathConfig
+ requiredPaths.add(PropertyPathBuilder
.getPath(PropertyType.MESSAGES, clusterName, instanceName));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName,
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName,
instanceName));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.STATUSUPDATES, clusterName,
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.STATUSUPDATES, clusterName,
instanceName));
- requiredPaths.add(PropertyPathConfig.getPath(PropertyType.ERRORS, clusterName, instanceName));
+ requiredPaths.add(PropertyPathBuilder.getPath(PropertyType.ERRORS, clusterName, instanceName));
boolean isValid = true;
for (String path : requiredPaths) {
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/main/java/org/apache/helix/task/TaskDriver.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/task/TaskDriver.java b/helix-core/src/main/java/org/apache/helix/task/TaskDriver.java
index 1020cc3..96cbbb8 100644
--- a/helix-core/src/main/java/org/apache/helix/task/TaskDriver.java
+++ b/helix-core/src/main/java/org/apache/helix/task/TaskDriver.java
@@ -48,7 +48,7 @@ import org.apache.helix.HelixManager;
import org.apache.helix.HelixManagerFactory;
import org.apache.helix.InstanceType;
import org.apache.helix.PropertyKey;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.ZNRecord;
import org.apache.helix.manager.zk.ZKHelixAdmin;
@@ -118,7 +118,7 @@ public class TaskDriver {
public TaskDriver(ZkClient client, ZkBaseDataAccessor<ZNRecord> baseAccessor, String clusterName) {
this(new ZKHelixAdmin(client), new ZKHelixDataAccessor(clusterName, baseAccessor),
new ConfigAccessor(client), new ZkHelixPropertyStore<ZNRecord>(baseAccessor,
- PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, clusterName), null), clusterName);
+ PropertyPathBuilder.getPath(PropertyType.PROPERTYSTORE, clusterName), null), clusterName);
}
public TaskDriver(HelixAdmin admin, HelixDataAccessor accessor, ConfigAccessor cfgAccessor,
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java b/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
index a87740e..4d4aaf4 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
@@ -43,7 +43,7 @@ import org.apache.commons.cli.ParseException;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixDefinedState;
import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.ZNRecord;
import org.apache.helix.controller.pipeline.Stage;
@@ -579,7 +579,7 @@ public class ClusterStateVerifier {
ExtViewVeriferZkListener listener = new ExtViewVeriferZkListener(countDown, zkClient, verifier);
- String extViewPath = PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName);
+ String extViewPath = PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName);
zkClient.subscribeChildChanges(extViewPath, listener);
for (String child : zkClient.getChildren(extViewPath)) {
String childPath = extViewPath.equals("/") ? extViewPath + child : extViewPath + "/" + child;
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java b/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
index a4e0e08..6422875 100644
--- a/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
+++ b/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
@@ -22,7 +22,7 @@ package org.apache.helix.util;
import java.util.Map;
import java.util.TreeMap;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.log4j.Logger;
@@ -130,7 +130,7 @@ public final class HelixUtil {
}
public static String getControllerPropertyPath(String clusterName, PropertyType type) {
- return PropertyPathConfig.getPath(type, clusterName);
+ return PropertyPathBuilder.getPath(type, clusterName);
}
/**
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/Mocks.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/Mocks.java b/helix-core/src/test/java/org/apache/helix/Mocks.java
index 6a27402..0fb7d9e 100644
--- a/helix-core/src/test/java/org/apache/helix/Mocks.java
+++ b/helix-core/src/test/java/org/apache/helix/Mocks.java
@@ -517,7 +517,7 @@ public class Mocks {
@Override
public boolean removeProperty(PropertyKey key) {
- String path = key.getPath(); // PropertyPathConfig.getPath(type,
+ String path = key.getPath(); // PropertyPathBuilder.getPath(type,
// _clusterName, keys);
data.remove(path);
return true;
@@ -543,7 +543,7 @@ public class Mocks {
@Override
public <T extends HelixProperty> List<T> getChildValues(PropertyKey propertyKey) {
List<ZNRecord> childs = new ArrayList<ZNRecord>();
- String path = propertyKey.getPath(); // PropertyPathConfig.getPath(type,
+ String path = propertyKey.getPath(); // PropertyPathBuilder.getPath(type,
// _clusterName, keys);
for (String key : data.keySet()) {
if (key.startsWith(path)) {
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/TestPropertyPathBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/TestPropertyPathBuilder.java b/helix-core/src/test/java/org/apache/helix/TestPropertyPathBuilder.java
new file mode 100644
index 0000000..8794128
--- /dev/null
+++ b/helix-core/src/test/java/org/apache/helix/TestPropertyPathBuilder.java
@@ -0,0 +1,53 @@
+package org.apache.helix;
+
+/*
+ * 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.testng.AssertJUnit;
+import org.testng.annotations.Test;
+
+@Test
+public class TestPropertyPathBuilder {
+ @Test
+ public void testGetPath() {
+ String actual;
+ actual = PropertyPathBuilder.getPath(PropertyType.IDEALSTATES, "test_cluster");
+ AssertJUnit.assertEquals(actual, "/test_cluster/IDEALSTATES");
+ actual = PropertyPathBuilder.getPath(PropertyType.IDEALSTATES, "test_cluster", "resource");
+ AssertJUnit.assertEquals(actual, "/test_cluster/IDEALSTATES/resource");
+
+ actual = PropertyPathBuilder.getPath(PropertyType.INSTANCES, "test_cluster", "instanceName1");
+ AssertJUnit.assertEquals(actual, "/test_cluster/INSTANCES/instanceName1");
+
+ actual =
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, "test_cluster", "instanceName1");
+ AssertJUnit.assertEquals(actual, "/test_cluster/INSTANCES/instanceName1/CURRENTSTATES");
+ actual =
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, "test_cluster", "instanceName1",
+ "sessionId");
+ AssertJUnit.assertEquals(actual,
+ "/test_cluster/INSTANCES/instanceName1/CURRENTSTATES/sessionId");
+
+ actual = PropertyPathBuilder.getPath(PropertyType.CONTROLLER, "test_cluster");
+ AssertJUnit.assertEquals(actual, "/test_cluster/CONTROLLER");
+ actual = PropertyPathBuilder.getPath(PropertyType.MESSAGES_CONTROLLER, "test_cluster");
+ AssertJUnit.assertEquals(actual, "/test_cluster/CONTROLLER/MESSAGES");
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/TestPropertyPathConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/TestPropertyPathConfig.java b/helix-core/src/test/java/org/apache/helix/TestPropertyPathConfig.java
deleted file mode 100644
index c25bd32..0000000
--- a/helix-core/src/test/java/org/apache/helix/TestPropertyPathConfig.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.apache.helix;
-
-/*
- * 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.testng.AssertJUnit;
-import org.testng.annotations.Test;
-
-@Test
-public class TestPropertyPathConfig {
- @Test
- public void testGetPath() {
- String actual;
- actual = PropertyPathConfig.getPath(PropertyType.IDEALSTATES, "test_cluster");
- AssertJUnit.assertEquals(actual, "/test_cluster/IDEALSTATES");
- actual = PropertyPathConfig.getPath(PropertyType.IDEALSTATES, "test_cluster", "resource");
- AssertJUnit.assertEquals(actual, "/test_cluster/IDEALSTATES/resource");
-
- actual = PropertyPathConfig.getPath(PropertyType.INSTANCES, "test_cluster", "instanceName1");
- AssertJUnit.assertEquals(actual, "/test_cluster/INSTANCES/instanceName1");
-
- actual =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, "test_cluster", "instanceName1");
- AssertJUnit.assertEquals(actual, "/test_cluster/INSTANCES/instanceName1/CURRENTSTATES");
- actual =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, "test_cluster", "instanceName1",
- "sessionId");
- AssertJUnit.assertEquals(actual,
- "/test_cluster/INSTANCES/instanceName1/CURRENTSTATES/sessionId");
-
- actual = PropertyPathConfig.getPath(PropertyType.CONTROLLER, "test_cluster");
- AssertJUnit.assertEquals(actual, "/test_cluster/CONTROLLER");
- actual = PropertyPathConfig.getPath(PropertyType.MESSAGES_CONTROLLER, "test_cluster");
- AssertJUnit.assertEquals(actual, "/test_cluster/CONTROLLER/MESSAGES");
-
- }
-}
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/ZkUnitTestBase.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/ZkUnitTestBase.java b/helix-core/src/test/java/org/apache/helix/ZkUnitTestBase.java
index 83f3d30..2fd9796 100644
--- a/helix-core/src/test/java/org/apache/helix/ZkUnitTestBase.java
+++ b/helix-core/src/test/java/org/apache/helix/ZkUnitTestBase.java
@@ -152,7 +152,7 @@ public class ZkUnitTestBase {
boolean wantExists) {
// String instanceConfigsPath = HelixUtil.getConfigPath(clusterName);
String instanceConfigsPath =
- PropertyPathConfig.getPath(PropertyType.CONFIGS, clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CONFIGS, clusterName,
ConfigScopeProperty.PARTICIPANT.toString());
String instanceConfigPath = instanceConfigsPath + "/" + instance;
String instancePath = HelixUtil.getInstancePath(clusterName, instance);
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/integration/TestAddNodeAfterControllerStart.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestAddNodeAfterControllerStart.java b/helix-core/src/test/java/org/apache/helix/integration/TestAddNodeAfterControllerStart.java
index 79d8b89..3b69441 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestAddNodeAfterControllerStart.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestAddNodeAfterControllerStart.java
@@ -22,7 +22,7 @@ package org.apache.helix.integration;
import java.util.Date;
import java.util.List;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZkTestHelper;
@@ -66,7 +66,7 @@ public class TestAddNodeAfterControllerStart extends ZkIntegrationTestBase {
ZK_ADDR, clusterName));
Assert.assertTrue(result);
String msgPath =
- PropertyPathConfig.getPath(PropertyType.MESSAGES, clusterName, "localhost_12918");
+ PropertyPathBuilder.getPath(PropertyType.MESSAGES, clusterName, "localhost_12918");
result = checkHandlers(controller.getHandlers(), msgPath);
Assert.assertTrue(result);
@@ -79,7 +79,7 @@ public class TestAddNodeAfterControllerStart extends ZkIntegrationTestBase {
ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
ZK_ADDR, clusterName));
Assert.assertTrue(result);
- msgPath = PropertyPathConfig.getPath(PropertyType.MESSAGES, clusterName, "localhost_12922");
+ msgPath = PropertyPathBuilder.getPath(PropertyType.MESSAGES, clusterName, "localhost_12922");
result = checkHandlers(controller.getHandlers(), msgPath);
Assert.assertTrue(result);
@@ -140,7 +140,7 @@ public class TestAddNodeAfterControllerStart extends ZkIntegrationTestBase {
// check if controller_0 has message listener for localhost_12918
String msgPath =
- PropertyPathConfig.getPath(PropertyType.MESSAGES, clusterName, "localhost_12918");
+ PropertyPathBuilder.getPath(PropertyType.MESSAGES, clusterName, "localhost_12918");
int numberOfListeners = ZkTestHelper.numberOfListeners(ZK_ADDR, msgPath);
// System.out.println("numberOfListeners(" + msgPath + "): " + numberOfListeners);
Assert.assertEquals(numberOfListeners, 2); // 1 of participant, and 1 of controller
@@ -155,7 +155,7 @@ public class TestAddNodeAfterControllerStart extends ZkIntegrationTestBase {
ZK_ADDR, clusterName));
Assert.assertTrue(result);
// check if controller_0 has message listener for localhost_12919
- msgPath = PropertyPathConfig.getPath(PropertyType.MESSAGES, clusterName, "localhost_12919");
+ msgPath = PropertyPathBuilder.getPath(PropertyType.MESSAGES, clusterName, "localhost_12919");
numberOfListeners = ZkTestHelper.numberOfListeners(ZK_ADDR, msgPath);
// System.out.println("numberOfListeners(" + msgPath + "): " + numberOfListeners);
Assert.assertEquals(numberOfListeners, 2); // 1 of participant, and 1 of controller
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/integration/TestAutoIsWithEmptyMap.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestAutoIsWithEmptyMap.java b/helix-core/src/test/java/org/apache/helix/integration/TestAutoIsWithEmptyMap.java
index bc1c1b0..d316016 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestAutoIsWithEmptyMap.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestAutoIsWithEmptyMap.java
@@ -23,7 +23,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
@@ -54,7 +54,7 @@ public class TestAutoIsWithEmptyMap extends ZkIntegrationTestBase {
"LeaderStandby", false); // do not rebalance
// calculate and set custom ideal state
- String idealPath = PropertyPathConfig.getPath(PropertyType.IDEALSTATES, clusterName, "TestDB0");
+ String idealPath = PropertyPathBuilder.getPath(PropertyType.IDEALSTATES, clusterName, "TestDB0");
ZNRecord curIdealState = _gZkClient.readData(idealPath);
List<String> instanceNames = new ArrayList<String>(5);
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/integration/TestCarryOverBadCurState.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestCarryOverBadCurState.java b/helix-core/src/test/java/org/apache/helix/integration/TestCarryOverBadCurState.java
index 97b6ebb..c013122 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestCarryOverBadCurState.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestCarryOverBadCurState.java
@@ -21,7 +21,7 @@ package org.apache.helix.integration;
import java.util.Date;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
@@ -53,7 +53,7 @@ public class TestCarryOverBadCurState extends ZkIntegrationTestBase {
// add a bad current state
ZNRecord badCurState = new ZNRecord("TestDB0");
String path =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_12918",
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_12918",
"session_0", "TestDB0");
_gZkClient.createPersistent(path, true);
_gZkClient.writeData(path, badCurState);
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/integration/TestDriver.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestDriver.java b/helix-core/src/test/java/org/apache/helix/integration/TestDriver.java
index 82b181a..6520100 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestDriver.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestDriver.java
@@ -27,7 +27,7 @@ import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.helix.HelixManager;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.ZNRecord;
import org.apache.helix.integration.manager.ClusterControllerManager;
@@ -355,7 +355,7 @@ public class TestDriver {
nextIS = nextIdealState(initIS, destIS, step);
// testInfo._idealStateMap.put(dbName, nextIS);
String idealStatePath =
- PropertyPathConfig.getPath(PropertyType.IDEALSTATES, clusterName, TEST_DB_PREFIX + i);
+ PropertyPathBuilder.getPath(PropertyType.IDEALSTATES, clusterName, TEST_DB_PREFIX + i);
ZnodeOpArg arg = new ZnodeOpArg(idealStatePath, ZnodePropertyType.ZNODE, "+", nextIS);
TestCommand command = new TestCommand(CommandType.MODIFY, new TestTrigger(beginTime), arg);
commandList.add(command);
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/integration/TestEnableCompression.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestEnableCompression.java b/helix-core/src/test/java/org/apache/helix/integration/TestEnableCompression.java
index 643973a..c385c2f 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestEnableCompression.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestEnableCompression.java
@@ -6,10 +6,9 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
import org.I0Itec.zkclient.serialize.BytesPushThroughSerializer;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
import org.apache.helix.integration.manager.ClusterControllerManager;
import org.apache.helix.integration.manager.MockParticipantManager;
import org.apache.helix.manager.zk.ZkClient;
@@ -115,9 +114,9 @@ public class TestEnableCompression extends ZkIntegrationTestBase {
// ONLY IDEALSTATE and EXTERNAL VIEW must be compressed
Assert.assertEquals(compressedPaths.size(), 2);
String idealstatePath =
- PropertyPathConfig.getPath(PropertyType.IDEALSTATES, clusterName, resourceName);
+ PropertyPathBuilder.getPath(PropertyType.IDEALSTATES, clusterName, resourceName);
String externalViewPath =
- PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName, resourceName);
+ PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName, resourceName);
Assert.assertTrue(compressedPaths.contains(idealstatePath));
Assert.assertTrue(compressedPaths.contains(externalViewPath));
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/integration/TestMessageThrottle.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestMessageThrottle.java b/helix-core/src/test/java/org/apache/helix/integration/TestMessageThrottle.java
index fc6d6bc..1ebfcb6 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestMessageThrottle.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestMessageThrottle.java
@@ -25,7 +25,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.I0Itec.zkclient.IZkChildListener;
import org.apache.helix.HelixAdmin;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
@@ -85,7 +85,7 @@ public class TestMessageThrottle extends ZkIntegrationTestBase {
final AtomicBoolean success = new AtomicBoolean(true);
for (int i = 0; i < 5; i++) {
String instanceName = "localhost_" + (12918 + i);
- String msgPath = PropertyPathConfig.getPath(PropertyType.MESSAGES, clusterName, instanceName);
+ String msgPath = PropertyPathBuilder.getPath(PropertyType.MESSAGES, clusterName, instanceName);
_gZkClient.subscribeChildChanges(msgPath, new IZkChildListener() {
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/integration/TestNullReplica.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestNullReplica.java b/helix-core/src/test/java/org/apache/helix/integration/TestNullReplica.java
index 0f5cc72..e29945a 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestNullReplica.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestNullReplica.java
@@ -21,7 +21,7 @@ package org.apache.helix.integration;
import java.util.Date;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
@@ -56,7 +56,7 @@ public class TestNullReplica extends ZkIntegrationTestBase {
"MasterSlave", true); // do rebalance
// set replica in ideal state to null
String idealStatePath =
- PropertyPathConfig.getPath(PropertyType.IDEALSTATES, clusterName, "TestDB0");
+ PropertyPathBuilder.getPath(PropertyType.IDEALSTATES, clusterName, "TestDB0");
ZNRecord idealState = _gZkClient.readData(idealStatePath);
idealState.getSimpleFields().remove(IdealState.IdealStateProperty.REPLICAS.toString());
_gZkClient.writeData(idealStatePath, idealState);
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/integration/TestStartMultipleControllersWithSameName.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestStartMultipleControllersWithSameName.java b/helix-core/src/test/java/org/apache/helix/integration/TestStartMultipleControllersWithSameName.java
index d191c18..0e6b86c 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestStartMultipleControllersWithSameName.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestStartMultipleControllersWithSameName.java
@@ -21,7 +21,7 @@ package org.apache.helix.integration;
import java.util.Date;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZkTestHelper;
@@ -61,7 +61,7 @@ public class TestStartMultipleControllersWithSameName extends ZkIntegrationTestB
}
Thread.sleep(500); // wait leader election finishes
- String liPath = PropertyPathConfig.getPath(PropertyType.LIVEINSTANCES, clusterName);
+ String liPath = PropertyPathBuilder.getPath(PropertyType.LIVEINSTANCES, clusterName);
int listenerNb = ZkTestHelper.numberOfListeners(ZK_ADDR, liPath);
// System.out.println("listenerNb: " + listenerNb);
Assert.assertEquals(listenerNb, 1, "Only one controller should succeed in becoming leader");
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java b/helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java
index b35bd13..ab3054a 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java
@@ -28,7 +28,7 @@ import org.apache.helix.HelixManager;
import org.apache.helix.InstanceType;
import org.apache.helix.NotificationContext;
import org.apache.helix.PropertyKey;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
@@ -237,7 +237,7 @@ public class TestParticipantManager extends ZkIntegrationTestBase {
// assert interrupt exception error in old session
String errPath =
- PropertyPathConfig.getPath(PropertyType.ERRORS, clusterName, "localhost_12918",
+ PropertyPathBuilder.getPath(PropertyType.ERRORS, clusterName, "localhost_12918",
oldSessionId, "TestDB0", "TestDB0_0");
ZNRecord error = _gZkClient.readData(errPath);
Assert
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/integration/task/TestTaskRebalancerStopResume.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/task/TestTaskRebalancerStopResume.java b/helix-core/src/test/java/org/apache/helix/integration/task/TestTaskRebalancerStopResume.java
index 8e1f47d..22feda4 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/task/TestTaskRebalancerStopResume.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/task/TestTaskRebalancerStopResume.java
@@ -28,7 +28,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.PropertyKey;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.task.JobConfig;
@@ -459,7 +459,7 @@ public class TestTaskRebalancerStopResume extends TaskTestBase {
= Lists.newArrayList(keyBuilder.resourceConfigs().getPath(),
keyBuilder.idealStates().getPath(),
keyBuilder.externalViews().getPath(),
- PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, CLUSTER_NAME)
+ PropertyPathBuilder.getPath(PropertyType.PROPERTYSTORE, CLUSTER_NAME)
+ TaskConstants.REBALANCER_CONTEXT_ROOT);
for (String path : paths) {
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheAsyncOpMultiThread.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheAsyncOpMultiThread.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheAsyncOpMultiThread.java
index aa0bd2b..dde054c 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheAsyncOpMultiThread.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheAsyncOpMultiThread.java
@@ -27,14 +27,12 @@ import java.util.concurrent.Callable;
import org.I0Itec.zkclient.DataUpdater;
import org.apache.helix.AccessOption;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
import org.apache.helix.ZNRecordUpdater;
import org.apache.helix.ZkUnitTestBase;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.manager.zk.ZkCacheBaseDataAccessor;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -73,7 +71,7 @@ public class TestWtCacheAsyncOpMultiThread extends ZkUnitTestBase {
for (int i = 0; i < 5; i++) {
int k = j * 5 + i;
String path =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, _clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, _clusterName,
"localhost_8901", "session_0", "TestDB" + k);
ZNRecord record = new ZNRecord("TestDB" + k);
@@ -117,7 +115,7 @@ public class TestWtCacheAsyncOpMultiThread extends ZkUnitTestBase {
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, _clusterName,
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, _clusterName,
"localhost_8901", "session_0", "TestDB" + i);
ZNRecord newRecord = new ZNRecord("TestDB" + i);
@@ -173,7 +171,7 @@ public class TestWtCacheAsyncOpMultiThread extends ZkUnitTestBase {
for (int i = 0; i < 5; i++) {
int k = j * 5 + i;
String path =
- PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, _clusterName, "TestDB" + k);
+ PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, _clusterName, "TestDB" + k);
ZNRecord record = new ZNRecord("TestDB" + k);
paths.add(path);
@@ -200,8 +198,8 @@ public class TestWtCacheAsyncOpMultiThread extends ZkUnitTestBase {
// init zkCacheDataAccessor
String curStatePath =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
- String extViewPath = PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName);
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
+ String extViewPath = PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName);
ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheAsyncOpSingleThread.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheAsyncOpSingleThread.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheAsyncOpSingleThread.java
index 4d684d3..7f0c256 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheAsyncOpSingleThread.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheAsyncOpSingleThread.java
@@ -26,14 +26,12 @@ import java.util.List;
import org.I0Itec.zkclient.DataUpdater;
import org.apache.helix.AccessOption;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
import org.apache.helix.ZNRecordUpdater;
import org.apache.helix.ZkUnitTestBase;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.manager.zk.ZkCacheBaseDataAccessor;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -47,8 +45,8 @@ public class TestWtCacheAsyncOpSingleThread extends ZkUnitTestBase {
// init zkCacheDataAccessor
String curStatePath =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
- String extViewPath = PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName);
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
+ String extViewPath = PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName);
ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
@@ -66,7 +64,7 @@ public class TestWtCacheAsyncOpSingleThread extends ZkUnitTestBase {
List<ZNRecord> records = new ArrayList<ZNRecord>();
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
"session_0", "TestDB" + i);
ZNRecord record = new ZNRecord("TestDB" + i);
@@ -114,7 +112,7 @@ public class TestWtCacheAsyncOpSingleThread extends ZkUnitTestBase {
records.clear();
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName, "TestDB" + i);
+ PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName, "TestDB" + i);
ZNRecord record = new ZNRecord("TestDB" + i);
paths.add(path);
@@ -135,7 +133,7 @@ public class TestWtCacheAsyncOpSingleThread extends ZkUnitTestBase {
records.clear();
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName, "TestDB" + i);
+ PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName, "TestDB" + i);
paths.add(path);
}
@@ -155,7 +153,7 @@ public class TestWtCacheAsyncOpSingleThread extends ZkUnitTestBase {
paths.clear();
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
"session_0", "TestDB" + i);
paths.add(path);
}
@@ -176,8 +174,8 @@ public class TestWtCacheAsyncOpSingleThread extends ZkUnitTestBase {
// init zkCacheDataAccessor
String curStatePath =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
- String extViewPath = PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName);
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
+ String extViewPath = PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName);
ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
@@ -196,7 +194,7 @@ public class TestWtCacheAsyncOpSingleThread extends ZkUnitTestBase {
List<ZNRecord> records = new ArrayList<ZNRecord>();
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
"session_1", "TestDB" + i);
ZNRecord record = new ZNRecord("TestDB" + i);
http://git-wip-us.apache.org/repos/asf/helix/blob/0b7a1a0f/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheSyncOpSingleThread.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheSyncOpSingleThread.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheSyncOpSingleThread.java
index edbcedc..8e83713 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheSyncOpSingleThread.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestWtCacheSyncOpSingleThread.java
@@ -24,14 +24,12 @@ import java.util.Date;
import java.util.List;
import org.apache.helix.AccessOption;
-import org.apache.helix.PropertyPathConfig;
+import org.apache.helix.PropertyPathBuilder;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
import org.apache.helix.ZNRecord;
import org.apache.helix.ZNRecordUpdater;
import org.apache.helix.ZkUnitTestBase;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.manager.zk.ZkCacheBaseDataAccessor;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -47,8 +45,8 @@ public class TestWtCacheSyncOpSingleThread extends ZkUnitTestBase {
// init zkCacheDataAccessor
String curStatePath =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
- String extViewPath = PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName);
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
+ String extViewPath = PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName);
ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
@@ -94,7 +92,7 @@ public class TestWtCacheSyncOpSingleThread extends ZkUnitTestBase {
// set 10 external views
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName, "TestDB" + i);
+ PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName, "TestDB" + i);
boolean success = accessor.set(path, new ZNRecord("TestDB" + i), AccessOption.PERSISTENT);
Assert.assertTrue(success, "Should succeed in set: " + path);
}
@@ -107,7 +105,7 @@ public class TestWtCacheSyncOpSingleThread extends ZkUnitTestBase {
// get 10 external views
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName, "TestDB" + i);
+ PropertyPathBuilder.getPath(PropertyType.EXTERNALVIEW, clusterName, "TestDB" + i);
ZNRecord record = accessor.get(path, null, 0);
Assert.assertEquals(record.getId(), "TestDB" + i);
}
@@ -123,7 +121,7 @@ public class TestWtCacheSyncOpSingleThread extends ZkUnitTestBase {
// exists
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
"session_0", "TestDB" + i);
Assert.assertTrue(accessor.exists(path, 0));
@@ -141,7 +139,7 @@ public class TestWtCacheSyncOpSingleThread extends ZkUnitTestBase {
// init zkCacheDataAccessor
String curStatePath =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901");
ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
@@ -151,7 +149,7 @@ public class TestWtCacheSyncOpSingleThread extends ZkUnitTestBase {
// create 10 current states
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
"session_1", "TestDB" + i);
boolean success = accessor.create(path, new ZNRecord("TestDB" + i), AccessOption.PERSISTENT);
Assert.assertTrue(success, "Should succeed in create: " + path);
@@ -160,7 +158,7 @@ public class TestWtCacheSyncOpSingleThread extends ZkUnitTestBase {
// create same 10 current states again, should fail
for (int i = 0; i < 10; i++) {
String path =
- PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
+ PropertyPathBuilder.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_8901",
"session_1", "TestDB" + i);
boolean success = accessor.create(path, new ZNRecord("TestDB" + i), AccessOption.PERSISTENT);
Assert.assertFalse(success, "Should fail in create due to NodeExists: " + path);