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 <j...@linkedin.com> Authored: Sat Jan 28 16:55:24 2017 -0800 Committer: Junkai Xue <j...@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);