helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject [4/9] helix git commit: Move HelixUtil.get*Path to PropertyPathBuilder
Date Thu, 02 Feb 2017 17:53:24 GMT
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 <jxue@linkedin.com>
Authored: Sat Jan 28 17:06:46 2017 -0800
Committer: Junkai Xue <jxue@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();


Mime
View raw message