You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ka...@apache.org on 2013/11/07 02:19:16 UTC

[08/53] [abbrv] [HELIX-98] clean up setting constraint api, [HELIX-246] Refactor scheduler task config to comply with new rebalancer config and fix related scheduler task tests

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/main/java/org/apache/helix/model/IdealState.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/IdealState.java b/helix-core/src/main/java/org/apache/helix/model/IdealState.java
index a0400f2..88992c1 100644
--- a/helix-core/src/main/java/org/apache/helix/model/IdealState.java
+++ b/helix-core/src/main/java/org/apache/helix/model/IdealState.java
@@ -128,6 +128,7 @@ public class IdealState extends HelixProperty {
    * Get the associated resource
    * @return the name of the resource
    */
+  @Deprecated
   public String getResourceName() {
     return _record.getId();
   }
@@ -174,6 +175,7 @@ public class IdealState extends HelixProperty {
    * Define a custom rebalancer that implements {@link Rebalancer}
    * @param rebalancerClassName the name of the custom rebalancing class
    */
+  @Deprecated
   public void setRebalancerClassName(String rebalancerClassName) {
     _record
         .setSimpleField(IdealStateProperty.REBALANCER_CLASS_NAME.toString(), rebalancerClassName);
@@ -183,6 +185,7 @@ public class IdealState extends HelixProperty {
    * Get the name of the user-defined rebalancer associated with this resource
    * @return the rebalancer class name, or null if none is being used
    */
+  @Deprecated
   public String getRebalancerClassName() {
     return _record.getSimpleField(IdealStateProperty.REBALANCER_CLASS_NAME.toString());
   }
@@ -276,6 +279,7 @@ public class IdealState extends HelixProperty {
    * Get all of the partitions
    * @return a set of partition names
    */
+  @Deprecated
   public Set<String> getPartitionStringSet() {
     if (getRebalanceMode() == RebalanceMode.SEMI_AUTO
         || getRebalanceMode() == RebalanceMode.FULL_AUTO) {
@@ -302,19 +306,11 @@ public class IdealState extends HelixProperty {
   }
 
   /**
-   * Set the current mapping of a partition
-   * @param partition the partition to set
-   * @param instanceStateMap (instance name, state) pairs
-   */
-  public void setInstanceStateMap(String partition, Map<String, String> instanceStateMap) {
-    _record.setMapField(partition, instanceStateMap);
-  }
-
-  /**
    * Get the current mapping of a partition
    * @param partitionName the name of the partition
    * @return the instances where the replicas live and the state of each
    */
+  @Deprecated
   public Map<String, String> getInstanceStateMap(String partitionName) {
     return _record.getMapField(partitionName);
   }
@@ -357,6 +353,7 @@ public class IdealState extends HelixProperty {
    * @param partitionName the partition to look up
    * @return set of instance names
    */
+  @Deprecated
   public Set<String> getInstanceSet(String partitionName) {
     if (getRebalanceMode() == RebalanceMode.SEMI_AUTO
         || getRebalanceMode() == RebalanceMode.FULL_AUTO) {
@@ -397,15 +394,6 @@ public class IdealState extends HelixProperty {
 
   /**
    * Set the preference list of a partition
-   * @param partitionName the name of the partition to set
-   * @param preferenceList a list of instances that can serve replicas of the partition
-   */
-  public void setPreferenceList(String partitionName, List<String> preferenceList) {
-    _record.setListField(partitionName, preferenceList);
-  }
-
-  /**
-   * Set the preference list of a partition
    * @param partitionId the id of the partition to set
    * @param preferenceList a list of participants that can serve replicas of the partition
    */
@@ -422,6 +410,7 @@ public class IdealState extends HelixProperty {
    * @param partitionName the name of the partition
    * @return a list of instances that can serve replicas of the partition
    */
+  @Deprecated
   public List<String> getPreferenceList(String partitionName) {
     List<String> instanceStateList = _record.getListField(partitionName);
 
@@ -453,6 +442,7 @@ public class IdealState extends HelixProperty {
    * Get the state model associated with this resource
    * @return an identifier of the state model
    */
+  @Deprecated
   public String getStateModelDefRef() {
     return _record.getSimpleField(IdealStateProperty.STATE_MODEL_DEF_REF.toString());
   }
@@ -469,6 +459,7 @@ public class IdealState extends HelixProperty {
    * Set the state model associated with this resource
    * @param stateModel state model identifier
    */
+  @Deprecated
   public void setStateModelDefRef(String stateModel) {
     _record.setSimpleField(IdealStateProperty.STATE_MODEL_DEF_REF.toString(), stateModel);
   }
@@ -558,6 +549,7 @@ public class IdealState extends HelixProperty {
    * Set the state model factory associated with this resource
    * @param name state model factory name
    */
+  @Deprecated
   public void setStateModelFactoryName(String name) {
     _record.setSimpleField(IdealStateProperty.STATE_MODEL_FACTORY_NAME.toString(), name);
   }
@@ -574,6 +566,7 @@ public class IdealState extends HelixProperty {
    * Get the state model factory associated with this resource
    * @return state model factory name
    */
+  @Deprecated
   public String getStateModelFactoryName() {
     return _record.getStringField(IdealStateProperty.STATE_MODEL_FACTORY_NAME.toString(),
         HelixConstants.DEFAULT_STATE_MODEL_FACTORY);

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/main/java/org/apache/helix/model/builder/ClusterConstraintsBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/builder/ClusterConstraintsBuilder.java b/helix-core/src/main/java/org/apache/helix/model/builder/ClusterConstraintsBuilder.java
index 59cd825..7a0e7a0 100644
--- a/helix-core/src/main/java/org/apache/helix/model/builder/ClusterConstraintsBuilder.java
+++ b/helix-core/src/main/java/org/apache/helix/model/builder/ClusterConstraintsBuilder.java
@@ -22,6 +22,7 @@ package org.apache.helix.model.builder;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.helix.api.ConstraintId;
 import org.apache.helix.model.ClusterConstraints;
 import org.apache.helix.model.ClusterConstraints.ConstraintType;
 import org.apache.log4j.Logger;
@@ -40,8 +41,8 @@ public class ClusterConstraintsBuilder {
    * TRANSITION : OFFLINE->SLAVE
    * CONSTRAINT_VALUE : 1
    */
-  private final Map<String, ConstraintItemBuilder> _constraintBuilderMap =
-      new HashMap<String, ConstraintItemBuilder>();
+  private final Map<ConstraintId, ConstraintItemBuilder> _constraintBuilderMap =
+      new HashMap<ConstraintId, ConstraintItemBuilder>();
 
   public ClusterConstraintsBuilder(ConstraintType type) {
     if (type == null) {
@@ -50,8 +51,8 @@ public class ClusterConstraintsBuilder {
     _constraintType = type;
   }
 
-  public ClusterConstraintsBuilder addConstraintAttribute(String constraintId, String attribute,
-      String value) {
+  public ClusterConstraintsBuilder addConstraintAttribute(ConstraintId constraintId,
+      String attribute, String value) {
     if (!_constraintBuilderMap.containsKey(constraintId)) {
       _constraintBuilderMap.put(constraintId, new ConstraintItemBuilder());
     }
@@ -63,7 +64,7 @@ public class ClusterConstraintsBuilder {
   public ClusterConstraints build() {
     ClusterConstraints constraints = new ClusterConstraints(_constraintType);
 
-    for (String constraintId : _constraintBuilderMap.keySet()) {
+    for (ConstraintId constraintId : _constraintBuilderMap.keySet()) {
       ConstraintItemBuilder builder = _constraintBuilderMap.get(constraintId);
       constraints.addConstraintItem(constraintId, builder.build());
     }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/main/java/org/apache/helix/model/builder/IdealStateBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/builder/IdealStateBuilder.java b/helix-core/src/main/java/org/apache/helix/model/builder/IdealStateBuilder.java
index 7ae9dfe..3eb1afb 100644
--- a/helix-core/src/main/java/org/apache/helix/model/builder/IdealStateBuilder.java
+++ b/helix-core/src/main/java/org/apache/helix/model/builder/IdealStateBuilder.java
@@ -24,6 +24,7 @@ import org.apache.helix.HelixException;
 import org.apache.helix.ZNRecord;
 import org.apache.helix.api.ResourceId;
 import org.apache.helix.api.StateModelDefId;
+import org.apache.helix.api.StateModelFactoryId;
 import org.apache.helix.model.IdealState;
 
 public abstract class IdealStateBuilder {
@@ -156,8 +157,8 @@ public abstract class IdealStateBuilder {
     IdealState idealstate = new IdealState(_record);
     idealstate.setNumPartitions(numPartitions);
     idealstate.setMaxPartitionsPerInstance(maxPartitionsPerNode);
-    idealstate.setStateModelDefRef(stateModel);
-    idealstate.setStateModelFactoryName(stateModelFactoryName);
+    idealstate.setStateModelDefId(StateModelDefId.from(stateModel));
+    idealstate.setStateModelFactoryId(StateModelFactoryId.from(stateModelFactoryName));
     idealstate.setRebalanceMode(rebalancerMode);
     idealstate.setReplicas("" + numReplica);
 
@@ -166,5 +167,4 @@ public abstract class IdealStateBuilder {
     }
     return idealstate;
   }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/main/java/org/apache/helix/model/builder/MessageConstraintItemBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/builder/MessageConstraintItemBuilder.java b/helix-core/src/main/java/org/apache/helix/model/builder/MessageConstraintItemBuilder.java
new file mode 100644
index 0000000..a44315b
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/model/builder/MessageConstraintItemBuilder.java
@@ -0,0 +1,107 @@
+package org.apache.helix.model.builder;
+
+import org.apache.helix.api.ParticipantId;
+import org.apache.helix.api.ResourceId;
+import org.apache.helix.model.ClusterConstraints.ConstraintAttribute;
+import org.apache.helix.model.ConstraintItem;
+import org.apache.helix.model.Message;
+import org.apache.helix.model.Message.MessageType;
+import org.apache.helix.model.Transition;
+
+/*
+ * 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.
+ */
+
+/**
+ * Specify a ConstraintItem based on a message (commonly used for transition constraints)
+ */
+public class MessageConstraintItemBuilder {
+  private ConstraintItemBuilder _builder;
+
+  /**
+   * Instantiate the builder
+   */
+  public MessageConstraintItemBuilder() {
+    _builder = new ConstraintItemBuilder();
+  }
+
+  /**
+   * Set the message type of the constraint
+   * @param messageType message type
+   * @return MessageConstraintItemBuilder
+   */
+  public MessageConstraintItemBuilder messageType(MessageType messageType) {
+    _builder.addConstraintAttribute(ConstraintAttribute.MESSAGE_TYPE.toString(),
+        messageType.toString());
+    return this;
+  }
+
+  /**
+   * Set a participant as part of the constraint scope
+   * @param participantId the participant to constrain
+   * @return MessageConstraintItemBuilder
+   */
+  public MessageConstraintItemBuilder participant(ParticipantId participantId) {
+    _builder.addConstraintAttribute(ConstraintAttribute.INSTANCE.toString(),
+        participantId.stringify());
+    return this;
+  }
+
+  /**
+   * Set a resource as part of the constraint scope
+   * @param resourceId the resource to constrain
+   * @return MessageConstraintItemBuilder
+   */
+  public MessageConstraintItemBuilder resource(ResourceId resourceId) {
+    _builder
+        .addConstraintAttribute(ConstraintAttribute.RESOURCE.toString(), resourceId.stringify());
+    return this;
+  }
+
+  /**
+   * Set the transition to constrain for transition message types
+   * @param transition the transition to constrain
+   * @return MessageConstraintItemBuilder
+   */
+  public MessageConstraintItemBuilder transition(Transition transition) {
+    // if this is a transition constraint, the message type must be STATE_TRANSITION
+    _builder.addConstraintAttribute(ConstraintAttribute.MESSAGE_TYPE.toString(),
+        Message.MessageType.STATE_TRANSITION.toString());
+    _builder.addConstraintAttribute(ConstraintAttribute.TRANSITION.toString(),
+        transition.toString());
+    return this;
+  }
+
+  /**
+   * Set the value of the constraint
+   * @param value constraint value
+   * @return MessageConstraintItemBuilder
+   */
+  public MessageConstraintItemBuilder constraintValue(String value) {
+    _builder.addConstraintAttribute(ConstraintAttribute.CONSTRAINT_VALUE.toString(), value);
+    return this;
+  }
+
+  /**
+   * Get the ConstraintItem instance that is built
+   * @return ConstraintItem
+   */
+  public ConstraintItem build() {
+    return _builder.build();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/main/java/org/apache/helix/model/builder/StateConstraintItemBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/builder/StateConstraintItemBuilder.java b/helix-core/src/main/java/org/apache/helix/model/builder/StateConstraintItemBuilder.java
new file mode 100644
index 0000000..d9af9f5
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/model/builder/StateConstraintItemBuilder.java
@@ -0,0 +1,92 @@
+package org.apache.helix.model.builder;
+
+import org.apache.helix.api.State;
+import org.apache.helix.api.StateModelDefId;
+import org.apache.helix.model.ClusterConstraints.ConstraintAttribute;
+import org.apache.helix.model.ConstraintItem;
+
+/*
+ * 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.
+ */
+
+/**
+ * Build a ConstraintItem corresponding to a state bound
+ */
+public class StateConstraintItemBuilder {
+  private ConstraintItemBuilder _builder;
+
+  /**
+   * Instantiate the builder
+   */
+  public StateConstraintItemBuilder() {
+    _builder = new ConstraintItemBuilder();
+  }
+
+  /**
+   * Get the state model definition to constrain
+   * @param stateModelDefId state model definition identifier
+   * @return StateConstraintItemBuilder
+   */
+  public StateConstraintItemBuilder stateModel(StateModelDefId stateModelDefId) {
+    _builder.addConstraintAttribute(ConstraintAttribute.STATE_MODEL.toString(),
+        stateModelDefId.stringify());
+    return this;
+  }
+
+  /**
+   * Get the state to constrain
+   * @param state state object
+   * @return StateConstraintItemBuilder
+   */
+  public StateConstraintItemBuilder state(State state) {
+    _builder.addConstraintAttribute(ConstraintAttribute.STATE.toString(), state.toString());
+    return this;
+  }
+
+  /**
+   * Set a numerical upper bound for the replicas that can be in a state
+   * @param upperBound maximum replica count for a state, per partition
+   * @return StateConstraintItemBuilder
+   */
+  public StateConstraintItemBuilder upperBound(int upperBound) {
+    _builder.addConstraintAttribute(ConstraintAttribute.CONSTRAINT_VALUE.toString(),
+        Integer.toString(upperBound));
+    return this;
+  }
+
+  /**
+   * Set an upper bound for the replicas that can be in a state. This can be numerical, or "N" for
+   * number of nodes, or "R" for total number of replicas per partition
+   * @param dynamicUpperBound maximum replica count for a state, per partition, can also be "N" or
+   *          "R"
+   * @return StateConstraintItemBuilder
+   */
+  public StateConstraintItemBuilder dynamicUpperBound(String dynamicUpperBound) {
+    _builder.addConstraintAttribute(ConstraintAttribute.CONSTRAINT_VALUE.toString(),
+        dynamicUpperBound);
+    return this;
+  }
+
+  /**
+   * Get the ConstraintItem instance that is built
+   * @return ConstraintItem
+   */
+  public ConstraintItem build() {
+    return _builder.build();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ResourceMonitor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ResourceMonitor.java b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ResourceMonitor.java
index 2041999..7dcbfda 100644
--- a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ResourceMonitor.java
+++ b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ResourceMonitor.java
@@ -22,6 +22,9 @@ package org.apache.helix.monitoring.mbeans;
 import java.util.Map;
 
 import org.apache.helix.HelixDefinedState;
+import org.apache.helix.api.ParticipantId;
+import org.apache.helix.api.PartitionId;
+import org.apache.helix.api.State;
 import org.apache.helix.model.ExternalView;
 import org.apache.helix.model.IdealState;
 import org.apache.log4j.Logger;
@@ -86,30 +89,31 @@ public class ResourceMonitor implements ResourceMonitorMBean {
 
     // TODO fix this; IdealState shall have either map fields (CUSTOM mode)
     // or list fields (AUDO mode)
-    for (String partitionName : idealState.getRecord().getMapFields().keySet()) {
-      Map<String, String> idealRecord = idealState.getInstanceStateMap(partitionName);
-      Map<String, String> externalViewRecord = externalView.getStateMap(partitionName);
+    for (PartitionId partitionId : idealState.getPartitionSet()) {
+      Map<ParticipantId, State> idealRecord = idealState.getParticipantStateMap(partitionId);
+      Map<ParticipantId, State> externalViewRecord = externalView.getStateMap(partitionId);
 
       if (externalViewRecord == null) {
         numOfDiff += idealRecord.size();
         continue;
       }
-      for (String host : idealRecord.keySet()) {
+      for (ParticipantId host : idealRecord.keySet()) {
         if (!externalViewRecord.containsKey(host)
             || !externalViewRecord.get(host).equals(idealRecord.get(host))) {
           numOfDiff++;
         }
       }
 
-      for (String host : externalViewRecord.keySet()) {
-        if (externalViewRecord.get(host).equalsIgnoreCase(HelixDefinedState.ERROR.toString())) {
+      for (ParticipantId host : externalViewRecord.keySet()) {
+        if (externalViewRecord.get(host).toString()
+            .equalsIgnoreCase(HelixDefinedState.ERROR.toString())) {
           numOfErrorPartitions++;
         }
       }
     }
     _numOfErrorPartitions = numOfErrorPartitions;
     _externalViewIdealStateDiff = numOfDiff;
-    _numOfPartitionsInExternalView = externalView.getPartitionStringSet().size();
+    _numOfPartitionsInExternalView = externalView.getPartitionSet().size();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/main/java/org/apache/helix/participant/HelixCustomCodeRunner.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/participant/HelixCustomCodeRunner.java b/helix-core/src/main/java/org/apache/helix/participant/HelixCustomCodeRunner.java
index 4aa8e6e..cd238e1 100644
--- a/helix-core/src/main/java/org/apache/helix/participant/HelixCustomCodeRunner.java
+++ b/helix-core/src/main/java/org/apache/helix/participant/HelixCustomCodeRunner.java
@@ -28,6 +28,9 @@ import org.apache.helix.HelixConstants.StateModelToken;
 import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.HelixManager;
 import org.apache.helix.PropertyKey.Builder;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.api.StateModelDefId;
+import org.apache.helix.api.StateModelFactoryId;
 import org.apache.helix.manager.zk.ZKHelixDataAccessor;
 import org.apache.helix.manager.zk.ZNRecordSerializer;
 import org.apache.helix.manager.zk.ZkBaseDataAccessor;
@@ -127,15 +130,16 @@ public class HelixCustomCodeRunner {
       zkClient = new ZkClient(_zkAddr, ZkClient.DEFAULT_CONNECTION_TIMEOUT);
       zkClient.setZkSerializer(new ZNRecordSerializer());
       HelixDataAccessor accessor =
-          new ZKHelixDataAccessor(_manager.getClusterName(), new ZkBaseDataAccessor(zkClient));
+          new ZKHelixDataAccessor(_manager.getClusterName(), new ZkBaseDataAccessor<ZNRecord>(
+              zkClient));
       Builder keyBuilder = accessor.keyBuilder();
 
       IdealState idealState = new IdealState(_resourceName);
       idealState.setRebalanceMode(RebalanceMode.SEMI_AUTO);
       idealState.setReplicas(StateModelToken.ANY_LIVEINSTANCE.toString());
       idealState.setNumPartitions(1);
-      idealState.setStateModelDefRef(LEADER_STANDBY);
-      idealState.setStateModelFactoryName(_resourceName);
+      idealState.setStateModelDefId(StateModelDefId.from(LEADER_STANDBY));
+      idealState.setStateModelFactoryId(StateModelFactoryId.from(_resourceName));
       List<String> prefList =
           new ArrayList<String>(Arrays.asList(StateModelToken.ANY_LIVEINSTANCE.toString()));
       idealState.getRecord().setListField(_resourceName + "_0", prefList);

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/main/java/org/apache/helix/tools/ClusterSetup.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/tools/ClusterSetup.java b/helix-core/src/main/java/org/apache/helix/tools/ClusterSetup.java
index ba417be..fa60c34 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/ClusterSetup.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/ClusterSetup.java
@@ -310,8 +310,8 @@ public class ClusterSetup {
         accessor.getChildValues(accessor.keyBuilder().idealStates());
     for (IdealState idealState : existingIdealStates) {
       swapInstanceInIdealState(idealState, oldInstanceName, newInstanceName);
-      accessor.setProperty(accessor.keyBuilder().idealState(idealState.getResourceName()),
-          idealState);
+      accessor.setProperty(
+          accessor.keyBuilder().idealState(idealState.getResourceId().stringify()), idealState);
     }
   }
 
@@ -383,15 +383,15 @@ public class ClusterSetup {
     IdealState idealState = _admin.getResourceIdealState(clusterName, resourceName);
     if (idealState.getRebalanceMode() == RebalanceMode.FULL_AUTO
         || idealState.getRebalanceMode() == RebalanceMode.CUSTOMIZED) {
-      _logger.info("Skipping idealState " + idealState.getResourceName() + " "
+      _logger.info("Skipping idealState " + idealState.getResourceId() + " "
           + idealState.getRebalanceMode());
       return;
     }
     boolean anyLiveInstance = false;
     for (List<String> list : idealState.getRecord().getListFields().values()) {
       if (list.contains(StateModelToken.ANY_LIVEINSTANCE.toString())) {
-        _logger.info("Skipping idealState " + idealState.getResourceName()
-            + " with ANY_LIVEINSTANCE");
+        _logger
+            .info("Skipping idealState " + idealState.getResourceId() + " with ANY_LIVEINSTANCE");
         anyLiveInstance = true;
         continue;
       }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/main/java/org/apache/helix/util/RebalanceUtil.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/util/RebalanceUtil.java b/helix-core/src/main/java/org/apache/helix/util/RebalanceUtil.java
index 0911cc4..4b014de 100644
--- a/helix-core/src/main/java/org/apache/helix/util/RebalanceUtil.java
+++ b/helix-core/src/main/java/org/apache/helix/util/RebalanceUtil.java
@@ -27,9 +27,13 @@ import java.util.Map;
 import java.util.TreeMap;
 
 import org.apache.helix.HelixException;
+import org.apache.helix.api.PartitionId;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.model.StateModelDefinition;
 
+import com.google.common.base.Functions;
+import com.google.common.collect.Lists;
+
 public class RebalanceUtil {
   public static Map<String, Object> buildInternalIdealState(IdealState state) {
     // Try parse the partition number from name DB_n. If not, sort the partitions and
@@ -37,17 +41,19 @@ public class RebalanceUtil {
     Map<String, Integer> partitionIndex = new HashMap<String, Integer>();
     Map<String, String> reversePartitionIndex = new HashMap<String, String>();
     boolean indexInPartitionName = true;
-    for (String partitionId : state.getPartitionStringSet()) {
-      int lastPos = partitionId.lastIndexOf("_");
+    for (PartitionId partitionId : state.getPartitionSet()) {
+      String partitionName = partitionId.stringify();
+      int lastPos = partitionName.lastIndexOf("_");
       if (lastPos < 0) {
         indexInPartitionName = false;
         break;
       }
       try {
-        String idStr = partitionId.substring(lastPos + 1);
+        String idStr = partitionName.substring(lastPos + 1);
         int partition = Integer.parseInt(idStr);
-        partitionIndex.put(partitionId, partition);
-        reversePartitionIndex.put(state.getResourceName() + "_" + partition, partitionId);
+        partitionIndex.put(partitionName, partition);
+        reversePartitionIndex.put(state.getResourceId().stringify() + "_" + partition,
+            partitionName);
       } catch (Exception e) {
         indexInPartitionName = false;
         partitionIndex.clear();
@@ -58,19 +64,20 @@ public class RebalanceUtil {
 
     if (indexInPartitionName == false) {
       List<String> partitions = new ArrayList<String>();
-      partitions.addAll(state.getPartitionStringSet());
+      partitions.addAll(Lists.transform(Lists.newArrayList(state.getPartitionSet()),
+          Functions.toStringFunction()));
       Collections.sort(partitions);
       for (int i = 0; i < partitions.size(); i++) {
         partitionIndex.put(partitions.get(i), i);
-        reversePartitionIndex.put(state.getResourceName() + "_" + i, partitions.get(i));
+        reversePartitionIndex.put(state.getResourceId().stringify() + "_" + i, partitions.get(i));
       }
     }
 
     Map<String, List<Integer>> nodeMasterAssignmentMap = new TreeMap<String, List<Integer>>();
     Map<String, Map<String, List<Integer>>> combinedNodeSlaveAssignmentMap =
         new TreeMap<String, Map<String, List<Integer>>>();
-    for (String partition : state.getPartitionStringSet()) {
-      List<String> instances = state.getRecord().getListField(partition);
+    for (PartitionId partition : state.getPartitionSet()) {
+      List<String> instances = state.getRecord().getListField(partition.stringify());
       String master = instances.get(0);
       if (!nodeMasterAssignmentMap.containsKey(master)) {
         nodeMasterAssignmentMap.put(master, new ArrayList<Integer>());

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/TestZKCallback.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/TestZKCallback.java b/helix-core/src/test/java/org/apache/helix/TestZKCallback.java
index 7abfd4c..40a189d 100644
--- a/helix-core/src/test/java/org/apache/helix/TestZKCallback.java
+++ b/helix-core/src/test/java/org/apache/helix/TestZKCallback.java
@@ -160,7 +160,7 @@ public class TestZKCallback extends ZkUnitTestBase {
     IdealState idealState = new IdealState("db-1234");
     idealState.setNumPartitions(400);
     idealState.setReplicas(Integer.toString(2));
-    idealState.setStateModelDefRef("StateModeldef");
+    idealState.setStateModelDefId(StateModelDefId.from("StateModeldef"));
     accessor.setProperty(keyBuilder.idealState("db-1234"), idealState);
     Thread.sleep(100);
     AssertJUnit.assertTrue(testListener.idealStateChangeReceived);

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/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 9a484d6..7eb53fe 100644
--- a/helix-core/src/test/java/org/apache/helix/ZkUnitTestBase.java
+++ b/helix-core/src/test/java/org/apache/helix/ZkUnitTestBase.java
@@ -29,7 +29,9 @@ import org.I0Itec.zkclient.ZkConnection;
 import org.I0Itec.zkclient.ZkServer;
 import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.api.MessageId;
+import org.apache.helix.api.PartitionId;
 import org.apache.helix.api.State;
+import org.apache.helix.api.StateModelDefId;
 import org.apache.helix.controller.pipeline.Pipeline;
 import org.apache.helix.controller.pipeline.Stage;
 import org.apache.helix.controller.pipeline.StageContext;
@@ -166,7 +168,7 @@ public class ZkUnitTestBase {
   public void verifyEnabled(ZkClient zkClient, String clusterName, String instance,
       boolean wantEnabled) {
     ZKHelixDataAccessor accessor =
-        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(zkClient));
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
     Builder keyBuilder = accessor.keyBuilder();
 
     InstanceConfig config = accessor.getProperty(keyBuilder.instanceConfig(instance));
@@ -175,15 +177,15 @@ public class ZkUnitTestBase {
 
   public void verifyReplication(ZkClient zkClient, String clusterName, String resource, int repl) {
     ZKHelixDataAccessor accessor =
-        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(zkClient));
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
     Builder keyBuilder = accessor.keyBuilder();
 
     IdealState idealState = accessor.getProperty(keyBuilder.idealState(resource));
-    for (String partitionName : idealState.getPartitionStringSet()) {
+    for (PartitionId partitionId : idealState.getPartitionSet()) {
       if (idealState.getRebalanceMode() == RebalanceMode.SEMI_AUTO) {
-        AssertJUnit.assertEquals(repl, idealState.getPreferenceList(partitionName).size());
+        AssertJUnit.assertEquals(repl, idealState.getPreferenceList(partitionId).size());
       } else if (idealState.getRebalanceMode() == RebalanceMode.CUSTOMIZED) {
-        AssertJUnit.assertEquals(repl, idealState.getInstanceStateMap(partitionName).size());
+        AssertJUnit.assertEquals(repl, idealState.getParticipantStateMap(partitionId).size());
       }
     }
   }
@@ -249,20 +251,19 @@ public class ZkUnitTestBase {
 
   protected void setupStateModel(String clusterName) {
     ZKHelixDataAccessor accessor =
-        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(_gZkClient));
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
     Builder keyBuilder = accessor.keyBuilder();
 
-    StateModelConfigGenerator generator = new StateModelConfigGenerator();
     StateModelDefinition masterSlave =
-        new StateModelDefinition(generator.generateConfigForMasterSlave());
+        new StateModelDefinition(StateModelConfigGenerator.generateConfigForMasterSlave());
     accessor.setProperty(keyBuilder.stateModelDef(masterSlave.getId()), masterSlave);
 
     StateModelDefinition leaderStandby =
-        new StateModelDefinition(generator.generateConfigForLeaderStandby());
+        new StateModelDefinition(StateModelConfigGenerator.generateConfigForLeaderStandby());
     accessor.setProperty(keyBuilder.stateModelDef(leaderStandby.getId()), leaderStandby);
 
     StateModelDefinition onlineOffline =
-        new StateModelDefinition(generator.generateConfigForOnlineOffline());
+        new StateModelDefinition(StateModelConfigGenerator.generateConfigForOnlineOffline());
     accessor.setProperty(keyBuilder.stateModelDef(onlineOffline.getId()), onlineOffline);
 
   }
@@ -270,7 +271,7 @@ public class ZkUnitTestBase {
   protected List<IdealState> setupIdealState(String clusterName, int[] nodes, String[] resources,
       int partitions, int replicas) {
     ZKHelixDataAccessor accessor =
-        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(_gZkClient));
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
     Builder keyBuilder = accessor.keyBuilder();
 
     List<IdealState> idealStates = new ArrayList<IdealState>();
@@ -291,7 +292,7 @@ public class ZkUnitTestBase {
       }
 
       idealState.setReplicas(Integer.toString(replicas));
-      idealState.setStateModelDefRef("MasterSlave");
+      idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
       idealState.setRebalanceMode(RebalanceMode.SEMI_AUTO);
       idealState.setNumPartitions(partitions);
       idealStates.add(idealState);

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/controller/stages/BaseStageTest.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/controller/stages/BaseStageTest.java b/helix-core/src/test/java/org/apache/helix/controller/stages/BaseStageTest.java
index 4d96431..f7cdcba 100644
--- a/helix-core/src/test/java/org/apache/helix/controller/stages/BaseStageTest.java
+++ b/helix-core/src/test/java/org/apache/helix/controller/stages/BaseStageTest.java
@@ -99,7 +99,7 @@ public class BaseStageTest {
         record.setListField(resourceName + "_" + p, value);
       }
       IdealState idealState = new IdealState(record);
-      idealState.setStateModelDefRef("MasterSlave");
+      idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
       idealState.setRebalanceMode(rebalanceMode);
       idealState.setNumPartitions(partitions);
       idealStates.add(idealState);

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/controller/stages/TestBestPossibleCalcStageCompatibility.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/controller/stages/TestBestPossibleCalcStageCompatibility.java b/helix-core/src/test/java/org/apache/helix/controller/stages/TestBestPossibleCalcStageCompatibility.java
index 8027d11..a8783c3 100644
--- a/helix-core/src/test/java/org/apache/helix/controller/stages/TestBestPossibleCalcStageCompatibility.java
+++ b/helix-core/src/test/java/org/apache/helix/controller/stages/TestBestPossibleCalcStageCompatibility.java
@@ -31,6 +31,7 @@ import org.apache.helix.api.PartitionId;
 import org.apache.helix.api.ResourceConfig;
 import org.apache.helix.api.ResourceId;
 import org.apache.helix.api.State;
+import org.apache.helix.api.StateModelDefId;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.model.IdealState.IdealStateModeProperty;
 import org.testng.AssertJUnit;
@@ -130,17 +131,17 @@ public class TestBestPossibleCalcStageCompatibility extends BaseStageTest {
       String resourceName = resources[i];
       IdealState idealState = new IdealState(resourceName);
       for (int p = 0; p < partitions; p++) {
-        List<String> value = new ArrayList<String>();
+        List<ParticipantId> value = new ArrayList<ParticipantId>();
         for (int r = 0; r < replicas; r++) {
-          value.add("localhost_" + (p + r + 1) % nodes);
+          value.add(ParticipantId.from("localhost_" + (p + r + 1) % nodes));
         }
-        idealState.setPreferenceList(resourceName + "_" + p, value);
+        idealState.setPreferenceList(PartitionId.from(resourceName + "_" + p), value);
         Map<ParticipantId, State> preferenceMap = new HashMap<ParticipantId, State>();
         preferenceMap.put(ParticipantId.from("localhost_" + (p + 1) % 5), State.from("MASTER"));
         idealState.setParticipantStateMap(
             PartitionId.from(ResourceId.from(resourceName), Integer.toString(p)), preferenceMap);
       }
-      idealState.setStateModelDefRef("MasterSlave");
+      idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
       idealState.setIdealStateMode(mode.toString());
       idealState.setNumPartitions(partitions);
       idealStates.add(idealState);

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/controller/stages/TestCompatibilityCheckStage.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/controller/stages/TestCompatibilityCheckStage.java b/helix-core/src/test/java/org/apache/helix/controller/stages/TestCompatibilityCheckStage.java
index 47875fc..28b8a19 100644
--- a/helix-core/src/test/java/org/apache/helix/controller/stages/TestCompatibilityCheckStage.java
+++ b/helix-core/src/test/java/org/apache/helix/controller/stages/TestCompatibilityCheckStage.java
@@ -25,6 +25,7 @@ import java.util.List;
 import org.apache.helix.Mocks;
 import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.ZNRecord;
+import org.apache.helix.api.StateModelDefId;
 import org.apache.helix.controller.pipeline.StageContext;
 import org.apache.helix.controller.strategy.DefaultTwoStateStrategy;
 import org.apache.helix.model.IdealState;
@@ -52,7 +53,7 @@ public class TestCompatibilityCheckStage extends BaseStageTest {
         DefaultTwoStateStrategy.calculateIdealState(instances, partitions, replicas, resourceName,
             "MASTER", "SLAVE");
     IdealState idealState = new IdealState(record);
-    idealState.setStateModelDefRef("MasterSlave");
+    idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
 
     Builder keyBuilder = accessor.keyBuilder();
     accessor.setProperty(keyBuilder.idealState(resourceName), idealState);

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/controller/stages/TestResourceComputationStage.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/controller/stages/TestResourceComputationStage.java b/helix-core/src/test/java/org/apache/helix/controller/stages/TestResourceComputationStage.java
index b9cba1f..45507a1 100644
--- a/helix-core/src/test/java/org/apache/helix/controller/stages/TestResourceComputationStage.java
+++ b/helix-core/src/test/java/org/apache/helix/controller/stages/TestResourceComputationStage.java
@@ -31,6 +31,7 @@ import org.apache.helix.api.PartitionId;
 import org.apache.helix.api.ResourceConfig;
 import org.apache.helix.api.ResourceId;
 import org.apache.helix.api.State;
+import org.apache.helix.api.StateModelDefId;
 import org.apache.helix.controller.pipeline.StageContext;
 import org.apache.helix.controller.strategy.DefaultTwoStateStrategy;
 import org.apache.helix.model.CurrentState;
@@ -60,7 +61,7 @@ public class TestResourceComputationStage extends BaseStageTest {
         DefaultTwoStateStrategy.calculateIdealState(instances, partitions, replicas, resourceName,
             "MASTER", "SLAVE");
     IdealState idealState = new IdealState(record);
-    idealState.setStateModelDefRef("MasterSlave");
+    idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
 
     HelixDataAccessor accessor = manager.getHelixDataAccessor();
     Builder keyBuilder = accessor.keyBuilder();
@@ -104,7 +105,7 @@ public class TestResourceComputationStage extends BaseStageTest {
       AssertJUnit.assertTrue(resourceMap.containsKey(resourceId));
       AssertJUnit.assertEquals(resourceMap.get(resourceId).getId(), resourceId);
       AssertJUnit.assertEquals(resourceMap.get(resourceId).getRebalancerConfig()
-          .getStateModelDefId(), idealState.getStateModelDefRef());
+          .getStateModelDefId(), idealState.getStateModelDefId());
       AssertJUnit.assertEquals(resourceMap.get(resourceId).getPartitionSet().size(),
           idealState.getNumPartitions());
     }
@@ -129,7 +130,7 @@ public class TestResourceComputationStage extends BaseStageTest {
           DefaultTwoStateStrategy.calculateIdealState(instances, partitions, replicas,
               resourceName, "MASTER", "SLAVE");
       IdealState idealState = new IdealState(record);
-      idealState.setStateModelDefRef("MasterSlave");
+      idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
 
       HelixDataAccessor accessor = manager.getHelixDataAccessor();
       Builder keyBuilder = accessor.keyBuilder();

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/controller/strategy/TestNewAutoRebalanceStrategy.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/controller/strategy/TestNewAutoRebalanceStrategy.java b/helix-core/src/test/java/org/apache/helix/controller/strategy/TestNewAutoRebalanceStrategy.java
index 02e7e29..7eb811b 100644
--- a/helix-core/src/test/java/org/apache/helix/controller/strategy/TestNewAutoRebalanceStrategy.java
+++ b/helix-core/src/test/java/org/apache/helix/controller/strategy/TestNewAutoRebalanceStrategy.java
@@ -35,6 +35,8 @@ import java.util.TreeSet;
 
 import org.apache.helix.HelixDefinedState;
 import org.apache.helix.ZNRecord;
+import org.apache.helix.api.ClusterConfig;
+import org.apache.helix.api.ClusterId;
 import org.apache.helix.api.MessageId;
 import org.apache.helix.api.Participant;
 import org.apache.helix.api.ParticipantId;
@@ -220,6 +222,15 @@ public class TestNewAutoRebalanceStrategy {
     private Map<String, Map<String, String>> getMapping(final Map<String, List<String>> listResult) {
       final Map<PartitionId, Map<ParticipantId, State>> mapResult =
           new HashMap<PartitionId, Map<ParticipantId, State>>();
+      ClusterId clusterId = ClusterId.from("clusterId");
+      ClusterConfig.Builder clusterConfigBuilder =
+          new ClusterConfig.Builder(clusterId).addStateModelDefinition(_stateModelDef);
+      for (State state : _stateModelDef.getStatesPriorityList()) {
+        clusterConfigBuilder.addStateUpperBoundConstraint(Scope.cluster(clusterId),
+            _stateModelDef.getStateModelDefId(), state,
+            _stateModelDef.getNumParticipantsPerState(state));
+      }
+      ClusterConfig clusterConfig = clusterConfigBuilder.build();
       for (String partition : _partitions) {
         PartitionId partitionId = PartitionId.from(partition);
         Set<ParticipantId> disabledParticipantsForPartition = Collections.emptySet();
@@ -249,9 +260,9 @@ public class TestNewAutoRebalanceStrategy {
         Map<ParticipantId, State> replicaMap =
             ResourceAssignment.replicaMapFromStringMap(_currentMapping.get(partition));
         Map<ParticipantId, State> assignment =
-            NewConstraintBasedAssignment.computeAutoBestStateForPartition(liveParticipantMap,
-                _stateModelDef, participantPreferenceList, replicaMap,
-                disabledParticipantsForPartition);
+            NewConstraintBasedAssignment.computeAutoBestStateForPartition(clusterConfig,
+                ResourceId.from(RESOURCE_NAME), liveParticipantMap, _stateModelDef,
+                participantPreferenceList, replicaMap, disabledParticipantsForPartition);
         mapResult.put(partitionId, assignment);
       }
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java b/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java
index f38f3b4..5325e30 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestAddStateModelFactoryAfterConnect.java
@@ -25,6 +25,7 @@ import java.util.List;
 import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.TestHelper;
 import org.apache.helix.ZNRecord;
+import org.apache.helix.api.StateModelFactoryId;
 import org.apache.helix.manager.zk.ZKHelixDataAccessor;
 import org.apache.helix.manager.zk.ZkBaseDataAccessor;
 import org.apache.helix.mock.controller.ClusterController;
@@ -84,7 +85,7 @@ public class TestAddStateModelFactoryAfterConnect extends ZkIntegrationTestBase
     ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, baseAccessor);
     Builder keyBuilder = accessor.keyBuilder();
     IdealState idealState = accessor.getProperty(keyBuilder.idealState("TestDB1"));
-    idealState.setStateModelFactoryName("TestDB1_Factory");
+    idealState.setStateModelFactoryId(StateModelFactoryId.from("TestDB1_Factory"));
     accessor.setProperty(keyBuilder.idealState("TestDB1"), idealState);
     setupTool.rebalanceStorageCluster(clusterName, "TestDB1", 3);
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/integration/TestAutoRebalance.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestAutoRebalance.java b/helix-core/src/test/java/org/apache/helix/integration/TestAutoRebalance.java
index ba44fcf..e837626 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestAutoRebalance.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestAutoRebalance.java
@@ -30,6 +30,7 @@ import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.TestHelper;
 import org.apache.helix.TestHelper.StartCMResult;
 import org.apache.helix.ZNRecord;
+import org.apache.helix.api.State;
 import org.apache.helix.controller.HelixControllerMain;
 import org.apache.helix.controller.stages.ClusterDataCache;
 import org.apache.helix.manager.zk.ZKHelixDataAccessor;
@@ -262,13 +263,13 @@ public class TestAutoRebalance extends ZkStandAloneCMTestBaseWithPropertyServerC
         return false;
       }
 
-      int numberOfPartitions = idealState.getRecord().getListFields()
-              .size();
+      int numberOfPartitions = idealState.getRecord().getListFields().size();
       ClusterDataCache cache = new ClusterDataCache();
       cache.refresh(accessor);
-      String masterValue =
-          cache.getStateModelDef(cache.getIdealState(_resourceName).getStateModelDefRef())
-              .getStatesPriorityStringList().get(0);
+      State masterValue =
+          cache
+              .getStateModelDef(cache.getIdealState(_resourceName).getStateModelDefId().stringify())
+              .getStatesPriorityList().get(0);
       int replicas = Integer.parseInt(cache.getIdealState(_resourceName).getReplicas());
       String instanceGroupTag = cache.getIdealState(_resourceName).getInstanceGroupTag();
       int instances = 0;
@@ -284,8 +285,8 @@ public class TestAutoRebalance extends ZkStandAloneCMTestBaseWithPropertyServerC
       if (ev == null) {
         return false;
       }
-      return verifyBalanceExternalView(ev.getRecord(), numberOfPartitions, masterValue, replicas,
-          instances);
+      return verifyBalanceExternalView(ev.getRecord(), numberOfPartitions, masterValue.toString(),
+          replicas, instances);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/integration/TestAutoRebalancePartitionLimit.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestAutoRebalancePartitionLimit.java b/helix-core/src/test/java/org/apache/helix/integration/TestAutoRebalancePartitionLimit.java
index 2a0c645..2446b67 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestAutoRebalancePartitionLimit.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestAutoRebalancePartitionLimit.java
@@ -29,6 +29,7 @@ import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.TestHelper;
 import org.apache.helix.TestHelper.StartCMResult;
 import org.apache.helix.ZNRecord;
+import org.apache.helix.api.State;
 import org.apache.helix.controller.HelixControllerMain;
 import org.apache.helix.controller.stages.ClusterDataCache;
 import org.apache.helix.manager.zk.ZKHelixDataAccessor;
@@ -229,13 +230,15 @@ public class TestAutoRebalancePartitionLimit extends ZkStandAloneCMTestBaseWithP
               .size();
       ClusterDataCache cache = new ClusterDataCache();
       cache.refresh(accessor);
-      String masterValue =
-          cache.getStateModelDef(cache.getIdealState(_resourceName).getStateModelDefRef())
-              .getStatesPriorityStringList().get(0);
+      State masterValue =
+          cache
+              .getStateModelDef(cache.getIdealState(_resourceName).getStateModelDefId().stringify())
+              .getStatesPriorityList().get(0);
       int replicas = Integer.parseInt(cache.getIdealState(_resourceName).getReplicas());
       return verifyBalanceExternalView(accessor.getProperty(keyBuilder.externalView(_resourceName))
-          .getRecord(), numberOfPartitions, masterValue, replicas, cache.getLiveInstances().size(),
-          cache.getIdealState(_resourceName).getMaxPartitionsPerInstance());
+          .getRecord(), numberOfPartitions, masterValue.toString(), replicas, cache
+          .getLiveInstances().size(), cache.getIdealState(_resourceName)
+          .getMaxPartitionsPerInstance());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/integration/TestCustomizedIdealStateRebalancer.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestCustomizedIdealStateRebalancer.java b/helix-core/src/test/java/org/apache/helix/integration/TestCustomizedIdealStateRebalancer.java
index 1b0a0b4..4f7b814 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestCustomizedIdealStateRebalancer.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestCustomizedIdealStateRebalancer.java
@@ -107,9 +107,9 @@ public class TestCustomizedIdealStateRebalancer extends
       Assert.assertEquals(ev.getStateMap(partition).size(), 1);
     }
     IdealState is = accessor.getProperty(keyBuilder.idealState(db2));
-    for (String partition : is.getPartitionStringSet()) {
+    for (PartitionId partition : is.getPartitionSet()) {
       Assert.assertEquals(is.getPreferenceList(partition).size(), 0);
-      Assert.assertEquals(is.getInstanceStateMap(partition).size(), 0);
+      Assert.assertEquals(is.getParticipantStateMap(partition).size(), 0);
     }
     Assert.assertTrue(testRebalancerInvoked);
   }
@@ -136,9 +136,11 @@ public class TestCustomizedIdealStateRebalancer extends
                 .size();
         ClusterDataCache cache = new ClusterDataCache();
         cache.refresh(accessor);
-        String masterValue =
-            cache.getStateModelDef(cache.getIdealState(_resourceName).getStateModelDefRef())
-                .getStatesPriorityStringList().get(0);
+        State masterValue =
+            cache
+                .getStateModelDef(
+                    cache.getIdealState(_resourceName).getStateModelDefId().stringify())
+                .getStatesPriorityList().get(0);
         int replicas = Integer.parseInt(cache.getIdealState(_resourceName).getReplicas());
         String instanceGroupTag = cache.getIdealState(_resourceName).getInstanceGroupTag();
         int instances = 0;
@@ -151,8 +153,8 @@ public class TestCustomizedIdealStateRebalancer extends
           instances = cache.getLiveInstances().size();
         }
         ExternalView externalView = accessor.getProperty(keyBuilder.externalView(_resourceName));
-        return verifyBalanceExternalView(externalView.getRecord(), numberOfPartitions, masterValue,
-            replicas, instances);
+        return verifyBalanceExternalView(externalView.getRecord(), numberOfPartitions,
+            masterValue.toString(), replicas, instances);
       } catch (Exception e) {
         return false;
       }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/integration/TestInvalidAutoIdealState.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestInvalidAutoIdealState.java b/helix-core/src/test/java/org/apache/helix/integration/TestInvalidAutoIdealState.java
index fa4d5a8..7f4335f 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestInvalidAutoIdealState.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestInvalidAutoIdealState.java
@@ -28,6 +28,7 @@ import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.TestHelper;
 import org.apache.helix.ZkUnitTestBase;
+import org.apache.helix.api.StateModelDefId;
 import org.apache.helix.manager.zk.ZKHelixAdmin;
 import org.apache.helix.mock.controller.ClusterController;
 import org.apache.helix.mock.participant.MockParticipant;
@@ -81,7 +82,7 @@ public class TestInvalidAutoIdealState extends ZkUnitTestBase {
     idealState.setRebalanceMode(RebalanceMode.SEMI_AUTO);
     idealState.setNumPartitions(2);
     idealState.setReplicas("" + 2); // should be 3
-    idealState.setStateModelDefRef("MasterSlave");
+    idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
     idealState.getRecord().setListField("TestDB_0",
         Arrays.asList("localhost_12918", "localhost_12919", "localhost_12920"));
     idealState.getRecord().setListField("TestDB_1",

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/integration/TestRenamePartition.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestRenamePartition.java b/helix-core/src/test/java/org/apache/helix/integration/TestRenamePartition.java
index 37a62ef..a0330d4 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestRenamePartition.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestRenamePartition.java
@@ -27,6 +27,7 @@ import java.util.Map;
 import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.TestHelper;
 import org.apache.helix.ZNRecord;
+import org.apache.helix.api.StateModelDefId;
 import org.apache.helix.controller.HelixControllerMain;
 import org.apache.helix.controller.strategy.DefaultTwoStateStrategy;
 import org.apache.helix.manager.zk.ZKHelixDataAccessor;
@@ -100,7 +101,7 @@ public class TestRenamePartition extends ZkIntegrationTestBase {
     IdealState idealState = new IdealState(destIS);
     idealState.setRebalanceMode(RebalanceMode.CUSTOMIZED);
     idealState.setReplicas("3");
-    idealState.setStateModelDefRef("MasterSlave");
+    idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
 
     ZKHelixDataAccessor accessor =
         new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(_gZkClient));

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/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 0a1e76a..90d317c 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
@@ -535,14 +535,14 @@ public class TestSchedulerMessage extends ZkStandAloneCMTestBaseWithPropertyServ
           keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.toString(), msgId);
       ZNRecord statusUpdate = helixDataAccessor.getProperty(controllerTaskStatus).getRecord();
       Assert.assertTrue(statusUpdate.getMapField("SentMessageCount").get("MessageCount")
-          .equals("" + (_PARTITIONS * 3 / 5)));
+          .equals("" + avgReplicas));
       int messageResultCount = 0;
       for (String key : statusUpdate.getMapFields().keySet()) {
         if (key.startsWith("MessageResult")) {
           messageResultCount++;
         }
       }
-      Assert.assertEquals(messageResultCount, _PARTITIONS * 3 / 5);
+      Assert.assertEquals(messageResultCount, avgReplicas);
 
       int count = 0;
       // System.out.println(i);
@@ -552,10 +552,7 @@ public class TestSchedulerMessage extends ZkStandAloneCMTestBaseWithPropertyServ
       }
       // System.out.println(count);
 
-      if (count != avgReplicas * (i + 1)) {
-        System.out.println("count: " + count + ", expect: " + avgReplicas * (i + 1));
-      }
-      // Assert.assertEquals(count, _PARTITIONS * 3 / 5 * (i + 1));
+      Assert.assertEquals(count, avgReplicas * (i + 1));
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java b/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java
index 7500003..4fff890 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java
@@ -31,6 +31,9 @@ import org.apache.helix.NotificationContext;
 import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.TestHelper;
 import org.apache.helix.TestHelper.StartCMResult;
+import org.apache.helix.api.ParticipantId;
+import org.apache.helix.api.PartitionId;
+import org.apache.helix.api.State;
 import org.apache.helix.controller.HelixControllerMain;
 import org.apache.helix.manager.zk.ZNRecordSerializer;
 import org.apache.helix.manager.zk.ZkClient;
@@ -176,9 +179,9 @@ public class TestStateTransitionTimeout extends ZkStandAloneCMTestBase {
       String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
       SleepStateModelFactory factory = new SleepStateModelFactory(1000);
       factories.put(instanceName, factory);
-      for (String p : idealState.getPartitionStringSet()) {
-        if (idealState.getPreferenceList(p).get(0).equals(instanceName)) {
-          factory.addPartition(p);
+      for (PartitionId p : idealState.getPartitionSet()) {
+        if (idealState.getPreferenceList(p).get(0).equals(ParticipantId.from(instanceName))) {
+          factory.addPartition(p.stringify());
         }
       }
 
@@ -198,11 +201,11 @@ public class TestStateTransitionTimeout extends ZkStandAloneCMTestBase {
 
     Builder kb = accessor.keyBuilder();
     ExternalView ev = accessor.getProperty(kb.externalView(TEST_DB));
-    for (String p : idealState.getPartitionStringSet()) {
-      String idealMaster = idealState.getPreferenceList(p).get(0);
-      Assert.assertTrue(ev.getStateMap(p).get(idealMaster).equals("ERROR"));
+    for (PartitionId p : idealState.getPartitionSet()) {
+      ParticipantId idealMaster = idealState.getPreferenceList(p).get(0);
+      Assert.assertTrue(ev.getStateMap(p).get(idealMaster).equals(State.from("ERROR")));
 
-      TimeOutStateModel model = factories.get(idealMaster).getStateModel(p);
+      TimeOutStateModel model = factories.get(idealMaster.stringify()).getStateModel(p.stringify());
       Assert.assertEquals(model._errorCallcount, 1);
       Assert.assertEquals(model._error.getCode(), ErrorCode.TIMEOUT);
     }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/integration/TestZkReconnect.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestZkReconnect.java b/helix-core/src/test/java/org/apache/helix/integration/TestZkReconnect.java
index e2c04d6..2be136d 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestZkReconnect.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestZkReconnect.java
@@ -35,6 +35,7 @@ import org.apache.helix.api.ParticipantId;
 import org.apache.helix.api.PartitionId;
 import org.apache.helix.api.ResourceId;
 import org.apache.helix.api.State;
+import org.apache.helix.api.StateModelFactoryId;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.model.Message;
 import org.apache.helix.participant.statemachine.StateModel;
@@ -100,7 +101,7 @@ public class TestZkReconnect {
 
     IdealState idealState = helixAdmin.getResourceIdealState(clusterName, resourceName);
     idealState.setReplicas("1");
-    idealState.setStateModelFactoryName("test");
+    idealState.setStateModelFactoryId(StateModelFactoryId.from("test"));
     idealState.setPartitionState(PartitionId.from(ResourceId.from(resourceName), "0"),
         ParticipantId.from(instanceId), State.from("ONLINE"));
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/manager/zk/TestZNRecordSizeLimit.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZNRecordSizeLimit.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZNRecordSizeLimit.java
index 5d09a92..cd65a42 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZNRecordSizeLimit.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZNRecordSizeLimit.java
@@ -27,6 +27,7 @@ import org.apache.helix.HelixProperty;
 import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.ZNRecord;
 import org.apache.helix.ZkUnitTestBase;
+import org.apache.helix.api.StateModelDefId;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.model.IdealState.RebalanceMode;
 import org.apache.helix.model.InstanceConfig;
@@ -108,11 +109,11 @@ public class TestZNRecordSizeLimit extends ZkUnitTestBase {
 
     // oversized data should not create any new data on zk
     ZKHelixDataAccessor accessor =
-        new ZKHelixDataAccessor(className, new ZkBaseDataAccessor(zkClient));
+        new ZKHelixDataAccessor(className, new ZkBaseDataAccessor<ZNRecord>(zkClient));
     Builder keyBuilder = accessor.keyBuilder();
 
     IdealState idealState = new IdealState("currentState");
-    idealState.setStateModelDefRef("MasterSlave");
+    idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
     idealState.setRebalanceMode(RebalanceMode.SEMI_AUTO);
     idealState.setNumPartitions(10);
 
@@ -128,7 +129,7 @@ public class TestZNRecordSizeLimit extends ZkUnitTestBase {
 
     // legal sized data gets written to zk
     idealState.getRecord().getSimpleFields().clear();
-    idealState.setStateModelDefRef("MasterSlave");
+    idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
     idealState.setRebalanceMode(RebalanceMode.SEMI_AUTO);
     idealState.setNumPartitions(10);
 
@@ -142,7 +143,7 @@ public class TestZNRecordSizeLimit extends ZkUnitTestBase {
 
     // oversized data should not update existing data on zk
     idealState.getRecord().getSimpleFields().clear();
-    idealState.setStateModelDefRef("MasterSlave");
+    idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
     idealState.setRebalanceMode(RebalanceMode.SEMI_AUTO);
     idealState.setNumPartitions(10);
     for (int i = 900; i < 1024; i++) {
@@ -231,12 +232,12 @@ public class TestZNRecordSizeLimit extends ZkUnitTestBase {
 
     // oversized data should not create any new data on zk
     ZKHelixDataAccessor accessor =
-        new ZKHelixDataAccessor(className, new ZkBaseDataAccessor(zkClient));
+        new ZKHelixDataAccessor(className, new ZkBaseDataAccessor<ZNRecord>(zkClient));
     Builder keyBuilder = accessor.keyBuilder();
 
     // ZNRecord statusUpdates = new ZNRecord("statusUpdates");
     IdealState idealState = new IdealState("currentState");
-    idealState.setStateModelDefRef("MasterSlave");
+    idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
     idealState.setRebalanceMode(RebalanceMode.SEMI_AUTO);
     idealState.setNumPartitions(10);
 
@@ -250,7 +251,7 @@ public class TestZNRecordSizeLimit extends ZkUnitTestBase {
 
     // legal sized data gets written to zk
     idealState.getRecord().getSimpleFields().clear();
-    idealState.setStateModelDefRef("MasterSlave");
+    idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
     idealState.setRebalanceMode(RebalanceMode.SEMI_AUTO);
     idealState.setNumPartitions(10);
 
@@ -264,7 +265,7 @@ public class TestZNRecordSizeLimit extends ZkUnitTestBase {
 
     // oversized data should not update existing data on zk
     idealState.getRecord().getSimpleFields().clear();
-    idealState.setStateModelDefRef("MasterSlave");
+    idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
     idealState.setRebalanceMode(RebalanceMode.SEMI_AUTO);
     idealState.setNumPartitions(10);
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
index 908a248..187a077 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
@@ -33,6 +33,7 @@ import org.apache.helix.PropertyType;
 import org.apache.helix.TestHelper;
 import org.apache.helix.ZNRecord;
 import org.apache.helix.ZkUnitTestBase;
+import org.apache.helix.api.ConstraintId;
 import org.apache.helix.model.ClusterConstraints;
 import org.apache.helix.model.ClusterConstraints.ConstraintAttribute;
 import org.apache.helix.model.ClusterConstraints.ConstraintType;
@@ -270,7 +271,7 @@ public class TestZkHelixAdmin extends ZkUnitTestBase {
     constraints =
         accessor.getProperty(keyBuilder.constraint(ConstraintType.MESSAGE_CONSTRAINT.toString()));
     Assert.assertNotNull(constraints, "message-constraint should exist");
-    ConstraintItem item = constraints.getConstraintItem("constraint1");
+    ConstraintItem item = constraints.getConstraintItem(ConstraintId.from("constraint1"));
     Assert.assertNotNull(item, "message-constraint for constraint1 should exist");
     Assert.assertEquals(item.getConstraintValue(), "1");
     Assert.assertEquals(item.getAttributeValue(ConstraintAttribute.RESOURCE), "MyDB");
@@ -278,7 +279,7 @@ public class TestZkHelixAdmin extends ZkUnitTestBase {
     // test admin.getMessageConstraints()
     constraints = tool.getConstraints(clusterName, ConstraintType.MESSAGE_CONSTRAINT);
     Assert.assertNotNull(constraints, "message-constraint should exist");
-    item = constraints.getConstraintItem("constraint1");
+    item = constraints.getConstraintItem(ConstraintId.from("constraint1"));
     Assert.assertNotNull(item, "message-constraint for constraint1 should exist");
     Assert.assertEquals(item.getConstraintValue(), "1");
     Assert.assertEquals(item.getAttributeValue(ConstraintAttribute.RESOURCE), "MyDB");
@@ -288,7 +289,7 @@ public class TestZkHelixAdmin extends ZkUnitTestBase {
     constraints =
         accessor.getProperty(keyBuilder.constraint(ConstraintType.MESSAGE_CONSTRAINT.toString()));
     Assert.assertNotNull(constraints, "message-constraint should exist");
-    item = constraints.getConstraintItem("constraint1");
+    item = constraints.getConstraintItem(ConstraintId.from("constraint1"));
     Assert.assertNull(item, "message-constraint for constraint1 should NOT exist");
 
     System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java b/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java
index 2045526..170578a 100644
--- a/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java
+++ b/helix-core/src/test/java/org/apache/helix/model/TestIdealState.java
@@ -29,6 +29,9 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.helix.TestHelper;
+import org.apache.helix.api.ParticipantId;
+import org.apache.helix.api.PartitionId;
+import org.apache.helix.api.StateModelDefId;
 import org.apache.helix.model.IdealState.IdealStateModeProperty;
 import org.apache.helix.model.IdealState.RebalanceMode;
 import org.testng.Assert;
@@ -52,24 +55,28 @@ public class TestIdealState {
 
     // test SEMI_AUTO mode
     idealState.setRebalanceMode(RebalanceMode.SEMI_AUTO);
-    Set<String> instances = idealState.getInstanceSet("TestDB_0");
+    Set<ParticipantId> instances = idealState.getParticipantSet(PartitionId.from("TestDB_0"));
     // System.out.println("instances: " + instances);
     Assert.assertEquals(instances.size(), 2, "Should contain node_1 and node_2");
-    Assert.assertTrue(instances.contains("node_1"), "Should contain node_1 and node_2");
-    Assert.assertTrue(instances.contains("node_2"), "Should contain node_1 and node_2");
+    Assert.assertTrue(instances.contains(ParticipantId.from("node_1")),
+        "Should contain node_1 and node_2");
+    Assert.assertTrue(instances.contains(ParticipantId.from("node_2")),
+        "Should contain node_1 and node_2");
 
-    instances = idealState.getInstanceSet("TestDB_nonExist_auto");
+    instances = idealState.getParticipantSet(PartitionId.from("TestDB_nonExist_auto"));
     Assert.assertEquals(instances, Collections.emptySet(), "Should get empty set");
 
     // test CUSTOMIZED mode
     idealState.setRebalanceMode(RebalanceMode.CUSTOMIZED);
-    instances = idealState.getInstanceSet("TestDB_1");
+    instances = idealState.getParticipantSet(PartitionId.from("TestDB_1"));
     // System.out.println("instances: " + instances);
     Assert.assertEquals(instances.size(), 2, "Should contain node_3 and node_4");
-    Assert.assertTrue(instances.contains("node_3"), "Should contain node_3 and node_4");
-    Assert.assertTrue(instances.contains("node_4"), "Should contain node_3 and node_4");
+    Assert.assertTrue(instances.contains(ParticipantId.from("node_3")),
+        "Should contain node_3 and node_4");
+    Assert.assertTrue(instances.contains(ParticipantId.from("node_4")),
+        "Should contain node_3 and node_4");
 
-    instances = idealState.getInstanceSet("TestDB_nonExist_custom");
+    instances = idealState.getParticipantSet(PartitionId.from("TestDB_nonExist_custom"));
     Assert.assertEquals(instances, Collections.emptySet(), "Should get empty set");
 
     System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis()));
@@ -80,7 +87,7 @@ public class TestIdealState {
     IdealState idealState = new IdealState("test-db");
     idealState.setRebalanceMode(RebalanceMode.SEMI_AUTO);
     idealState.setNumPartitions(4);
-    idealState.setStateModelDefRef("MasterSlave");
+    idealState.setStateModelDefId(StateModelDefId.from("MasterSlave"));
 
     idealState.setReplicas("" + 2);
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/243f2adf/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java b/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java
index 6935de4..a9679de 100644
--- a/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java
+++ b/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java
@@ -29,6 +29,8 @@ import org.apache.helix.BaseDataAccessor;
 import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.TestHelper;
 import org.apache.helix.ZNRecord;
+import org.apache.helix.api.ParticipantId;
+import org.apache.helix.api.PartitionId;
 import org.apache.helix.controller.HelixControllerMain;
 import org.apache.helix.integration.ZkIntegrationTestBase;
 import org.apache.helix.manager.zk.ZKHelixDataAccessor;
@@ -651,13 +653,13 @@ public class TestHelixAdminCli extends ZkIntegrationTestBase {
     ClusterSetup.processCommandLineArgs(command.split("\\s+"));
 
     IdealState dbIs = accessor.getProperty(accessor.keyBuilder().idealState("db_11"));
-    Set<String> hosts = new HashSet<String>();
-    for (String p : dbIs.getPartitionStringSet()) {
-      for (String hostName : dbIs.getInstanceStateMap(p).keySet()) {
+    Set<ParticipantId> hosts = new HashSet<ParticipantId>();
+    for (PartitionId p : dbIs.getPartitionSet()) {
+      for (ParticipantId participantId : dbIs.getParticipantStateMap(p).keySet()) {
         InstanceConfig config =
-            accessor.getProperty(accessor.keyBuilder().instanceConfig(hostName));
+            accessor.getProperty(accessor.keyBuilder().instanceConfig(participantId.stringify()));
         Assert.assertTrue(config.containsTag("tag1"));
-        hosts.add(hostName);
+        hosts.add(participantId);
       }
     }
     Assert.assertEquals(hosts.size(), 2);
@@ -673,13 +675,13 @@ public class TestHelixAdminCli extends ZkIntegrationTestBase {
     ClusterSetup.processCommandLineArgs(command.split("\\s+"));
 
     dbIs = accessor.getProperty(accessor.keyBuilder().idealState("db_11"));
-    hosts = new HashSet<String>();
-    for (String p : dbIs.getPartitionStringSet()) {
-      for (String hostName : dbIs.getInstanceStateMap(p).keySet()) {
+    hosts = new HashSet<ParticipantId>();
+    for (PartitionId p : dbIs.getPartitionSet()) {
+      for (ParticipantId participantId : dbIs.getParticipantStateMap(p).keySet()) {
         InstanceConfig config =
-            accessor.getProperty(accessor.keyBuilder().instanceConfig(hostName));
+            accessor.getProperty(accessor.keyBuilder().instanceConfig(participantId.stringify()));
         Assert.assertTrue(config.containsTag("tag2"));
-        hosts.add(hostName);
+        hosts.add(participantId);
       }
     }
     Assert.assertEquals(hosts.size(), 4);
@@ -701,13 +703,13 @@ public class TestHelixAdminCli extends ZkIntegrationTestBase {
     command = "-zkSvr localhost:2183 -rebalance " + clusterName + " db_11 3 -instanceGroupTag tag2";
     ClusterSetup.processCommandLineArgs(command.split("\\s+"));
     dbIs = accessor.getProperty(accessor.keyBuilder().idealState("db_11"));
-    hosts = new HashSet<String>();
-    for (String p : dbIs.getPartitionStringSet()) {
-      for (String hostName : dbIs.getInstanceStateMap(p).keySet()) {
+    hosts = new HashSet<ParticipantId>();
+    for (PartitionId p : dbIs.getPartitionSet()) {
+      for (ParticipantId participantId : dbIs.getParticipantStateMap(p).keySet()) {
         InstanceConfig config =
-            accessor.getProperty(accessor.keyBuilder().instanceConfig(hostName));
+            accessor.getProperty(accessor.keyBuilder().instanceConfig(participantId.stringify()));
         Assert.assertTrue(config.containsTag("tag2"));
-        hosts.add(hostName);
+        hosts.add(participantId);
       }
     }
     Assert.assertEquals(hosts.size(), 3);