helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject [2/2] git commit: HELIX-62: add ideal-state builders, move config-scope-builder and state-transition builder to model.builder package
Date Wed, 20 Mar 2013 22:14:19 GMT
HELIX-62: add ideal-state builders, move config-scope-builder and state-transition builder to model.builder package


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

Branch: refs/heads/master
Commit: 6119a4467b0fadbab09267a68d15aa470410a182
Parents: 78296ef
Author: zzhang <zzhang5@uci.edu>
Authored: Wed Mar 20 15:14:08 2013 -0700
Committer: zzhang <zzhang5@uci.edu>
Committed: Wed Mar 20 15:14:08 2013 -0700

----------------------------------------------------------------------
 .../helix/webapp/resources/ConfigResource.java     |    6 +-
 .../main/java/org/apache/helix/ConfigAccessor.java |    3 +-
 .../main/java/org/apache/helix/ConfigScope.java    |  149 -----------
 .../java/org/apache/helix/ConfigScopeBuilder.java  |  137 ----------
 .../src/main/java/org/apache/helix/HelixAdmin.java |    7 +-
 .../main/java/org/apache/helix/HelixManager.java   |    2 +-
 .../main/java/org/apache/helix/PropertyKey.java    |    6 +-
 .../helix/controller/GenericHelixController.java   |    6 -
 .../healthcheck/HealthStatsAggregationTask.java    |    4 +-
 .../helix/josql/ClusterJosqlQueryProcessor.java    |    2 +-
 .../org/apache/helix/manager/zk/ZKHelixAdmin.java  |    4 +-
 .../apache/helix/manager/zk/ZKHelixManager.java    |    4 +-
 .../java/org/apache/helix/manager/zk/ZKUtil.java   |    2 +-
 .../helix/messaging/DefaultMessagingService.java   |    4 +-
 .../messaging/handling/HelixTaskExecutor.java      |    9 +-
 .../java/org/apache/helix/model/ConfigScope.java   |  150 +++++++++++
 .../java/org/apache/helix/model/IdealState.java    |   30 --
 .../apache/helix/model/StateModelDefinition.java   |    2 +-
 .../helix/model/builder/AutoModeISBuilder.java     |   50 ++++
 .../model/builder/AutoRebalanceModeISBuilder.java  |   49 ++++
 .../helix/model/builder/ConfigScopeBuilder.java    |  138 ++++++++++
 .../helix/model/builder/CustomModeISBuilder.java   |   66 +++++
 .../helix/model/builder/IdealStateBuilder.java     |  167 ++++++++++++
 .../model/builder/StateTransitionTableBuilder.java |  205 +++++++++++++++
 .../statemachine/StateTransitionTableBuilder.java  |  204 --------------
 .../java/org/apache/helix/tools/ClusterSetup.java  |   11 +-
 .../helix/tools/StateModelConfigGenerator.java     |    2 +-
 .../src/test/java/org/apache/helix/Mocks.java      |   24 +--
 .../java/org/apache/helix/TestConfigAccessor.java  |    7 +-
 .../src/test/java/org/apache/helix/TestHelper.java |    6 +-
 .../org/apache/helix/TestListenerCallback.java     |    2 +-
 .../java/org/apache/helix/TestRoutingTable.java    |    9 +-
 .../test/java/org/apache/helix/ZkUnitTestBase.java |    7 +-
 .../controller/stages/DummyClusterManager.java     |    2 +-
 .../healthcheck/TestAlertActionTriggering.java     |    5 +-
 .../helix/healthcheck/TestAlertFireHistory.java    |    6 +-
 .../apache/helix/integration/TestBatchMessage.java |    2 +-
 .../helix/integration/ZkIntegrationTestBase.java   |    4 +-
 .../org/apache/helix/manager/zk/TestZKUtil.java    |    5 +-
 .../helix/manager/zk/TestZkClusterManager.java     |    5 +-
 .../apache/helix/manager/zk/TestZkHelixAdmin.java  |    4 +-
 .../handling/TestConfigThreadpoolSize.java         |   13 +-
 .../handling/TestResourceThreadpoolSize.java       |    5 +-
 .../helix/model/builder/TestIdealStateBuilder.java |   90 +++++++
 .../helix/participant/MockZKHelixManager.java      |    3 +-
 .../apache/helix/filestore/IntegrationTest.java    |    4 +-
 46 files changed, 971 insertions(+), 651 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConfigResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConfigResource.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConfigResource.java
index 5f828d1..3daf2b9 100644
--- a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConfigResource.java
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConfigResource.java
@@ -24,13 +24,13 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.helix.ConfigScope;
-import org.apache.helix.ConfigScopeBuilder;
 import org.apache.helix.HelixAdmin;
 import org.apache.helix.HelixException;
 import org.apache.helix.ZNRecord;
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
 import org.apache.helix.manager.zk.ZkClient;
+import org.apache.helix.model.ConfigScope;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.builder.ConfigScopeBuilder;
 import org.apache.helix.tools.ClusterSetup;
 import org.apache.helix.webapp.RestAdminApplication;
 import org.apache.log4j.Logger;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java b/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
index fa91521..0734b72 100644
--- a/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
@@ -25,7 +25,8 @@ import java.util.Collections;
 import java.util.List;
 import java.util.TreeMap;
 
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.ConfigScope;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 import org.apache.helix.manager.zk.ZKUtil;
 import org.apache.helix.manager.zk.ZkClient;
 import org.apache.helix.util.StringTemplate;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/ConfigScope.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/ConfigScope.java b/helix-core/src/main/java/org/apache/helix/ConfigScope.java
deleted file mode 100644
index 6ee689c..0000000
--- a/helix-core/src/main/java/org/apache/helix/ConfigScope.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package org.apache.helix;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.helix.util.StringTemplate;
-import org.apache.log4j.Logger;
-
-
-public class ConfigScope
-{
-  public enum ConfigScopeProperty
-  {
-    CLUSTER, PARTICIPANT, RESOURCE, PARTITION, CONSTRAINT;
-  }
-
-  private static Logger LOG = Logger.getLogger(ConfigScope.class);
-
-  private static final List<ConfigScopeProperty> scopePriority =
-      new ArrayList<ConfigScopeProperty>();
-  private static final Map<ConfigScopeProperty, Map<ConfigScopeProperty, ConfigScopeProperty>> scopeTransition =
-      new HashMap<ConfigScopeProperty, Map<ConfigScopeProperty, ConfigScopeProperty>>();
-  private static final StringTemplate template = new StringTemplate();
-  static
-  {
-    // scope priority: CLUSTER > PARTICIPANT > RESOURCE > PARTITION
-    scopePriority.add(ConfigScopeProperty.CLUSTER);
-    scopePriority.add(ConfigScopeProperty.PARTICIPANT);
-    scopePriority.add(ConfigScopeProperty.RESOURCE);
-    scopePriority.add(ConfigScopeProperty.PARTITION);
-
-    // scope transition table to check valid inputs
-    scopeTransition.put(ConfigScopeProperty.CLUSTER,
-                        new HashMap<ConfigScopeProperty, ConfigScopeProperty>());
-    scopeTransition.get(ConfigScopeProperty.CLUSTER).put(ConfigScopeProperty.PARTICIPANT,
-                                                         ConfigScopeProperty.PARTICIPANT);
-    scopeTransition.get(ConfigScopeProperty.CLUSTER).put(ConfigScopeProperty.RESOURCE,
-                                                         ConfigScopeProperty.RESOURCE);
-    scopeTransition.put(ConfigScopeProperty.RESOURCE,
-                        new HashMap<ConfigScopeProperty, ConfigScopeProperty>());
-    scopeTransition.get(ConfigScopeProperty.RESOURCE).put(ConfigScopeProperty.PARTITION,
-                                                          ConfigScopeProperty.PARTITION);
-
-    // string templates to generate znode path/index
-    // @formatter:off
-    template.addEntry(ConfigScopeProperty.CLUSTER,
-                      2,
-                      "/{clusterName}/CONFIGS/CLUSTER/{clusterName}");
-    template.addEntry(ConfigScopeProperty.PARTICIPANT,
-                      2,
-                      "/{clusterName}/CONFIGS/PARTICIPANT/{participantName}");
-    template.addEntry(ConfigScopeProperty.RESOURCE,
-                      2,
-                      "/{clusterName}/CONFIGS/RESOURCE/{resourceName}");
-    template.addEntry(ConfigScopeProperty.PARTITION,
-                      3,
-                      "/{clusterName}/CONFIGS/RESOURCE/{resourceName}|{partitionName}");
-    // @formatter:on
-  }
-
-  private final String _clusterName;
-  private final ConfigScopeProperty _scope;
-  private final String _scopeStr;
-
-  ConfigScope(ConfigScopeBuilder configScopeBuilder)
-  {
-    Map<ConfigScopeProperty, String> scopeMap = configScopeBuilder
-        .getScopeMap();
-    List<String> keys = new ArrayList<String>();
-
-    ConfigScopeProperty curScope = null;
-    for (ConfigScopeProperty scope : scopePriority)
-    {
-      if (scopeMap.containsKey(scope))
-      {
-        if (curScope == null && scope == ConfigScopeProperty.CLUSTER)
-        {
-          keys.add(scopeMap.get(scope));
-          curScope = ConfigScopeProperty.CLUSTER;
-        } else if (curScope == null)
-        {
-          throw new IllegalArgumentException("Missing CLUSTER scope. Can't build scope using " + configScopeBuilder);
-        } else
-        {
-          if (!scopeTransition.containsKey(curScope) || !scopeTransition.get(curScope).containsKey(scope))
-          {
-            throw new IllegalArgumentException("Can't build scope using " + configScopeBuilder);
-          }
-          keys.add(scopeMap.get(scope));
-          curScope = scopeTransition.get(curScope).get(scope);
-        }
-      }
-    }
-
-    if (curScope == ConfigScopeProperty.CLUSTER)
-    {
-      // append one more {clusterName}
-      keys.add(scopeMap.get(ConfigScopeProperty.CLUSTER));
-    }
-
-    String scopeStr = template.instantiate(curScope, keys.toArray(new String[0]));
-
-    _clusterName = keys.get(0);
-    _scopeStr = scopeStr;
-    _scope = curScope;
-  }
-
-  public ConfigScopeProperty getScope()
-  {
-    return _scope;
-  }
-
-  public String getClusterName()
-  {
-    return _clusterName;
-  }
-
-  public String getScopeStr()
-  {
-    return _scopeStr;
-  }
-
-  @Override
-  public String toString()
-  {
-    return super.toString() + ": " + _scopeStr;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/ConfigScopeBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/ConfigScopeBuilder.java b/helix-core/src/main/java/org/apache/helix/ConfigScopeBuilder.java
deleted file mode 100644
index 5f147b7..0000000
--- a/helix-core/src/main/java/org/apache/helix/ConfigScopeBuilder.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.apache.helix;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
-import org.apache.helix.util.StringTemplate;
-import org.apache.log4j.Logger;
-
-
-public class ConfigScopeBuilder
-{
-  private static Logger LOG = Logger.getLogger(ConfigScopeBuilder.class);
-
-  private static StringTemplate template = new StringTemplate();
-  static
-  {
-    // @formatter:off
-    template.addEntry(ConfigScopeProperty.CLUSTER, 1, "CLUSTER={clusterName}");
-    template.addEntry(ConfigScopeProperty.RESOURCE, 2, "CLUSTER={clusterName},RESOURCE={resourceName}");
-    template.addEntry(ConfigScopeProperty.PARTITION, 3, "CLUSTER={clusterName},RESOURCE={resourceName},PARTITION={partitionName}");
-    template.addEntry(ConfigScopeProperty.PARTICIPANT, 2, "CLUSTER={clusterName},PARTICIPANT={participantName}");
-    // @formatter:on
-  }
-
-  private final Map<ConfigScopeProperty, String> _scopeMap;
-
-  public Map<ConfigScopeProperty, String> getScopeMap()
-  {
-    return _scopeMap;
-  }
-
-  public ConfigScopeBuilder()
-  {
-    _scopeMap = new HashMap<ConfigScopeProperty, String>();
-  }
-
-  public ConfigScopeBuilder forCluster(String clusterName)
-  {
-    _scopeMap.put(ConfigScopeProperty.CLUSTER, clusterName);
-    return this;
-  }
-
-  public ConfigScopeBuilder forParticipant(String participantName)
-  {
-    _scopeMap.put(ConfigScopeProperty.PARTICIPANT, participantName);
-    return this;
-  }
-
-  public ConfigScopeBuilder forResource(String resourceName)
-  {
-    _scopeMap.put(ConfigScopeProperty.RESOURCE, resourceName);
-    return this;
-
-  }
-
-  public ConfigScopeBuilder forPartition(String partitionName)
-  {
-    _scopeMap.put(ConfigScopeProperty.PARTITION, partitionName);
-    return this;
-
-  }
-
-  public ConfigScope build()
-  {
-    // TODO: validate the scopes map
-    return new ConfigScope(this);
-  }
-
-  public ConfigScope build(ConfigScopeProperty scope, String clusterName, String... scopeKeys)
-  {
-    if (scopeKeys == null)
-    {
-      scopeKeys = new String[]{};
-    }
-
-    String[] args = new String[1 + scopeKeys.length];
-    args[0] = clusterName;
-    System.arraycopy(scopeKeys, 0, args, 1, scopeKeys.length);
-    String scopePairs = template.instantiate(scope, args);
-
-    return build(scopePairs);
-  }
-
-  public ConfigScope build(String scopePairs)
-  {
-    String[] scopes = scopePairs.split("[\\s,]+");
-    for (String scope : scopes)
-    {
-      try
-      {
-        int idx = scope.indexOf('=');
-        if (idx == -1)
-        {
-          LOG.error("Invalid scope string: " + scope);
-          continue;
-        }
-
-        String scopeStr = scope.substring(0, idx);
-        String value = scope.substring(idx + 1);
-        ConfigScopeProperty scopeProperty = ConfigScopeProperty.valueOf(scopeStr);
-        _scopeMap.put(scopeProperty, value);
-      } catch (Exception e)
-      {
-        LOG.error("Invalid scope string: " + scope);
-        continue;
-      }
-    }
-
-    return build();
-  }
-
-  @Override
-  public String toString()
-  {
-    return _scopeMap.toString();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixAdmin.java b/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
index 6cece6e..903516d 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
@@ -24,11 +24,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
-import org.apache.helix.model.ExternalView;
-import org.apache.helix.model.IdealState;
-import org.apache.helix.model.InstanceConfig;
-import org.apache.helix.model.StateModelDefinition;
+import org.apache.helix.model.*;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 
 
 public interface HelixAdmin

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/HelixManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixManager.java b/helix-core/src/main/java/org/apache/helix/HelixManager.java
index 7c91cd6..46e9ed9 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixManager.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixManager.java
@@ -21,7 +21,7 @@ package org.apache.helix;
 
 import java.util.List;
 
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 import org.apache.helix.controller.GenericHelixController;
 import org.apache.helix.healthcheck.ParticipantHealthReportCollector;
 import org.apache.helix.participant.HelixStateMachineEngine;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/PropertyKey.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/PropertyKey.java b/helix-core/src/main/java/org/apache/helix/PropertyKey.java
index 96cf979..55face9 100644
--- a/helix-core/src/main/java/org/apache/helix/PropertyKey.java
+++ b/helix-core/src/main/java/org/apache/helix/PropertyKey.java
@@ -42,12 +42,8 @@ import static org.apache.helix.PropertyType.STATUSUPDATES;
 import static org.apache.helix.PropertyType.STATUSUPDATES_CONTROLLER;
 
 import java.util.Arrays;
-import java.util.concurrent.TimeUnit;
 
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
-import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.manager.zk.ZkClient;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 import org.apache.helix.model.AlertHistory;
 import org.apache.helix.model.AlertStatus;
 import org.apache.helix.model.Alerts;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java b/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
index 914f964..9a414cd 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
@@ -24,16 +24,11 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.Timer;
 import java.util.TimerTask;
-import java.util.concurrent.ConcurrentSkipListSet;
 import java.util.concurrent.atomic.AtomicReference;
 
-import org.apache.helix.ConfigAccessor;
 import org.apache.helix.ConfigChangeListener;
-import org.apache.helix.ConfigScope;
-import org.apache.helix.ConfigScopeBuilder;
 import org.apache.helix.ControllerChangeListener;
 import org.apache.helix.CurrentStateChangeListener;
 import org.apache.helix.ExternalViewChangeListener;
@@ -69,7 +64,6 @@ import org.apache.helix.model.LiveInstance;
 import org.apache.helix.model.Message;
 import org.apache.helix.model.PauseSignal;
 import org.apache.helix.monitoring.mbeans.ClusterStatusMonitor;
-import org.apache.helix.monitoring.mbeans.MessageQueueMonitor;
 import org.apache.log4j.Logger;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/healthcheck/HealthStatsAggregationTask.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/healthcheck/HealthStatsAggregationTask.java b/helix-core/src/main/java/org/apache/helix/healthcheck/HealthStatsAggregationTask.java
index 785b190..4b5fe92 100644
--- a/helix-core/src/main/java/org/apache/helix/healthcheck/HealthStatsAggregationTask.java
+++ b/helix-core/src/main/java/org/apache/helix/healthcheck/HealthStatsAggregationTask.java
@@ -26,8 +26,8 @@ import java.util.Random;
 import java.util.Timer;
 
 import org.apache.helix.ConfigAccessor;
-import org.apache.helix.ConfigScope;
-import org.apache.helix.ConfigScopeBuilder;
+import org.apache.helix.model.ConfigScope;
+import org.apache.helix.model.builder.ConfigScopeBuilder;
 import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.HelixManager;
 import org.apache.helix.HelixTimerTask;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/josql/ClusterJosqlQueryProcessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/josql/ClusterJosqlQueryProcessor.java b/helix-core/src/main/java/org/apache/helix/josql/ClusterJosqlQueryProcessor.java
index c1ed70c..1b54d1a 100644
--- a/helix-core/src/main/java/org/apache/helix/josql/ClusterJosqlQueryProcessor.java
+++ b/helix-core/src/main/java/org/apache/helix/josql/ClusterJosqlQueryProcessor.java
@@ -30,7 +30,7 @@ import org.apache.helix.HelixManager;
 import org.apache.helix.HelixProperty;
 import org.apache.helix.PropertyType;
 import org.apache.helix.ZNRecord;
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.model.LiveInstance.LiveInstanceProperty;
 import org.apache.log4j.Logger;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/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 73e6045..3dee34e 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
@@ -40,7 +40,7 @@ import org.I0Itec.zkclient.DataUpdater;
 import org.I0Itec.zkclient.exception.ZkNoNodeException;
 import org.apache.helix.AccessOption;
 import org.apache.helix.ConfigAccessor;
-import org.apache.helix.ConfigScope;
+import org.apache.helix.model.ConfigScope;
 import org.apache.helix.HelixAdmin;
 import org.apache.helix.HelixConstants;
 import org.apache.helix.HelixDataAccessor;
@@ -49,7 +49,7 @@ import org.apache.helix.PropertyKey;
 import org.apache.helix.PropertyPathConfig;
 import org.apache.helix.PropertyType;
 import org.apache.helix.ZNRecord;
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.alerts.AlertsHolder;
 import org.apache.helix.alerts.StatsHolder;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
index e4cf348..86af1cf 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
@@ -24,7 +24,6 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Timer;
@@ -35,7 +34,7 @@ import org.apache.helix.BaseDataAccessor;
 import org.apache.helix.ClusterMessagingService;
 import org.apache.helix.ConfigAccessor;
 import org.apache.helix.ConfigChangeListener;
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 import org.apache.helix.ControllerChangeListener;
 import org.apache.helix.CurrentStateChangeListener;
 import org.apache.helix.ExternalViewChangeListener;
@@ -73,7 +72,6 @@ import org.apache.helix.participant.DistClusterControllerElection;
 import org.apache.helix.participant.HelixStateMachineEngine;
 import org.apache.helix.participant.StateMachineEngine;
 import org.apache.helix.participant.statemachine.ScheduledTaskStateModelFactory;
-import org.apache.helix.store.ZNRecordJsonSerializer;
 import org.apache.helix.store.zk.ZkHelixPropertyStore;
 import org.apache.helix.tools.PropertiesReader;
 import org.apache.log4j.Logger;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java
index 5903d04..85458f0 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKUtil.java
@@ -27,7 +27,7 @@ import org.I0Itec.zkclient.DataUpdater;
 import org.apache.helix.PropertyPathConfig;
 import org.apache.helix.PropertyType;
 import org.apache.helix.ZNRecord;
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.data.Stat;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/messaging/DefaultMessagingService.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/messaging/DefaultMessagingService.java b/helix-core/src/main/java/org/apache/helix/messaging/DefaultMessagingService.java
index 558c91c..64db02e 100644
--- a/helix-core/src/main/java/org/apache/helix/messaging/DefaultMessagingService.java
+++ b/helix-core/src/main/java/org/apache/helix/messaging/DefaultMessagingService.java
@@ -28,8 +28,8 @@ import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.helix.ClusterMessagingService;
 import org.apache.helix.ConfigAccessor;
-import org.apache.helix.ConfigScope;
-import org.apache.helix.ConfigScopeBuilder;
+import org.apache.helix.model.ConfigScope;
+import org.apache.helix.model.builder.ConfigScopeBuilder;
 import org.apache.helix.Criteria;
 import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.HelixManager;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java b/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
index 4220d22..c67fc2a 100644
--- a/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
+++ b/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
@@ -21,27 +21,22 @@ package org.apache.helix.messaging.handling;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.Date;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.Timer;
 import java.util.TimerTask;
-import java.util.TreeMap;
-import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.helix.ConfigAccessor;
-import org.apache.helix.ConfigScope;
-import org.apache.helix.ConfigScopeBuilder;
+import org.apache.helix.model.ConfigScope;
+import org.apache.helix.model.builder.ConfigScopeBuilder;
 import org.apache.helix.HelixConstants;
 import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.HelixException;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/model/ConfigScope.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/ConfigScope.java b/helix-core/src/main/java/org/apache/helix/model/ConfigScope.java
new file mode 100644
index 0000000..87c7c34
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/model/ConfigScope.java
@@ -0,0 +1,150 @@
+package org.apache.helix.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.helix.model.builder.ConfigScopeBuilder;
+import org.apache.helix.util.StringTemplate;
+import org.apache.log4j.Logger;
+
+
+public class ConfigScope
+{
+  public enum ConfigScopeProperty
+  {
+    CLUSTER, PARTICIPANT, RESOURCE, PARTITION, CONSTRAINT;
+  }
+
+  private static Logger LOG = Logger.getLogger(ConfigScope.class);
+
+  private static final List<ConfigScopeProperty> scopePriority =
+      new ArrayList<ConfigScopeProperty>();
+  private static final Map<ConfigScopeProperty, Map<ConfigScopeProperty, ConfigScopeProperty>> scopeTransition =
+      new HashMap<ConfigScopeProperty, Map<ConfigScopeProperty, ConfigScopeProperty>>();
+  private static final StringTemplate template = new StringTemplate();
+  static
+  {
+    // scope priority: CLUSTER > PARTICIPANT > RESOURCE > PARTITION
+    scopePriority.add(ConfigScopeProperty.CLUSTER);
+    scopePriority.add(ConfigScopeProperty.PARTICIPANT);
+    scopePriority.add(ConfigScopeProperty.RESOURCE);
+    scopePriority.add(ConfigScopeProperty.PARTITION);
+
+    // scope transition table to check valid inputs
+    scopeTransition.put(ConfigScopeProperty.CLUSTER,
+                        new HashMap<ConfigScopeProperty, ConfigScopeProperty>());
+    scopeTransition.get(ConfigScopeProperty.CLUSTER).put(ConfigScopeProperty.PARTICIPANT,
+                                                         ConfigScopeProperty.PARTICIPANT);
+    scopeTransition.get(ConfigScopeProperty.CLUSTER).put(ConfigScopeProperty.RESOURCE,
+                                                         ConfigScopeProperty.RESOURCE);
+    scopeTransition.put(ConfigScopeProperty.RESOURCE,
+                        new HashMap<ConfigScopeProperty, ConfigScopeProperty>());
+    scopeTransition.get(ConfigScopeProperty.RESOURCE).put(ConfigScopeProperty.PARTITION,
+                                                          ConfigScopeProperty.PARTITION);
+
+    // string templates to generate znode path/index
+    // @formatter:off
+    template.addEntry(ConfigScopeProperty.CLUSTER,
+                      2,
+                      "/{clusterName}/CONFIGS/CLUSTER/{clusterName}");
+    template.addEntry(ConfigScopeProperty.PARTICIPANT,
+                      2,
+                      "/{clusterName}/CONFIGS/PARTICIPANT/{participantName}");
+    template.addEntry(ConfigScopeProperty.RESOURCE,
+                      2,
+                      "/{clusterName}/CONFIGS/RESOURCE/{resourceName}");
+    template.addEntry(ConfigScopeProperty.PARTITION,
+                      3,
+                      "/{clusterName}/CONFIGS/RESOURCE/{resourceName}|{partitionName}");
+    // @formatter:on
+  }
+
+  private final String _clusterName;
+  private final ConfigScopeProperty _scope;
+  private final String _scopeStr;
+
+  public ConfigScope(ConfigScopeBuilder configScopeBuilder)
+  {
+    Map<ConfigScopeProperty, String> scopeMap = configScopeBuilder
+        .getScopeMap();
+    List<String> keys = new ArrayList<String>();
+
+    ConfigScopeProperty curScope = null;
+    for (ConfigScopeProperty scope : scopePriority)
+    {
+      if (scopeMap.containsKey(scope))
+      {
+        if (curScope == null && scope == ConfigScopeProperty.CLUSTER)
+        {
+          keys.add(scopeMap.get(scope));
+          curScope = ConfigScopeProperty.CLUSTER;
+        } else if (curScope == null)
+        {
+          throw new IllegalArgumentException("Missing CLUSTER scope. Can't build scope using " + configScopeBuilder);
+        } else
+        {
+          if (!scopeTransition.containsKey(curScope) || !scopeTransition.get(curScope).containsKey(scope))
+          {
+            throw new IllegalArgumentException("Can't build scope using " + configScopeBuilder);
+          }
+          keys.add(scopeMap.get(scope));
+          curScope = scopeTransition.get(curScope).get(scope);
+        }
+      }
+    }
+
+    if (curScope == ConfigScopeProperty.CLUSTER)
+    {
+      // append one more {clusterName}
+      keys.add(scopeMap.get(ConfigScopeProperty.CLUSTER));
+    }
+
+    String scopeStr = template.instantiate(curScope, keys.toArray(new String[0]));
+
+    _clusterName = keys.get(0);
+    _scopeStr = scopeStr;
+    _scope = curScope;
+  }
+
+  public ConfigScopeProperty getScope()
+  {
+    return _scope;
+  }
+
+  public String getClusterName()
+  {
+    return _clusterName;
+  }
+
+  public String getScopeStr()
+  {
+    return _scopeStr;
+  }
+
+  @Override
+  public String toString()
+  {
+    return super.toString() + ": " + _scopeStr;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/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 a29ffe8..a2d2dc0 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
@@ -357,34 +357,4 @@ public class IdealState extends HelixProperty
     return true;
   }
 
-  public static class CustomBuilder
-  {
-    public void set(String partitionName, String instanceName, String state)
-    {
-
-    }
-
-  }
-
-  public static class AutoModeBuilder
-  {
-    public void setNumPartitions(int partitions)
-    {
-      
-    }
-
-    public void replicas(int replicas)
-    {
-
-    }
-
-  }
-
-  public static class SemiAutoBuilder
-  {
-    public void set(String partitionName, String... instancePreferenceList)
-    {
-
-    }
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/model/StateModelDefinition.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/StateModelDefinition.java b/helix-core/src/main/java/org/apache/helix/model/StateModelDefinition.java
index eea9da2..c61d4ca 100644
--- a/helix-core/src/main/java/org/apache/helix/model/StateModelDefinition.java
+++ b/helix-core/src/main/java/org/apache/helix/model/StateModelDefinition.java
@@ -28,7 +28,7 @@ import java.util.Map;
 
 import org.apache.helix.HelixProperty;
 import org.apache.helix.ZNRecord;
-import org.apache.helix.participant.statemachine.StateTransitionTableBuilder;
+import org.apache.helix.model.builder.StateTransitionTableBuilder;
 import org.apache.log4j.Logger;
 
 /**

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

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

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/model/builder/ConfigScopeBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/builder/ConfigScopeBuilder.java b/helix-core/src/main/java/org/apache/helix/model/builder/ConfigScopeBuilder.java
new file mode 100644
index 0000000..5157465
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/model/builder/ConfigScopeBuilder.java
@@ -0,0 +1,138 @@
+package org.apache.helix.model.builder;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.helix.model.ConfigScope;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.util.StringTemplate;
+import org.apache.log4j.Logger;
+
+
+public class ConfigScopeBuilder
+{
+  private static Logger LOG = Logger.getLogger(ConfigScopeBuilder.class);
+
+  private static StringTemplate template = new StringTemplate();
+  static
+  {
+    // @formatter:off
+    template.addEntry(ConfigScopeProperty.CLUSTER, 1, "CLUSTER={clusterName}");
+    template.addEntry(ConfigScopeProperty.RESOURCE, 2, "CLUSTER={clusterName},RESOURCE={resourceName}");
+    template.addEntry(ConfigScopeProperty.PARTITION, 3, "CLUSTER={clusterName},RESOURCE={resourceName},PARTITION={partitionName}");
+    template.addEntry(ConfigScopeProperty.PARTICIPANT, 2, "CLUSTER={clusterName},PARTICIPANT={participantName}");
+    // @formatter:on
+  }
+
+  private final Map<ConfigScopeProperty, String> _scopeMap;
+
+  public Map<ConfigScopeProperty, String> getScopeMap()
+  {
+    return _scopeMap;
+  }
+
+  public ConfigScopeBuilder()
+  {
+    _scopeMap = new HashMap<ConfigScopeProperty, String>();
+  }
+
+  public ConfigScopeBuilder forCluster(String clusterName)
+  {
+    _scopeMap.put(ConfigScopeProperty.CLUSTER, clusterName);
+    return this;
+  }
+
+  public ConfigScopeBuilder forParticipant(String participantName)
+  {
+    _scopeMap.put(ConfigScopeProperty.PARTICIPANT, participantName);
+    return this;
+  }
+
+  public ConfigScopeBuilder forResource(String resourceName)
+  {
+    _scopeMap.put(ConfigScopeProperty.RESOURCE, resourceName);
+    return this;
+
+  }
+
+  public ConfigScopeBuilder forPartition(String partitionName)
+  {
+    _scopeMap.put(ConfigScopeProperty.PARTITION, partitionName);
+    return this;
+
+  }
+
+  public ConfigScope build()
+  {
+    // TODO: validate the scopes map
+    return new ConfigScope(this);
+  }
+
+  public ConfigScope build(ConfigScopeProperty scope, String clusterName, String... scopeKeys)
+  {
+    if (scopeKeys == null)
+    {
+      scopeKeys = new String[]{};
+    }
+
+    String[] args = new String[1 + scopeKeys.length];
+    args[0] = clusterName;
+    System.arraycopy(scopeKeys, 0, args, 1, scopeKeys.length);
+    String scopePairs = template.instantiate(scope, args);
+
+    return build(scopePairs);
+  }
+
+  public ConfigScope build(String scopePairs)
+  {
+    String[] scopes = scopePairs.split("[\\s,]+");
+    for (String scope : scopes)
+    {
+      try
+      {
+        int idx = scope.indexOf('=');
+        if (idx == -1)
+        {
+          LOG.error("Invalid scope string: " + scope);
+          continue;
+        }
+
+        String scopeStr = scope.substring(0, idx);
+        String value = scope.substring(idx + 1);
+        ConfigScopeProperty scopeProperty = ConfigScopeProperty.valueOf(scopeStr);
+        _scopeMap.put(scopeProperty, value);
+      } catch (Exception e)
+      {
+        LOG.error("Invalid scope string: " + scope);
+        continue;
+      }
+    }
+
+    return build();
+  }
+
+  @Override
+  public String toString()
+  {
+    return _scopeMap.toString();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/model/builder/CustomModeISBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/builder/CustomModeISBuilder.java b/helix-core/src/main/java/org/apache/helix/model/builder/CustomModeISBuilder.java
new file mode 100644
index 0000000..e75b7ac
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/model/builder/CustomModeISBuilder.java
@@ -0,0 +1,66 @@
+package org.apache.helix.model.builder;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.helix.model.IdealState;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+public class CustomModeISBuilder extends IdealStateBuilder {
+
+    public CustomModeISBuilder(String resourceName)
+    {
+        super(resourceName);
+        setMode(IdealState.IdealStateModeProperty.CUSTOMIZED);
+    }
+
+    /**
+     * Add a sub-resource
+     *
+     * @param partitionName
+     */
+    public void add(String partitionName)
+    {
+        if (_record.getMapField(partitionName) == null)
+        {
+            _record.setMapField(partitionName, new TreeMap<String, String>());
+        }
+    }
+
+    /**
+     * add an instance->state assignment
+     *
+     * @param partitionName
+     * @param instanceName
+     * @param state
+     * @return
+     */
+    public CustomModeISBuilder assignInstanceAndState(String partitionName, String instanceName,
+                                       String state)
+    {
+        add(partitionName);
+        Map<String, String> partitionToInstanceStateMapping = _record
+                .getMapField(partitionName);
+        partitionToInstanceStateMapping.put(instanceName, state);
+        return this;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/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
new file mode 100644
index 0000000..e880833
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/model/builder/IdealStateBuilder.java
@@ -0,0 +1,167 @@
+package org.apache.helix.model.builder;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.helix.HelixConstants;
+import org.apache.helix.HelixException;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.model.IdealState;
+
+public abstract class IdealStateBuilder {
+    /**
+     * Resource name e.g. myDB,
+     */
+    private String resourceName;
+    /**
+     * Number of partitions/subresources
+     */
+    private int numPartitions;
+    /**
+     * Number of replicas for each partition
+     */
+    private int numReplica;
+    /**
+     * State model that is applicable for this resource
+     */
+    private String stateModel;
+    /**
+     * The state model factory implementation in the participant. Allows
+     * participants to plugin resource specific implementation, by default Helix
+     * uses the implementation specified per state model.<br/>
+     * This is optional
+     */
+    private String stateModelFactoryName = HelixConstants.DEFAULT_STATE_MODEL_FACTORY;
+    /**
+     * Helix Execution mode/strategies. AUTO_REBALANCE, AUTO, CUSTOM
+     */
+    protected IdealState.IdealStateModeProperty mode;
+    /**
+     * A constraint that limits the maximum number of partitions per Node.
+     */
+    private int maxPartitionsPerNode;
+    /**
+     * Allocate the resource to nodes that are tagged with a specific "nodeGroup"
+     * name. By default a resource will be allocated to all nodes registered to
+     * the cluster.
+     */
+    private String nodeGroup = "*";
+
+    protected ZNRecord _record;
+
+    /**
+     *
+     * @param resourceName
+     */
+    public IdealStateBuilder(String resourceName)
+    {
+        this.resourceName = resourceName;
+        _record = new ZNRecord(resourceName);
+    }
+
+    /**
+     *
+     * @param numReplica
+     */
+    public IdealStateBuilder setNumReplica(int numReplica)
+    {
+        this.numReplica = numReplica;
+        return this;
+    }
+
+    /**
+     *
+     * @param numPartitions
+     */
+    public IdealStateBuilder setNumPartitions(int numPartitions)
+    {
+        this.numPartitions = numPartitions;
+        return this;
+    }
+
+    /**
+     *
+     * @param stateModel
+     */
+    public IdealStateBuilder setStateModel(String stateModel)
+    {
+        this.stateModel = stateModel;
+        return this;
+    }
+
+    /**
+     *
+     * @param stateModelFactoryName
+     */
+    public IdealStateBuilder setStateModelFactoryName(String stateModelFactoryName)
+    {
+        this.stateModelFactoryName = stateModelFactoryName;
+        return this;
+    }
+
+    /**
+     *
+     * @param maxPartitionsPerNode
+     */
+    public IdealStateBuilder setMaxPartitionsPerNode(int maxPartitionsPerNode)
+    {
+        this.maxPartitionsPerNode = maxPartitionsPerNode;
+        return this;
+    }
+
+    /**
+     *
+     * @param nodeGroup
+     */
+    public IdealStateBuilder setNodeGroup(String nodeGroup)
+    {
+        this.nodeGroup = nodeGroup;
+        return this;
+    }
+
+    /**
+     * sub-class should implement this to set ideal-state mode
+     *
+     * @return
+     */
+    public IdealStateBuilder setMode(IdealState.IdealStateModeProperty mode) {
+        this.mode = mode;
+        return this;
+    }
+
+    /**
+     *
+     * @return
+     */
+    public IdealState build()
+    {
+        IdealState idealstate = new IdealState(_record);
+        idealstate.setNumPartitions(numPartitions);
+        idealstate.setMaxPartitionsPerInstance(maxPartitionsPerNode);
+        idealstate.setStateModelDefRef(stateModel);
+        idealstate.setStateModelFactoryName(stateModelFactoryName);
+        idealstate.setIdealStateMode(mode.toString());
+
+        if (!idealstate.isValid()) {
+            throw new HelixException("invalid ideal-state: " + idealstate);
+        }
+        return idealstate;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/model/builder/StateTransitionTableBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/builder/StateTransitionTableBuilder.java b/helix-core/src/main/java/org/apache/helix/model/builder/StateTransitionTableBuilder.java
new file mode 100644
index 0000000..9468eb4
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/model/builder/StateTransitionTableBuilder.java
@@ -0,0 +1,205 @@
+package org.apache.helix.model.builder;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.helix.model.Transition;
+
+public class StateTransitionTableBuilder
+{
+  // for convenient get path value, in which non-exist means MAX
+  static int getPathVal(Map<String, Map<String, Integer>> path,
+      String fromState, String toState)
+  {
+    if (!path.containsKey(fromState))
+    {
+      return Integer.MAX_VALUE;
+    }
+
+    if (!(path.get(fromState).containsKey(toState)))
+    {
+      return Integer.MAX_VALUE;
+    }
+
+    return path.get(fromState).get(toState);
+  }
+
+  static void setPathVal(Map<String, Map<String, Integer>> path,
+      String fromState, String toState, int val)
+  {
+    if (!path.containsKey(fromState))
+    {
+      path.put(fromState, new HashMap<String, Integer>());
+    }
+
+    path.get(fromState).put(toState, val);
+  }
+
+  static void setNext(Map<String, Map<String, String>> next, String fromState,
+      String toState, String nextState)
+  {
+    if (!next.containsKey(fromState))
+    {
+      next.put(fromState, new HashMap<String, String>());
+    }
+
+    next.get(fromState).put(toState, nextState);
+
+  }
+
+  /**
+   * auxiliary method to get next state based on next map
+   * 
+   * @param next
+   * @param fromState
+   * @param toState
+   * @return nextState or null if doesn't exist a path
+   */
+  public static String getNext(Map<String, Map<String, String>> next,
+      String fromState, String toState)
+  {
+    if (!next.containsKey(fromState))
+    {
+      // no path
+      return null;
+    }
+
+    return next.get(fromState).get(toState);
+  }
+
+  // debug
+  static void printPath(List<String> states,
+      Map<String, Map<String, String>> next)
+  {
+    for (String fromState : states)
+    {
+      for (String toState : states)
+      {
+        if (toState.equals(fromState))
+        {
+          // not print self-loop
+          continue;
+        }
+
+        System.out.print(fromState);
+        String nextState = getNext(next, fromState, toState);
+        while (nextState != null && !nextState.equals(toState))
+        {
+          System.out.print("->" + nextState);
+          nextState = getNext(next, nextState, toState);
+        }
+
+        if (nextState == null)
+        {
+          // no path between fromState -> toState
+          System.out.println("->null" + toState + " (no path avaliable)");
+        } else
+        {
+          System.out.println("->" + toState);
+        }
+      }
+    }
+  }
+
+  /**
+   * Uses floyd-warshall algorithm, shortest distance for all pair of nodes
+   * Allows one to lookup nextState given fromState,toState  <br/>
+   * map.get(fromState).get(toState) --> nextState
+   * @param states
+   * @param transitions
+   * @return next map
+   */
+  public Map<String, Map<String, String>> buildTransitionTable(List<String> states,
+      List<Transition> transitions)
+  {
+    // path distance value
+    Map<String, Map<String, Integer>> path = new HashMap<String, Map<String, Integer>>();
+
+    // next state
+    Map<String, Map<String, String>> next = new HashMap<String, Map<String, String>>();
+
+    // init path and next
+    for (String state : states)
+    {
+      setPathVal(path, state, state, 0);
+      setNext(next, state, state, state);
+    }
+
+    for (Transition transition : transitions)
+    {
+      String fromState = transition.getFromState();
+      String toState = transition.getToState();
+      setPathVal(path, fromState, toState, 1);
+      setNext(next, fromState, toState, toState);
+    }
+
+    // iterate
+    for (String intermediateState : states)
+    {
+      for (String fromState : states)
+      {
+        for (String toState : states)
+        {
+          int pathVal1 = getPathVal(path, fromState, intermediateState);
+          int pathVal2 = getPathVal(path, intermediateState, toState);
+          int pathValCur = getPathVal(path, fromState, toState);
+
+          // should not overflow
+          if (pathVal1 < Integer.MAX_VALUE && pathVal2 < Integer.MAX_VALUE
+              && (pathVal1 + pathVal2) < pathValCur)
+          {
+            setPathVal(path, fromState, toState, pathVal1 + pathVal2);
+            setNext(next, fromState, toState, getNext(next, fromState, intermediateState));
+          }
+        }
+      }
+    }
+    return next;
+  }
+
+  // TODO move this to test
+  public static void main(String[] args)
+  {
+    List<String> states = new ArrayList<String>();
+    //[MASTER, SLAVE, DROPPED, OFFLINE]
+    //[SLAVE-OFFLINE, OFFLINE-SLAVE, SLAVE-MASTER, OFFLINE-DROPPED, MASTER-SLAVE]
+    states.add("MASTER");
+    states.add("SLAVE");
+    states.add("DROPPED");
+    states.add("OFFLINE");
+
+
+    List<Transition> transitions = new ArrayList<Transition>();
+    transitions.add(new Transition("SLAVE", "OFFLINE"));
+    transitions.add(new Transition("OFFLINE", "SLAVE"));
+    transitions.add(new Transition("SLAVE", "MASTER"));
+    transitions.add(new Transition("OFFLINE", "DROPPED"));
+    transitions.add(new Transition("MASTER", "SLAVE"));
+
+    StateTransitionTableBuilder builder = new StateTransitionTableBuilder();
+    Map<String, Map<String, String>> next = builder.buildTransitionTable(states, transitions);
+    System.out.println(next);
+    printPath(states, next);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/participant/statemachine/StateTransitionTableBuilder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/participant/statemachine/StateTransitionTableBuilder.java b/helix-core/src/main/java/org/apache/helix/participant/statemachine/StateTransitionTableBuilder.java
deleted file mode 100644
index 0d0e9cd..0000000
--- a/helix-core/src/main/java/org/apache/helix/participant/statemachine/StateTransitionTableBuilder.java
+++ /dev/null
@@ -1,204 +0,0 @@
-package org.apache.helix.participant.statemachine;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.helix.model.Transition;
-
-public class StateTransitionTableBuilder
-{
-  // for convenient get path value, in which non-exist means MAX
-  static int getPathVal(Map<String, Map<String, Integer>> path,
-      String fromState, String toState)
-  {
-    if (!path.containsKey(fromState))
-    {
-      return Integer.MAX_VALUE;
-    }
-
-    if (!(path.get(fromState).containsKey(toState)))
-    {
-      return Integer.MAX_VALUE;
-    }
-
-    return path.get(fromState).get(toState);
-  }
-
-  static void setPathVal(Map<String, Map<String, Integer>> path,
-      String fromState, String toState, int val)
-  {
-    if (!path.containsKey(fromState))
-    {
-      path.put(fromState, new HashMap<String, Integer>());
-    }
-
-    path.get(fromState).put(toState, val);
-  }
-
-  static void setNext(Map<String, Map<String, String>> next, String fromState,
-      String toState, String nextState)
-  {
-    if (!next.containsKey(fromState))
-    {
-      next.put(fromState, new HashMap<String, String>());
-    }
-
-    next.get(fromState).put(toState, nextState);
-
-  }
-
-  /**
-   * auxiliary method to get next state based on next map
-   * 
-   * @param next
-   * @param fromState
-   * @param toState
-   * @return nextState or null if doesn't exist a path
-   */
-  public static String getNext(Map<String, Map<String, String>> next,
-      String fromState, String toState)
-  {
-    if (!next.containsKey(fromState))
-    {
-      // no path
-      return null;
-    }
-
-    return next.get(fromState).get(toState);
-  }
-
-  // debug
-  static void printPath(List<String> states,
-      Map<String, Map<String, String>> next)
-  {
-    for (String fromState : states)
-    {
-      for (String toState : states)
-      {
-        if (toState.equals(fromState))
-        {
-          // not print self-loop
-          continue;
-        }
-
-        System.out.print(fromState);
-        String nextState = getNext(next, fromState, toState);
-        while (nextState != null && !nextState.equals(toState))
-        {
-          System.out.print("->" + nextState);
-          nextState = getNext(next, nextState, toState);
-        }
-
-        if (nextState == null)
-        {
-          // no path between fromState -> toState
-          System.out.println("->null" + toState + " (no path avaliable)");
-        } else
-        {
-          System.out.println("->" + toState);
-        }
-      }
-    }
-  }
-
-  /**
-   * Uses floyd-warshall algorithm, shortest distance for all pair of nodes
-   * Allows one to lookup nextState given fromState,toState  <br/>
-   * map.get(fromState).get(toState) --> nextState
-   * @param states
-   * @param transitions
-   * @return next map
-   */
-  public Map<String, Map<String, String>> buildTransitionTable(List<String> states,
-      List<Transition> transitions)
-  {
-    // path distance value
-    Map<String, Map<String, Integer>> path = new HashMap<String, Map<String, Integer>>();
-
-    // next state
-    Map<String, Map<String, String>> next = new HashMap<String, Map<String, String>>();
-
-    // init path and next
-    for (String state : states)
-    {
-      setPathVal(path, state, state, 0);
-      setNext(next, state, state, state);
-    }
-
-    for (Transition transition : transitions)
-    {
-      String fromState = transition.getFromState();
-      String toState = transition.getToState();
-      setPathVal(path, fromState, toState, 1);
-      setNext(next, fromState, toState, toState);
-    }
-
-    // iterate
-    for (String intermediateState : states)
-    {
-      for (String fromState : states)
-      {
-        for (String toState : states)
-        {
-          int pathVal1 = getPathVal(path, fromState, intermediateState);
-          int pathVal2 = getPathVal(path, intermediateState, toState);
-          int pathValCur = getPathVal(path, fromState, toState);
-
-          // should not overflow
-          if (pathVal1 < Integer.MAX_VALUE && pathVal2 < Integer.MAX_VALUE
-              && (pathVal1 + pathVal2) < pathValCur)
-          {
-            setPathVal(path, fromState, toState, pathVal1 + pathVal2);
-            setNext(next, fromState, toState, getNext(next, fromState, intermediateState));
-          }
-        }
-      }
-    }
-    return next;
-  }
-
-  public static void main(String[] args)
-  {
-    List<String> states = new ArrayList<String>();
-    //[MASTER, SLAVE, DROPPED, OFFLINE]
-    //[SLAVE-OFFLINE, OFFLINE-SLAVE, SLAVE-MASTER, OFFLINE-DROPPED, MASTER-SLAVE]
-    states.add("MASTER");
-    states.add("SLAVE");
-    states.add("DROPPED");
-    states.add("OFFLINE");
-
-
-    List<Transition> transitions = new ArrayList<Transition>();
-    transitions.add(new Transition("SLAVE", "OFFLINE"));
-    transitions.add(new Transition("OFFLINE", "SLAVE"));
-    transitions.add(new Transition("SLAVE", "MASTER"));
-    transitions.add(new Transition("OFFLINE", "DROPPED"));
-    transitions.add(new Transition("MASTER", "SLAVE"));
-
-    StateTransitionTableBuilder builder = new StateTransitionTableBuilder();
-    Map<String, Map<String, String>> next = builder.buildTransitionTable(states, transitions);
-    System.out.println(next);
-    printPath(states, next);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/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 549f68d..b4dec19 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
@@ -23,10 +23,7 @@ import java.io.DataInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -42,8 +39,8 @@ import org.apache.commons.cli.OptionBuilder;
 import org.apache.commons.cli.OptionGroup;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
-import org.apache.helix.ConfigScope;
-import org.apache.helix.ConfigScopeBuilder;
+import org.apache.helix.model.ConfigScope;
+import org.apache.helix.model.builder.ConfigScopeBuilder;
 import org.apache.helix.HelixAdmin;
 import org.apache.helix.HelixException;
 import org.apache.helix.ZNRecord;
@@ -546,9 +543,9 @@ public class ClusterSetup
   /**
    * setConfig
    * 
-   * @param scopeStr
+   * @param scopesStr
    *          : scope=value, ... where scope=CLUSTER, RESOURCE, PARTICIPANT, PARTITION
-   * @param properitesStr
+   * @param propertiesStr
    *          : key=value, ... which represents a Map<String, String>
    */
   public void setConfig(String scopesStr, String propertiesStr)

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/main/java/org/apache/helix/tools/StateModelConfigGenerator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/tools/StateModelConfigGenerator.java b/helix-core/src/main/java/org/apache/helix/tools/StateModelConfigGenerator.java
index 02b843f..527748f 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/StateModelConfigGenerator.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/StateModelConfigGenerator.java
@@ -29,7 +29,7 @@ import org.apache.helix.manager.zk.DefaultSchedulerMessageHandlerFactory;
 import org.apache.helix.manager.zk.ZNRecordSerializer;
 import org.apache.helix.model.Transition;
 import org.apache.helix.model.StateModelDefinition.StateModelDefinitionProperty;
-import org.apache.helix.participant.statemachine.StateTransitionTableBuilder;
+import org.apache.helix.model.builder.StateTransitionTableBuilder;
 
 
 public class StateModelConfigGenerator

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/test/java/org/apache/helix/Mocks.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/Mocks.java b/helix-core/src/test/java/org/apache/helix/Mocks.java
index d71556a..e22444d 100644
--- a/helix-core/src/test/java/org/apache/helix/Mocks.java
+++ b/helix-core/src/test/java/org/apache/helix/Mocks.java
@@ -30,29 +30,7 @@ import java.util.concurrent.Future;
 import org.I0Itec.zkclient.DataUpdater;
 import org.I0Itec.zkclient.IZkChildListener;
 import org.I0Itec.zkclient.IZkDataListener;
-import org.apache.helix.BaseDataAccessor;
-import org.apache.helix.ClusterMessagingService;
-import org.apache.helix.ConfigAccessor;
-import org.apache.helix.ConfigChangeListener;
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
-import org.apache.helix.ControllerChangeListener;
-import org.apache.helix.Criteria;
-import org.apache.helix.CurrentStateChangeListener;
-import org.apache.helix.ExternalViewChangeListener;
-import org.apache.helix.HealthStateChangeListener;
-import org.apache.helix.HelixAdmin;
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixManager;
-import org.apache.helix.HelixProperty;
-import org.apache.helix.IdealStateChangeListener;
-import org.apache.helix.InstanceType;
-import org.apache.helix.LiveInstanceChangeListener;
-import org.apache.helix.MessageListener;
-import org.apache.helix.NotificationContext;
-import org.apache.helix.PreConnectCallback;
-import org.apache.helix.PropertyKey;
-import org.apache.helix.PropertyType;
-import org.apache.helix.ZNRecord;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.healthcheck.HealthReportProvider;
 import org.apache.helix.healthcheck.ParticipantHealthReportCollector;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/test/java/org/apache/helix/TestConfigAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/TestConfigAccessor.java b/helix-core/src/test/java/org/apache/helix/TestConfigAccessor.java
index f658d37..76c331f 100644
--- a/helix-core/src/test/java/org/apache/helix/TestConfigAccessor.java
+++ b/helix-core/src/test/java/org/apache/helix/TestConfigAccessor.java
@@ -21,10 +21,9 @@ package org.apache.helix;
 
 import java.util.List;
 
-import org.apache.helix.ConfigAccessor;
-import org.apache.helix.ConfigScope;
-import org.apache.helix.ConfigScopeBuilder;
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.ConfigScope;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.builder.ConfigScopeBuilder;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/test/java/org/apache/helix/TestHelper.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/TestHelper.java b/helix-core/src/test/java/org/apache/helix/TestHelper.java
index 8bc12bb..55b08d5 100644
--- a/helix-core/src/test/java/org/apache/helix/TestHelper.java
+++ b/helix-core/src/test/java/org/apache/helix/TestHelper.java
@@ -435,11 +435,11 @@ public class TestHelper
 
     for (int i = 0; i < resourceNb; i++)
     {
-      String dbName = resourceNamePrefix + i;
-      setupTool.addResourceToCluster(clusterName, dbName, partitionNb, stateModelDef, mode.toString());
+      String resourceName = resourceNamePrefix + i;
+      setupTool.addResourceToCluster(clusterName, resourceName, partitionNb, stateModelDef, mode.toString());
       if (doRebalance)
       {
-        setupTool.rebalanceStorageCluster(clusterName, dbName, replica);
+        setupTool.rebalanceStorageCluster(clusterName, resourceName, replica);
       }
     }
     zkClient.close();

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/test/java/org/apache/helix/TestListenerCallback.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/TestListenerCallback.java b/helix-core/src/test/java/org/apache/helix/TestListenerCallback.java
index 7465f7c..7d0d0e0 100644
--- a/helix-core/src/test/java/org/apache/helix/TestListenerCallback.java
+++ b/helix-core/src/test/java/org/apache/helix/TestListenerCallback.java
@@ -22,7 +22,7 @@ package org.apache.helix;
 import java.util.Date;
 import java.util.List;
 
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.model.InstanceConfig;
 import org.testng.Assert;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/test/java/org/apache/helix/TestRoutingTable.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/TestRoutingTable.java b/helix-core/src/test/java/org/apache/helix/TestRoutingTable.java
index 986bb82..36c7a0f 100644
--- a/helix-core/src/test/java/org/apache/helix/TestRoutingTable.java
+++ b/helix-core/src/test/java/org/apache/helix/TestRoutingTable.java
@@ -31,14 +31,7 @@ import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixManager;
-import org.apache.helix.HelixProperty;
-import org.apache.helix.NotificationContext;
-import org.apache.helix.PropertyKey;
-import org.apache.helix.PropertyType;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 import org.apache.helix.Mocks.MockAccessor;
 import org.apache.helix.model.ExternalView;
 import org.apache.helix.model.InstanceConfig;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/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 c432106..1ccc8a5 100644
--- a/helix-core/src/test/java/org/apache/helix/ZkUnitTestBase.java
+++ b/helix-core/src/test/java/org/apache/helix/ZkUnitTestBase.java
@@ -27,12 +27,7 @@ import java.util.Map;
 import org.I0Itec.zkclient.IZkStateListener;
 import org.I0Itec.zkclient.ZkConnection;
 import org.I0Itec.zkclient.ZkServer;
-import org.apache.helix.HelixAdmin;
-import org.apache.helix.HelixManager;
-import org.apache.helix.PropertyPathConfig;
-import org.apache.helix.PropertyType;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.controller.pipeline.Pipeline;
 import org.apache.helix.controller.pipeline.Stage;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/test/java/org/apache/helix/controller/stages/DummyClusterManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/controller/stages/DummyClusterManager.java b/helix-core/src/test/java/org/apache/helix/controller/stages/DummyClusterManager.java
index cad41d0..b112656 100644
--- a/helix-core/src/test/java/org/apache/helix/controller/stages/DummyClusterManager.java
+++ b/helix-core/src/test/java/org/apache/helix/controller/stages/DummyClusterManager.java
@@ -22,7 +22,7 @@ package org.apache.helix.controller.stages;
 import org.apache.helix.ClusterMessagingService;
 import org.apache.helix.ConfigAccessor;
 import org.apache.helix.ConfigChangeListener;
-import org.apache.helix.ConfigScope.ConfigScopeProperty;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 import org.apache.helix.ControllerChangeListener;
 import org.apache.helix.CurrentStateChangeListener;
 import org.apache.helix.ExternalViewChangeListener;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertActionTriggering.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertActionTriggering.java b/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertActionTriggering.java
index 4131558..32a9965 100644
--- a/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertActionTriggering.java
+++ b/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertActionTriggering.java
@@ -24,13 +24,12 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.helix.ConfigAccessor;
-import org.apache.helix.ConfigScope;
-import org.apache.helix.ConfigScopeBuilder;
+import org.apache.helix.model.ConfigScope;
+import org.apache.helix.model.builder.ConfigScopeBuilder;
 import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.HelixManager;
 import org.apache.helix.ZNRecord;
 import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.healthcheck.HealthStatsAggregationTask;
 import org.apache.helix.integration.ZkStandAloneCMTestBaseWithPropertyServerCheck;
 import org.apache.helix.model.ExternalView;
 import org.apache.helix.model.HealthStat;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertFireHistory.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertFireHistory.java b/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertFireHistory.java
index 87151aa..5c82b72 100644
--- a/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertFireHistory.java
+++ b/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertFireHistory.java
@@ -24,15 +24,13 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.TreeMap;
 
-import org.apache.helix.ConfigScope;
-import org.apache.helix.ConfigScopeBuilder;
+import org.apache.helix.model.ConfigScope;
+import org.apache.helix.model.builder.ConfigScopeBuilder;
 import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.HelixManager;
 import org.apache.helix.HelixProperty;
 import org.apache.helix.ZNRecord;
 import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.healthcheck.HealthStatsAggregationTask;
-import org.apache.helix.integration.ZkStandAloneCMTestBase;
 import org.apache.helix.integration.ZkStandAloneCMTestBaseWithPropertyServerCheck;
 import org.apache.helix.model.AlertHistory;
 import org.apache.helix.model.HealthStat;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java b/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
index 145c2a3..36f25f2 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
@@ -90,7 +90,7 @@ public class TestBatchMessage extends ZkIntegrationTestBase
     idealState.setBatchMessageMode(true);
     accessor.setProperty(keyBuilder.idealStates("TestDB0"), idealState);
 
-    // registry a message listener so we know how many message generated
+    // register a message listener so we know how many message generated
     TestZkChildListener listener = new TestZkChildListener();
     _gZkClient.subscribeChildChanges(keyBuilder.messages("localhost_12918").getPath(), listener);
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java b/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java
index 5a08d41..9605b76 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/ZkIntegrationTestBase.java
@@ -24,8 +24,8 @@ import java.util.logging.Level;
 
 import org.I0Itec.zkclient.ZkServer;
 import org.apache.helix.ConfigAccessor;
-import org.apache.helix.ConfigScope;
-import org.apache.helix.ConfigScopeBuilder;
+import org.apache.helix.model.ConfigScope;
+import org.apache.helix.model.builder.ConfigScopeBuilder;
 import org.apache.helix.TestHelper;
 import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.TestHelper.StartCMResult;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/test/java/org/apache/helix/manager/zk/TestZKUtil.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZKUtil.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZKUtil.java
index a31cc90..d2ed932 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZKUtil.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZKUtil.java
@@ -28,10 +28,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.ConfigScope.ConfigScopeProperty;
-import org.apache.helix.manager.zk.ZKUtil;
-import org.apache.helix.manager.zk.ZNRecordSerializer;
-import org.apache.helix.manager.zk.ZkClient;
+import org.apache.helix.model.ConfigScope.ConfigScopeProperty;
 import org.apache.log4j.Logger;
 import org.testng.AssertJUnit;
 import org.testng.annotations.AfterClass;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkClusterManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkClusterManager.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkClusterManager.java
index 50e8a2f..511f975 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkClusterManager.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkClusterManager.java
@@ -24,8 +24,8 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.helix.AccessOption;
-import org.apache.helix.ConfigScope;
-import org.apache.helix.ConfigScopeBuilder;
+import org.apache.helix.model.ConfigScope;
+import org.apache.helix.model.builder.ConfigScopeBuilder;
 import org.apache.helix.HelixAdmin;
 import org.apache.helix.HelixException;
 import org.apache.helix.InstanceType;
@@ -34,7 +34,6 @@ import org.apache.helix.TestHelper;
 import org.apache.helix.ZNRecord;
 import org.apache.helix.ZkUnitTestBase;
 import org.apache.helix.manager.MockListener;
-import org.apache.helix.manager.zk.ZKHelixManager;
 import org.apache.helix.store.zk.ZkHelixPropertyStore;
 import org.apache.zookeeper.data.Stat;
 import org.testng.Assert;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/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 d5118c9..3684362 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
@@ -25,11 +25,11 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.helix.*;
-import org.apache.helix.manager.zk.ZKHelixAdmin;
-import org.apache.helix.manager.zk.ZKUtil;
+import org.apache.helix.model.ConfigScope;
 import org.apache.helix.model.ExternalView;
 import org.apache.helix.model.InstanceConfig;
 import org.apache.helix.model.StateModelDefinition;
+import org.apache.helix.model.builder.ConfigScopeBuilder;
 import org.apache.helix.tools.StateModelConfigGenerator;
 import org.testng.Assert;
 import org.testng.AssertJUnit;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/6119a446/helix-core/src/test/java/org/apache/helix/messaging/handling/TestConfigThreadpoolSize.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/messaging/handling/TestConfigThreadpoolSize.java b/helix-core/src/test/java/org/apache/helix/messaging/handling/TestConfigThreadpoolSize.java
index f40cf09..8b1b08b 100644
--- a/helix-core/src/test/java/org/apache/helix/messaging/handling/TestConfigThreadpoolSize.java
+++ b/helix-core/src/test/java/org/apache/helix/messaging/handling/TestConfigThreadpoolSize.java
@@ -23,21 +23,12 @@ import java.util.HashSet;
 import java.util.concurrent.ThreadPoolExecutor;
 
 import org.apache.helix.ConfigAccessor;
-import org.apache.helix.ConfigScope;
-import org.apache.helix.ConfigScopeBuilder;
+import org.apache.helix.model.ConfigScope;
+import org.apache.helix.model.builder.ConfigScopeBuilder;
 import org.apache.helix.HelixManager;
 import org.apache.helix.NotificationContext;
-import org.apache.helix.TestHelper;
-import org.apache.helix.TestHelper.StartCMResult;
 import org.apache.helix.integration.ZkStandAloneCMTestBase;
-import org.apache.helix.integration.TestMessagingService.TestMessagingHandlerFactory.TestMessagingHandler;
 import org.apache.helix.messaging.DefaultMessagingService;
-import org.apache.helix.messaging.handling.HelixTaskExecutor;
-import org.apache.helix.messaging.handling.HelixTaskResult;
-import org.apache.helix.messaging.handling.MessageHandler;
-import org.apache.helix.messaging.handling.MessageHandlerFactory;
-import org.apache.helix.messaging.handling.MessageHandler.ErrorCode;
-import org.apache.helix.messaging.handling.MessageHandler.ErrorType;
 import org.apache.helix.model.Message;
 import org.testng.Assert;
 import org.testng.annotations.Test;


Mime
View raw message