You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by zz...@apache.org on 2014/08/04 22:19:23 UTC

[6/7] git commit: [HELIX-376] Remove HelixConnection/HelixManager duplicate code

[HELIX-376] Remove HelixConnection/HelixManager duplicate code


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

Branch: refs/heads/master
Commit: 02165c5203ffd226ad23d310ee3e027c9b761f65
Parents: 961b930
Author: zzhang <zz...@apache.org>
Authored: Tue Jul 29 17:04:22 2014 -0700
Committer: zzhang <zz...@apache.org>
Committed: Mon Aug 4 13:09:34 2014 -0700

----------------------------------------------------------------------
 .../helix/webapp/resources/ClusterResource.java |   5 +-
 .../helix/webapp/resources/ConfigResource.java  |   3 -
 .../webapp/resources/ConstraintResource.java    |   3 -
 .../webapp/resources/ControllerResource.java    |   5 +-
 .../webapp/TestHelixAdminScenariosRest.java     | 112 +--
 .../apache/helix/webapp/TestResetInstance.java  |  12 +-
 .../helix/webapp/TestResetPartitionState.java   |  14 +-
 .../apache/helix/webapp/TestResetResource.java  |  12 +-
 .../org/apache/helix/agent/TestHelixAgent.java  |   4 +-
 .../java/org/apache/helix/ConfigAccessor.java   | 234 ------
 .../org/apache/helix/ConfigChangeListener.java  |  38 -
 .../org/apache/helix/HelixAutoController.java   |  62 --
 .../java/org/apache/helix/HelixConnection.java  |  15 +-
 .../java/org/apache/helix/HelixManager.java     |  12 +-
 .../helix/HelixMultiClusterController.java      |  62 ++
 .../main/java/org/apache/helix/HelixRole.java   |   5 +
 .../java/org/apache/helix/HelixService.java     |   6 +
 .../apache/helix/api/id/AdministratorId.java    |  51 ++
 .../controller/GenericHelixController.java      |  15 +-
 .../helix/controller/HelixControllerMain.java   |   2 +-
 .../stages/BestPossibleStateCalcStage.java      |   2 +-
 .../controller/stages/TaskAssignmentStage.java  |   8 +-
 .../helix/manager/zk/CallbackHandler.java       |  13 +-
 .../manager/zk/ControllerManagerHelper.java     |   2 +-
 .../manager/zk/HelixConnectionAdaptor.java      | 304 -------
 .../apache/helix/manager/zk/ZKHelixManager.java | 808 ++++---------------
 .../helix/manager/zk/ZkCallbackHandler.java     |  16 +-
 .../helix/manager/zk/ZkHelixAutoController.java | 133 ---
 .../helix/manager/zk/ZkHelixConnection.java     | 160 ++--
 .../helix/manager/zk/ZkHelixController.java     |  20 +-
 .../zk/ZkHelixMultiClusterController.java       | 145 ++++
 .../helix/manager/zk/ZkHelixParticipant.java    |  15 +-
 .../manager/zk/ZkHelixRoleDefaultImpl.java      | 126 +++
 .../messaging/DefaultMessagingService.java      |  16 +-
 .../messaging/handling/HelixTaskExecutor.java   |   1 -
 .../org/apache/helix/model/ConfigScope.java     | 137 ----
 .../helix/model/builder/ConfigScopeBuilder.java | 127 ---
 .../helix/participant/CustomCodeInvoker.java    |   6 +-
 .../participant/GenericLeaderStandbyModel.java  |   2 +-
 .../helix/spectator/RoutingTableProvider.java   |   6 +-
 .../src/test/java/org/apache/helix/Mocks.java   |   6 -
 .../org/apache/helix/TestConfigAccessor.java    |  78 +-
 .../test/java/org/apache/helix/TestHelper.java  |  14 +-
 .../java/org/apache/helix/TestZKCallback.java   |   6 +-
 .../java/org/apache/helix/ZkTestHelper.java     |   1 -
 .../org/apache/helix/api/TestNewStages.java     |  12 +-
 .../controller/stages/DummyClusterManager.java  |   7 -
 .../stages/TestRebalancePipeline.java           |   6 +-
 .../helix/integration/IntegrationTest.java      |  52 +-
 .../helix/integration/TestAddClusterV2.java     |  12 +-
 .../TestAddNodeAfterControllerStart.java        |  32 +-
 .../TestAddStateModelFactoryAfterConnect.java   |  13 +-
 .../integration/TestAutoIsWithEmptyMap.java     |  12 +-
 .../helix/integration/TestAutoRebalance.java    |  14 +-
 .../TestAutoRebalancePartitionLimit.java        |  14 +-
 .../helix/integration/TestBasicSpectator.java   |   2 +-
 .../helix/integration/TestBatchMessage.java     |  40 +-
 .../integration/TestBatchMessageWrapper.java    |  12 +-
 .../integration/TestBucketizedResource.java     |  12 +-
 .../integration/TestCarryOverBadCurState.java   |  12 +-
 .../integration/TestCleanupExternalView.java    |  12 +-
 .../helix/integration/TestClusterStartsup.java  |   1 -
 .../TestCorrectnessOnConnectivityLoss.java      |   8 +-
 .../helix/integration/TestCustomIdealState.java |   1 -
 .../TestCustomizedIdealStateRebalancer.java     |   1 -
 .../apache/helix/integration/TestDisable.java   |  36 +-
 .../TestDisableCustomCodeRunner.java            |  16 +-
 .../helix/integration/TestDisableResource.java  |  31 +-
 .../integration/TestDistributedCMMain.java      |  15 +-
 .../TestDistributedClusterController.java       |  16 +-
 .../apache/helix/integration/TestDriver.java    |  24 +-
 .../org/apache/helix/integration/TestDrop.java  |  62 +-
 .../helix/integration/TestDropResource.java     |   4 +-
 .../TestEnablePartitionDuringDisable.java       |  14 +-
 .../integration/TestEntropyFreeNodeBounce.java  |  15 +-
 .../helix/integration/TestErrorPartition.java   |  16 +-
 .../integration/TestExternalViewUpdates.java    |  12 +-
 .../integration/TestFullAutoNodeTagging.java    |  28 +-
 .../integration/TestHelixCustomCodeRunner.java  |  12 +-
 .../helix/integration/TestInstanceAutoJoin.java |  15 +-
 .../integration/TestInvalidAutoIdealState.java  |  12 +-
 .../TestInvalidResourceRebalance.java           |  12 +-
 .../helix/integration/TestMessageThrottle.java  |  13 +-
 .../helix/integration/TestMessageThrottle2.java |  26 +-
 .../helix/integration/TestMessagingService.java |  10 +-
 .../integration/TestNonOfflineInitState.java    |  13 +-
 .../helix/integration/TestNullReplica.java      |  12 +-
 .../TestParticipantNameCollision.java           |   6 +-
 .../TestPartitionLevelTransitionConstraint.java |  17 +-
 .../helix/integration/TestPauseSignal.java      |  12 +-
 .../integration/TestPreferenceListAsQueue.java  |   1 -
 .../integration/TestRedefineStateModelDef.java  |  14 +-
 .../TestReelectedPipelineCorrectness.java       |  13 +-
 .../helix/integration/TestRenamePartition.java  |  26 +-
 .../helix/integration/TestResetInstance.java    |  14 +-
 .../integration/TestResetPartitionState.java    |  14 +-
 .../helix/integration/TestResetResource.java    |  14 +-
 .../integration/TestRestartParticipant.java     |  26 +-
 .../helix/integration/TestSchemataSM.java       |  14 +-
 .../TestSessionExpiryInTransition.java          |  22 +-
 .../helix/integration/TestSharedConnection.java |   5 +-
 .../helix/integration/TestStandAloneCMMain.java |   6 +-
 .../TestStandAloneCMSessionExpiry.java          |  15 +-
 ...estStartMultipleControllersWithSameName.java |   8 +-
 .../integration/TestStateTransitionTimeout.java |  10 +-
 .../helix/integration/TestSwapInstance.java     |   8 +-
 .../integration/TestZkCallbackHandlerLeak.java  | 116 +--
 .../helix/integration/TestZkSessionExpiry.java  |  12 +-
 .../integration/ZkStandAloneCMTestBase.java     |  12 +-
 .../manager/ClusterControllerManager.java       |  90 ---
 .../manager/ClusterDistributedController.java   |  92 ---
 .../manager/MockParticipantManager.java         | 116 ---
 .../manager/TestConsecutiveZkSessionExpiry.java |  33 +-
 .../manager/TestControllerManager.java          |  18 +-
 .../TestDistributedControllerManager.java       |  22 +-
 .../manager/TestParticipantManager.java         |  18 +-
 .../integration/manager/TestStateModelLeak.java |  18 +-
 .../manager/TestZkCallbackHandlerLeak.java      |  69 +-
 .../task/TestIndependentTaskRebalancer.java     |  12 +-
 .../integration/task/TestTaskRebalancer.java    |  12 +-
 .../task/TestTaskRebalancerStopResume.java      |  12 +-
 .../org/apache/helix/manager/MockListener.java  |   6 +-
 .../apache/helix/manager/zk/MockController.java |  86 ++
 .../manager/zk/MockMultiClusterController.java  |  99 +++
 .../helix/manager/zk/MockParticipant.java       | 119 +++
 .../helix/manager/zk/TestHandleNewSession.java  |   5 +-
 .../manager/zk/TestLiveInstanceBounce.java      |   3 +-
 .../manager/zk/TestZKLiveInstanceData.java      |  13 -
 .../helix/manager/zk/TestZkClusterManager.java  |  39 +-
 .../apache/helix/manager/zk/TestZkFlapping.java |  10 +-
 .../manager/zk/TestZkHelixAutoController.java   |   4 +-
 .../zk/TestZkManagerFlappingDetection.java      |   6 +-
 .../manager/zk/TestZkStateChangeListener.java   |  13 +-
 .../helix/manager/zk/ZkConnTestHelper.java      |  34 +
 .../handling/TestConfigThreadpoolSize.java      |  15 +-
 .../handling/TestResourceThreadpoolSize.java    |  10 +-
 .../helix/mock/controller/MockController.java   | 140 ----
 .../mock/controller/MockControllerProcess.java  |  76 --
 .../org/apache/helix/model/TestConstraint.java  |   2 -
 .../TestClusterStatusMonitorLifecycle.java      |  25 +-
 .../mbeans/TestDropResourceMetricsReset.java    |  14 +-
 .../mbeans/TestResetClusterMetrics.java         |  12 +-
 .../helix/participant/MockZKHelixManager.java   |   7 -
 .../zk/TestZkManagerWithAutoFallbackStore.java  |   6 +-
 .../org/apache/helix/testutil/TestUtil.java     |   4 +-
 .../helix/tools/TestClusterStateVerifier.java   |  16 +-
 .../apache/helix/tools/TestHelixAdminCli.java   |  36 +-
 .../provisioning/yarn/AppMasterLauncher.java    |   4 +-
 .../yarn/example/JobRunnerMain.java             |  10 +-
 .../yarn/example/MyTaskService.java             |   4 +-
 150 files changed, 1905 insertions(+), 3323 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterResource.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterResource.java
index b22d801..dda0794 100644
--- a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterResource.java
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ClusterResource.java
@@ -20,9 +20,7 @@ package org.apache.helix.webapp.resources;
  */
 
 import java.io.IOException;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.HelixException;
@@ -35,7 +33,6 @@ import org.apache.helix.webapp.RestAdminApplication;
 import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.map.JsonMappingException;
 import org.restlet.data.MediaType;
-import org.restlet.data.Method;
 import org.restlet.data.Status;
 import org.restlet.representation.Representation;
 import org.restlet.representation.StringRepresentation;
@@ -43,7 +40,7 @@ import org.restlet.representation.Variant;
 import org.restlet.resource.ServerResource;
 
 public class ClusterResource extends ServerResource {
-    
+
   public ClusterResource() {
     getVariants().add(new Variant(MediaType.TEXT_PLAIN));
     getVariants().add(new Variant(MediaType.APPLICATION_JSON));

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/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 3c384d4..3a0d83a 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
@@ -33,9 +33,6 @@ import org.apache.helix.model.builder.HelixConfigScopeBuilder;
 import org.apache.helix.tools.ClusterSetup;
 import org.apache.helix.webapp.RestAdminApplication;
 import org.apache.log4j.Logger;
-import org.restlet.Context;
-import org.restlet.Request;
-import org.restlet.Response;
 import org.restlet.data.MediaType;
 import org.restlet.data.Status;
 import org.restlet.representation.Representation;

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConstraintResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConstraintResource.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConstraintResource.java
index 675d0ec..afa2454 100644
--- a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConstraintResource.java
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConstraintResource.java
@@ -29,9 +29,6 @@ import org.apache.helix.model.ClusterConstraints.ConstraintType;
 import org.apache.helix.tools.ClusterSetup;
 import org.apache.helix.webapp.RestAdminApplication;
 import org.apache.log4j.Logger;
-import org.restlet.Context;
-import org.restlet.Request;
-import org.restlet.Response;
 import org.restlet.data.MediaType;
 import org.restlet.data.Status;
 import org.restlet.representation.Representation;

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ControllerResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ControllerResource.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ControllerResource.java
index ea7be42..3ac4151 100644
--- a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ControllerResource.java
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ControllerResource.java
@@ -40,9 +40,6 @@ import org.apache.helix.util.StatusUpdateUtil.Level;
 import org.apache.helix.webapp.RestAdminApplication;
 import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.map.JsonMappingException;
-import org.restlet.Context;
-import org.restlet.Request;
-import org.restlet.Response;
 import org.restlet.data.MediaType;
 import org.restlet.data.Status;
 import org.restlet.representation.Representation;
@@ -135,7 +132,7 @@ public class ControllerResource extends ServerResource {
           MediaType.APPLICATION_JSON);
       getResponse().setStatus(Status.SUCCESS_OK);
     }
-    
+
     return null;
   }
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestHelixAdminScenariosRest.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestHelixAdminScenariosRest.java b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestHelixAdminScenariosRest.java
index 66065c3..5aa26d2 100644
--- a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestHelixAdminScenariosRest.java
+++ b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestHelixAdminScenariosRest.java
@@ -31,9 +31,9 @@ import java.util.Map;
 import org.apache.helix.HelixAdmin;
 import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.ZNRecord;
-import org.apache.helix.integration.manager.ClusterControllerManager;
-import org.apache.helix.integration.manager.ClusterDistributedController;
-import org.apache.helix.integration.manager.MockParticipantManager;
+import org.apache.helix.manager.zk.MockParticipant;
+import org.apache.helix.manager.zk.MockMultiClusterController;
+import org.apache.helix.manager.zk.MockController;
 import org.apache.helix.manager.zk.ZKUtil;
 import org.apache.helix.model.ExternalView;
 import org.apache.helix.model.IdealState;
@@ -330,10 +330,10 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     final String clusterName = "clusterTestDeactivateCluster";
     final String controllerClusterName = "controllerClusterTestDeactivateCluster";
 
-    Map<String, MockParticipantManager> participants =
-        new HashMap<String, MockParticipantManager>();
-    Map<String, ClusterDistributedController> distControllers =
-        new HashMap<String, ClusterDistributedController>();
+    Map<String, MockParticipant> participants =
+        new HashMap<String, MockParticipant>();
+    Map<String, MockMultiClusterController> distControllers =
+        new HashMap<String, MockMultiClusterController>();
 
     // setup cluster
     addCluster(clusterName);
@@ -347,8 +347,8 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     // start mock nodes
     for (int i = 0; i < 6; i++) {
       String instanceName = "localhost_123" + i;
-      MockParticipantManager participant =
-          new MockParticipantManager(_zkaddr, clusterName, instanceName);
+      MockParticipant participant =
+          new MockParticipant(_zkaddr, clusterName, instanceName);
       participant.syncStart();
       participants.put(instanceName, participant);
     }
@@ -356,8 +356,8 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     // start controller nodes
     for (int i = 0; i < 2; i++) {
       String controllerName = "controller_900" + i;
-      ClusterDistributedController distController =
-          new ClusterDistributedController(_zkaddr, controllerClusterName, controllerName);
+      MockMultiClusterController distController =
+          new MockMultiClusterController(_zkaddr, controllerClusterName, controllerName);
       distController.syncStart();
       distControllers.put(controllerName, distController);
     }
@@ -390,7 +390,7 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     Assert.assertTrue(_zkclient.exists("/" + clusterName));
 
     // leader node should be gone
-    for (MockParticipantManager participant : participants.values()) {
+    for (MockParticipant participant : participants.values()) {
       participant.syncStop();
     }
     deleteUrl(clusterUrl, false);
@@ -398,11 +398,11 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     Assert.assertFalse(_zkclient.exists("/" + clusterName));
 
     // clean up
-    for (ClusterDistributedController controller : distControllers.values()) {
+    for (MockMultiClusterController controller : distControllers.values()) {
       controller.syncStop();
     }
 
-    for (MockParticipantManager participant : participants.values()) {
+    for (MockParticipant participant : participants.values()) {
       participant.syncStop();
     }
   }
@@ -433,17 +433,17 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     pw.write(x);
     pw.close();
 
-    ClusterControllerManager controller =
-        new ClusterControllerManager(_zkaddr, clusterName, "controller_9900");
+    MockController controller =
+        new MockController(_zkaddr, clusterName, "controller_9900");
     controller.syncStart();
 
     // start mock nodes
-    Map<String, MockParticipantManager> participants =
-        new HashMap<String, MockParticipantManager>();
+    Map<String, MockParticipant> participants =
+        new HashMap<String, MockParticipant>();
     for (int i = 0; i < 6; i++) {
       String instanceName = "localhost_123" + i;
-      MockParticipantManager participant =
-          new MockParticipantManager(_zkaddr, clusterName, instanceName);
+      MockParticipant participant =
+          new MockParticipant(_zkaddr, clusterName, instanceName);
       participant.syncStart();
       participants.put(instanceName, participant);
     }
@@ -478,7 +478,7 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
 
     // clean up
     controller.syncStop();
-    for (MockParticipantManager participant : participants.values()) {
+    for (MockParticipant participant : participants.values()) {
       participant.syncStop();
     }
   }
@@ -509,17 +509,17 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     addResource(clusterName, "db_11", 22);
     rebalanceResource(clusterName, "db_11");
 
-    ClusterControllerManager controller =
-        new ClusterControllerManager(_zkaddr, clusterName, "controller_9900");
+    MockController controller =
+        new MockController(_zkaddr, clusterName, "controller_9900");
     controller.syncStart();
 
     // start mock nodes
-    Map<String, MockParticipantManager> participants =
-        new HashMap<String, MockParticipantManager>();
+    Map<String, MockParticipant> participants =
+        new HashMap<String, MockParticipant>();
     for (int i = 0; i < 6; i++) {
       String instanceName = "localhost_123" + i;
-      MockParticipantManager participant =
-          new MockParticipantManager(_zkaddr, clusterName, instanceName);
+      MockParticipant participant =
+          new MockParticipant(_zkaddr, clusterName, instanceName);
       participant.syncStart();
       participants.put(instanceName, participant);
     }
@@ -543,8 +543,8 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
 
     for (int i = 3; i <= 6; i++) {
       String instanceName = "localhost_123" + i + "1";
-      MockParticipantManager participant =
-          new MockParticipantManager(_zkaddr, clusterName, instanceName);
+      MockParticipant participant =
+          new MockParticipant(_zkaddr, clusterName, instanceName);
       participant.syncStart();
       participants.put(instanceName, participant);
     }
@@ -561,7 +561,7 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
 
     // clean up
     controller.syncStop();
-    for (MockParticipantManager participant : participants.values()) {
+    for (MockParticipant participant : participants.values()) {
       participant.syncStop();
     }
   }
@@ -587,17 +587,17 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     addResource(clusterName, "db_11", 22);
     rebalanceResource(clusterName, "db_11");
 
-    ClusterControllerManager controller =
-        new ClusterControllerManager(_zkaddr, clusterName, "controller_9900");
+    MockController controller =
+        new MockController(_zkaddr, clusterName, "controller_9900");
     controller.syncStart();
 
     // start mock nodes
-    Map<String, MockParticipantManager> participants =
-        new HashMap<String, MockParticipantManager>();
+    Map<String, MockParticipant> participants =
+        new HashMap<String, MockParticipant>();
     for (int i = 0; i < 6; i++) {
       String instanceName = "localhost_123" + i;
-      MockParticipantManager participant =
-          new MockParticipantManager(_zkaddr, clusterName, instanceName);
+      MockParticipant participant =
+          new MockParticipant(_zkaddr, clusterName, instanceName);
       participant.syncStart();
       participants.put(instanceName, participant);
     }
@@ -641,7 +641,7 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
 
     // clean up
     controller.syncStop();
-    for (MockParticipantManager participant : participants.values()) {
+    for (MockParticipant participant : participants.values()) {
       participant.syncStop();
     }
   }
@@ -673,17 +673,17 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     addResource(clusterName, "db_11", 8);
     rebalanceResource(clusterName, "db_11");
 
-    ClusterControllerManager controller =
-        new ClusterControllerManager(_zkaddr, clusterName, "controller_9900");
+    MockController controller =
+        new MockController(_zkaddr, clusterName, "controller_9900");
     controller.syncStart();
 
     // start mock nodes
-    Map<String, MockParticipantManager> participants =
-        new HashMap<String, MockParticipantManager>();
+    Map<String, MockParticipant> participants =
+        new HashMap<String, MockParticipant>();
     for (int i = 0; i < 6; i++) {
       String instanceName = "localhost_123" + i;
-      MockParticipantManager participant =
-          new MockParticipantManager(_zkaddr, clusterName, instanceName);
+      MockParticipant participant =
+          new MockParticipant(_zkaddr, clusterName, instanceName);
       participant.syncStart();
       participants.put(instanceName, participant);
     }
@@ -723,8 +723,8 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     String path = accessor.keyBuilder().instanceConfig("localhost_1232").getPath();
     Assert.assertFalse(_zkclient.exists(path));
 
-    MockParticipantManager newParticipant =
-        new MockParticipantManager(_zkaddr, clusterName, "localhost_12320");
+    MockParticipant newParticipant =
+        new MockParticipant(_zkaddr, clusterName, "localhost_12320");
     newParticipant.syncStart();
     participants.put("localhost_12320", newParticipant);
 
@@ -735,7 +735,7 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
 
     // clean up
     controller.syncStop();
-    for (MockParticipantManager participant : participants.values()) {
+    for (MockParticipant participant : participants.values()) {
       participant.syncStop();
     }
   }
@@ -745,10 +745,10 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     final String clusterName = "clusterTestStartCluster";
     final String controllerClusterName = "controllerClusterTestStartCluster";
 
-    Map<String, MockParticipantManager> participants =
-        new HashMap<String, MockParticipantManager>();
-    Map<String, ClusterDistributedController> distControllers =
-        new HashMap<String, ClusterDistributedController>();
+    Map<String, MockParticipant> participants =
+        new HashMap<String, MockParticipant>();
+    Map<String, MockMultiClusterController> distControllers =
+        new HashMap<String, MockMultiClusterController>();
 
     // setup cluster
     addCluster(clusterName);
@@ -762,8 +762,8 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     // start mock nodes
     for (int i = 0; i < 6; i++) {
       String instanceName = "localhost_123" + i;
-      MockParticipantManager participant =
-          new MockParticipantManager(_zkaddr, clusterName, instanceName);
+      MockParticipant participant =
+          new MockParticipant(_zkaddr, clusterName, instanceName);
       participant.syncStart();
       participants.put(instanceName, participant);
     }
@@ -771,8 +771,8 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     // start controller nodes
     for (int i = 0; i < 2; i++) {
       String controllerName = "controller_900" + i;
-      ClusterDistributedController distController =
-          new ClusterDistributedController(_zkaddr, controllerClusterName, controllerName);
+      MockMultiClusterController distController =
+          new MockMultiClusterController(_zkaddr, controllerClusterName, controllerName);
       distController.syncStart();
       distControllers.put(controllerName, distController);
     }
@@ -821,10 +821,10 @@ public class TestHelixAdminScenariosRest extends AdminTestBase {
     Thread.sleep(1000);
 
     // clean up
-    for (ClusterDistributedController controller : distControllers.values()) {
+    for (MockMultiClusterController controller : distControllers.values()) {
       controller.syncStop();
     }
-    for (MockParticipantManager participant : participants.values()) {
+    for (MockParticipant participant : participants.values()) {
       participant.syncStop();
     }
   }

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetInstance.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetInstance.java b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetInstance.java
index b89a067..a9ecaa0 100644
--- a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetInstance.java
+++ b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetInstance.java
@@ -25,8 +25,8 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.helix.TestHelper;
-import org.apache.helix.integration.manager.ClusterControllerManager;
-import org.apache.helix.integration.manager.MockParticipantManager;
+import org.apache.helix.manager.zk.MockParticipant;
+import org.apache.helix.manager.zk.MockController;
 import org.apache.helix.mock.participant.ErrTransition;
 import org.apache.helix.tools.ClusterSetup;
 import org.apache.helix.tools.ClusterStateVerifier;
@@ -54,7 +54,7 @@ public class TestResetInstance extends AdminTestBase {
         "MasterSlave", true); // do rebalance
 
     // start controller
-    ClusterControllerManager controller = new ClusterControllerManager(_zkaddr, clusterName, "controller_0");
+    MockController controller = new MockController(_zkaddr, clusterName, "controller_0");
     controller.syncStart();
 
     Map<String, Set<String>> errPartitions = new HashMap<String, Set<String>>() {
@@ -65,16 +65,16 @@ public class TestResetInstance extends AdminTestBase {
     };
 
     // start mock participants
-    MockParticipantManager[] participants = new MockParticipantManager[n];
+    MockParticipant[] participants = new MockParticipant[n];
     for (int i = 0; i < n; i++) {
       String instanceName = "localhost_" + (12918 + i);
 
       if (i == 0) {
         participants[i] =
-            new MockParticipantManager(_zkaddr, clusterName, instanceName);
+            new MockParticipant(_zkaddr, clusterName, instanceName);
         participants[i].setTransition(new ErrTransition(errPartitions));
       } else {
-        participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
+        participants[i] = new MockParticipant(_zkaddr, clusterName, instanceName);
       }
       participants[i].syncStart();
     }

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetPartitionState.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetPartitionState.java b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetPartitionState.java
index 8cd6f42..d44f3bb 100644
--- a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetPartitionState.java
+++ b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetPartitionState.java
@@ -28,12 +28,10 @@ import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.helix.NotificationContext;
 import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
 import org.apache.helix.api.State;
-import org.apache.helix.integration.manager.ClusterControllerManager;
-import org.apache.helix.integration.manager.MockParticipantManager;
+import org.apache.helix.manager.zk.MockParticipant;
+import org.apache.helix.manager.zk.MockController;
 import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
 import org.apache.helix.mock.participant.ErrTransition;
 import org.apache.helix.model.LiveInstance;
 import org.apache.helix.model.Message;
@@ -98,7 +96,7 @@ public class TestResetPartitionState extends AdminTestBase {
         "MasterSlave", true); // do rebalance
 
     // start controller
-    ClusterControllerManager controller = new ClusterControllerManager(_zkaddr, clusterName, "controller_0");
+    MockController controller = new MockController(_zkaddr, clusterName, "controller_0");
     controller.syncStart();
 
     Map<String, Set<String>> errPartitions = new HashMap<String, Set<String>>();
@@ -106,16 +104,16 @@ public class TestResetPartitionState extends AdminTestBase {
     errPartitions.put("OFFLINE-SLAVE", TestHelper.setOf("TestDB0_8"));
 
     // start mock participants
-    MockParticipantManager[] participants = new MockParticipantManager[n];
+    MockParticipant[] participants = new MockParticipant[n];
     for (int i = 0; i < n; i++) {
       String instanceName = "localhost_" + (12918 + i);
 
       if (i == 0) {
         participants[i] =
-            new MockParticipantManager(_zkaddr, clusterName, instanceName);
+            new MockParticipant(_zkaddr, clusterName, instanceName);
         participants[i].setTransition(new ErrTransition(errPartitions));
       } else {
-        participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
+        participants[i] = new MockParticipant(_zkaddr, clusterName, instanceName);
       }
       participants[i].syncStart();
     }

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetResource.java b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetResource.java
index 464edc4..a54b0a3 100644
--- a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetResource.java
+++ b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestResetResource.java
@@ -25,8 +25,8 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.helix.TestHelper;
-import org.apache.helix.integration.manager.ClusterControllerManager;
-import org.apache.helix.integration.manager.MockParticipantManager;
+import org.apache.helix.manager.zk.MockParticipant;
+import org.apache.helix.manager.zk.MockController;
 import org.apache.helix.mock.participant.ErrTransition;
 import org.apache.helix.tools.ClusterSetup;
 import org.apache.helix.tools.ClusterStateVerifier;
@@ -54,7 +54,7 @@ public class TestResetResource extends AdminTestBase {
         "MasterSlave", true); // do rebalance
 
     // start controller
-    ClusterControllerManager controller = new ClusterControllerManager(_zkaddr, clusterName, "controller_0");
+    MockController controller = new MockController(_zkaddr, clusterName, "controller_0");
     controller.syncStart();
 
     Map<String, Set<String>> errPartitions = new HashMap<String, Set<String>>() {
@@ -65,16 +65,16 @@ public class TestResetResource extends AdminTestBase {
     };
 
     // start mock participants
-    MockParticipantManager[] participants = new MockParticipantManager[n];
+    MockParticipant[] participants = new MockParticipant[n];
     for (int i = 0; i < n; i++) {
       String instanceName = "localhost_" + (12918 + i);
 
       if (i == 0) {
         participants[i] =
-            new MockParticipantManager(_zkaddr, clusterName, instanceName);
+            new MockParticipant(_zkaddr, clusterName, instanceName);
         participants[i].setTransition(new ErrTransition(errPartitions));
       } else {
-        participants[i] = new MockParticipantManager(_zkaddr, clusterName, instanceName);
+        participants[i] = new MockParticipant(_zkaddr, clusterName, instanceName);
       }
       participants[i].syncStart();
     }

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-agent/src/test/java/org/apache/helix/agent/TestHelixAgent.java
----------------------------------------------------------------------
diff --git a/helix-agent/src/test/java/org/apache/helix/agent/TestHelixAgent.java b/helix-agent/src/test/java/org/apache/helix/agent/TestHelixAgent.java
index cbf0582..2904803 100644
--- a/helix-agent/src/test/java/org/apache/helix/agent/TestHelixAgent.java
+++ b/helix-agent/src/test/java/org/apache/helix/agent/TestHelixAgent.java
@@ -28,7 +28,7 @@ import org.apache.helix.ConfigAccessor;
 import org.apache.helix.ExternalCommand;
 import org.apache.helix.ScriptTestHelper;
 import org.apache.helix.TestHelper;
-import org.apache.helix.integration.manager.ClusterControllerManager;
+import org.apache.helix.manager.zk.MockController;
 import org.apache.helix.model.HelixConfigScope;
 import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
 import org.apache.helix.model.builder.HelixConfigScopeBuilder;
@@ -147,7 +147,7 @@ public class TestHelixAgent extends ZkTestBase {
     configAccessor.set(scope, cmdConfig.toKeyValueMap());
 
     // start controller
-    ClusterControllerManager controller = new ClusterControllerManager(zkAddr, clusterName, "controller_0");
+    MockController controller = new MockController(zkAddr, clusterName, "controller_0");
     controller.syncStart();
 
     // start helix-agent

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/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 3589165..406aeb1 100644
--- a/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
@@ -30,7 +30,6 @@ import java.util.TreeMap;
 import org.I0Itec.zkclient.exception.ZkNoNodeException;
 import org.apache.helix.manager.zk.ZKUtil;
 import org.apache.helix.manager.zk.ZkClient;
-import org.apache.helix.model.ConfigScope;
 import org.apache.helix.model.HelixConfigScope;
 import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
 import org.apache.helix.util.StringTemplate;
@@ -73,66 +72,6 @@ public class ConfigAccessor {
   }
 
   /**
-   * get config
-   * @deprecated replaced by {@link #get(HelixConfigScope, String)}
-   * @param scope
-   * @param key
-   * @return value or null if doesn't exist
-   */
-  @Deprecated
-  public String get(ConfigScope scope, String key) {
-    Map<String, String> map = get(scope, Arrays.asList(key));
-    return map.get(key);
-  }
-
-  /**
-   * get configs
-   * @deprecated replaced by {@link #get(HelixConfigScope, List<String>)}
-   * @param scope
-   * @param keys
-   * @return
-   */
-  @Deprecated
-  public Map<String, String> get(ConfigScope scope, List<String> keys) {
-    if (scope == null || scope.getScope() == null) {
-      LOG.error("Scope can't be null");
-      return null;
-    }
-
-    // String value = null;
-    Map<String, String> map = new HashMap<String, String>();
-    String clusterName = scope.getClusterName();
-    if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
-      throw new HelixException("cluster " + clusterName + " is not setup yet");
-    }
-
-    String scopeStr = scope.getScopeStr();
-    String[] splits = scopeStr.split("\\|");
-
-    ZNRecord record = zkClient.readData(splits[0], true);
-
-    if (record != null) {
-      if (splits.length == 1) {
-        for (String key : keys) {
-          if (record.getSimpleFields().containsKey(key)) {
-            map.put(key, record.getSimpleField(key));
-          }
-        }
-      } else if (splits.length == 2) {
-        if (record.getMapField(splits[1]) != null) {
-          for (String key : keys) {
-            if (record.getMapField(splits[1]).containsKey(key)) {
-              map.put(key, record.getMapField(splits[1]).get(key));
-            }
-          }
-        }
-      }
-    }
-    return map;
-
-  }
-
-  /**
    * get a single config entry
    * @param scope specification of the entity set to query
    *          (e.g. cluster, resource, participant, etc.)
@@ -198,72 +137,6 @@ public class ConfigAccessor {
   }
 
   /**
-   * Set config, create if not exist
-   * @deprecated replaced by {@link #set(HelixConfigScope, String, String)}
-   * @param scope
-   * @param key
-   * @param value
-   */
-  @Deprecated
-  public void set(ConfigScope scope, String key, String value) {
-    Map<String, String> map = new HashMap<String, String>();
-    map.put(key, value);
-    set(scope, map);
-  }
-
-  /**
-   * Set configs, create if not exist
-   * @deprecated replaced by {@link #set(HelixConfigScope, Map<String, String>)}
-   * @param scope
-   * @param keyValueMap
-   */
-  @Deprecated
-  public void set(ConfigScope scope, Map<String, String> keyValueMap) {
-    if (scope == null || scope.getScope() == null) {
-      LOG.error("Scope can't be null");
-      return;
-    }
-
-    String clusterName = scope.getClusterName();
-    if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
-      throw new HelixException("cluster: " + clusterName + " is NOT setup.");
-    }
-
-    if (scope.getScope() == ConfigScopeProperty.PARTICIPANT) {
-      String scopeStr = scope.getScopeStr();
-      String instanceName = scopeStr.substring(scopeStr.lastIndexOf('/') + 1);
-      if (!ZKUtil.isInstanceSetup(zkClient, scope.getClusterName(), instanceName,
-          InstanceType.PARTICIPANT)) {
-        throw new HelixException("instance: " + instanceName + " is NOT setup in cluster: "
-            + clusterName);
-      }
-    }
-
-    // use "|" to delimit resource and partition. e.g. /MyCluster/CONFIGS/PARTICIPANT/MyDB|MyDB_0
-    String scopeStr = scope.getScopeStr();
-    String[] splits = scopeStr.split("\\|");
-
-    String id = splits[0].substring(splits[0].lastIndexOf('/') + 1);
-    ZNRecord update = new ZNRecord(id);
-    if (splits.length == 1) {
-      for (String key : keyValueMap.keySet()) {
-        String value = keyValueMap.get(key);
-        update.setSimpleField(key, value);
-      }
-    } else if (splits.length == 2) {
-      if (update.getMapField(splits[1]) == null) {
-        update.setMapField(splits[1], new TreeMap<String, String>());
-      }
-      for (String key : keyValueMap.keySet()) {
-        String value = keyValueMap.get(key);
-        update.getMapField(splits[1]).put(key, value);
-      }
-    }
-    ZKUtil.createOrUpdate(zkClient, splits[0], update, true, true);
-    return;
-  }
-
-  /**
    * Set config, creating it if it doesn't exist
    * @param scope scope specification of the entity set to query
    *          (e.g. cluster, resource, participant, etc.)
@@ -315,59 +188,6 @@ public class ConfigAccessor {
   }
 
   /**
-   * Remove config
-   * @deprecated replaced by {@link #remove(HelixConfigScope, String)}
-   * @param scope
-   * @param key
-   */
-  @Deprecated
-  public void remove(ConfigScope scope, String key) {
-    remove(scope, Arrays.asList(key));
-  }
-
-  /**
-   * remove configs
-   * @deprecated replaced by {@link #remove(HelixConfigScope, List<String>)}
-   * @param scope
-   * @param keys
-   */
-  @Deprecated
-  public void remove(ConfigScope scope, List<String> keys) {
-    if (scope == null || scope.getScope() == null) {
-      LOG.error("Scope can't be null");
-      return;
-    }
-
-    String clusterName = scope.getClusterName();
-    if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
-      throw new HelixException("cluster " + clusterName + " is not setup yet");
-    }
-
-    String scopeStr = scope.getScopeStr();
-    String[] splits = scopeStr.split("\\|");
-
-    String id = splits[0].substring(splits[0].lastIndexOf('/') + 1);
-    ZNRecord update = new ZNRecord(id);
-    if (splits.length == 1) {
-      // subtract doesn't care about value, use empty string
-      for (String key : keys) {
-        update.setSimpleField(key, "");
-      }
-    } else if (splits.length == 2) {
-      if (update.getMapField(splits[1]) == null) {
-        update.setMapField(splits[1], new TreeMap<String, String>());
-      }
-      // subtract doesn't care about value, use empty string
-      for (String key : keys) {
-        update.getMapField(splits[1]).put(key, "");
-      }
-    }
-
-    ZKUtil.subtract(zkClient, splits[0], update);
-    return;
-  }
-
-  /**
    * Remove a single config
    * @param scope scope specification of the entity set to query
    *          (e.g. cluster, resource, participant, etc.)
@@ -416,60 +236,6 @@ public class ConfigAccessor {
   }
 
   /**
-   * get config keys
-   * @deprecated replaced by {@link #getKeys(HelixConfigScope)}
-   * @param type
-   * @param clusterName
-   * @param keys
-   * @return
-   */
-  @Deprecated
-  public List<String> getKeys(ConfigScopeProperty type, String clusterName, String... keys) {
-    if (type == null || clusterName == null) {
-      LOG.error("clusterName|scope can't be null");
-      return Collections.emptyList();
-    }
-
-    try {
-      if (!ZKUtil.isClusterSetup(clusterName, zkClient)) {
-        LOG.error("cluster " + clusterName + " is not setup yet");
-        return Collections.emptyList();
-      }
-
-      String[] args = new String[1 + keys.length];
-      args[0] = clusterName;
-      System.arraycopy(keys, 0, args, 1, keys.length);
-      String scopeStr = template.instantiate(type, args);
-      String[] splits = scopeStr.split("\\|");
-      List<String> retKeys = null;
-      if (splits.length == 1) {
-        retKeys = zkClient.getChildren(splits[0]);
-      } else {
-        ZNRecord record = zkClient.readData(splits[0]);
-
-        if (splits[1].startsWith("SIMPLEKEYS")) {
-          retKeys = new ArrayList<String>(record.getSimpleFields().keySet());
-
-        } else if (splits[1].startsWith("MAPKEYS")) {
-          retKeys = new ArrayList<String>(record.getMapFields().keySet());
-        } else if (splits[1].startsWith("MAPMAPKEYS")) {
-          retKeys = new ArrayList<String>(record.getMapField(splits[2]).keySet());
-        }
-      }
-      if (retKeys == null) {
-        LOG.error("Invalid scope: " + type + " or keys: " + Arrays.toString(args));
-        return Collections.emptyList();
-      }
-
-      Collections.sort(retKeys);
-      return retKeys;
-    } catch (Exception e) {
-      return Collections.emptyList();
-    }
-
-  }
-
-  /**
    * Get list of config keys for a scope
    * @param scope
    * @return a list of configuration keys

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-core/src/main/java/org/apache/helix/ConfigChangeListener.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/ConfigChangeListener.java b/helix-core/src/main/java/org/apache/helix/ConfigChangeListener.java
deleted file mode 100644
index 1dbf2fe..0000000
--- a/helix-core/src/main/java/org/apache/helix/ConfigChangeListener.java
+++ /dev/null
@@ -1,38 +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.List;
-
-import org.apache.helix.model.InstanceConfig;
-
-/**
- * @deprecated replaced by InstanceConfigChangeListener
- */
-public interface ConfigChangeListener {
-
-  /**
-   * Invoked when participant config changes
-   * @param configs
-   * @param changeContext
-   */
-  public void onConfigChange(List<InstanceConfig> configs, NotificationContext changeContext);
-
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-core/src/main/java/org/apache/helix/HelixAutoController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixAutoController.java b/helix-core/src/main/java/org/apache/helix/HelixAutoController.java
deleted file mode 100644
index 91ec809..0000000
--- a/helix-core/src/main/java/org/apache/helix/HelixAutoController.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.apache.helix;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.helix.api.id.ControllerId;
-import org.apache.helix.participant.StateMachineEngine;
-
-/**
- * Autonomous controller
- */
-public interface HelixAutoController extends HelixRole, HelixService, HelixConnectionStateListener {
-  /**
-   * get controller id
-   * @return controller id
-   */
-  ControllerId getControllerId();
-
-  /**
-   * get state machine engine
-   * @return state machine engine
-   */
-  StateMachineEngine getStateMachineEngine();
-
-  /**
-   * add pre-connect callback
-   * @param callback
-   */
-  void addPreConnectCallback(PreConnectCallback callback);
-
-  /**
-   * Add a LiveInstanceInfoProvider that is invoked before creating liveInstance.</br>
-   * This allows applications to provide additional information that will be published to zookeeper
-   * and become available for discovery</br>
-   * @see LiveInstanceInfoProvider#getAdditionalLiveInstanceInfo()
-   * @param liveInstanceInfoProvider
-   */
-  void setLiveInstanceInfoProvider(LiveInstanceInfoProvider liveInstanceInfoProvider);
-
-  /**
-   * tell if this controller is leader of cluster
-   * @return
-   */
-  boolean isLeader();
-
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-core/src/main/java/org/apache/helix/HelixConnection.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixConnection.java b/helix-core/src/main/java/org/apache/helix/HelixConnection.java
index ff5f458..4b7487b 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixConnection.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixConnection.java
@@ -82,7 +82,7 @@ public interface HelixConnection {
    * @param controllerId
    * @return
    */
-  HelixAutoController createAutoController(ClusterId clusterId, ControllerId controllerId);
+  HelixMultiClusterController createAutoController(ClusterId clusterId, ControllerId controllerId);
 
   /**
    * create a cluster-accessor
@@ -113,10 +113,8 @@ public interface HelixConnection {
 
   /**
    * get config accessor
-   * TODO replace with new ConfigAccessor
    * @return config accessor
    */
-  @Deprecated
   ConfigAccessor getConfigAccessor();
 
   /**
@@ -164,15 +162,6 @@ public interface HelixConnection {
       ParticipantId participantId);
 
   /**
-   * add config change listener
-   * @param role
-   * @param listener
-   * @param clusterId
-   */
-  @Deprecated
-  void addConfigChangeListener(HelixRole role, ConfigChangeListener listener, ClusterId clusterId);
-
-  /**
    * add instance config change listener
    * @see InstanceConfigChangeListener#onInstanceConfigChange(List, NotificationContext)
    * @param role
@@ -234,7 +223,7 @@ public interface HelixConnection {
   void removeConnectionStateListener(HelixConnectionStateListener listener);
 
   /**
-   * create messasing service using this connection
+   * create messaging service using this connection
    * @param role
    * @return messaging-service
    */

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/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 73313c0..9e2bd14 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixManager.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixManager.java
@@ -33,7 +33,7 @@ import org.apache.helix.store.zk.ZkHelixPropertyStore;
  * Class that represents the Helix Agent.
  * First class Object any process will interact with<br/>
  * General flow <blockquote>
- * 
+ *
  * <pre>
  * manager = HelixManagerFactory.getZKHelixManager(
  *    clusterName, instanceName, ROLE, zkAddr);
@@ -49,7 +49,7 @@ import org.apache.helix.store.zk.ZkHelixPropertyStore;
  * FINALIZE -> will be invoked when listener is removed or session expires
  * manager.disconnect()
  * </pre>
- * 
+ *
  * </blockquote> Default implementations available
  * @see HelixStateMachineEngine HelixStateMachineEngine for participant
  * @see RoutingTableProvider RoutingTableProvider for spectator
@@ -98,14 +98,6 @@ public interface HelixManager {
   void addLiveInstanceChangeListener(LiveInstanceChangeListener listener) throws Exception;
 
   /**
-   * @see ConfigChangeListener#onConfigChange(List, NotificationContext)
-   * @param listener
-   * @deprecated replaced by addInstanceConfigChangeListener()
-   */
-  @Deprecated
-  void addConfigChangeListener(ConfigChangeListener listener) throws Exception;
-
-  /**
    * @see InstanceConfigChangeListener#onInstanceConfigChange(List, NotificationContext)
    * @param listener
    */

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-core/src/main/java/org/apache/helix/HelixMultiClusterController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixMultiClusterController.java b/helix-core/src/main/java/org/apache/helix/HelixMultiClusterController.java
new file mode 100644
index 0000000..c4a587e
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/HelixMultiClusterController.java
@@ -0,0 +1,62 @@
+package org.apache.helix;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.helix.api.id.ControllerId;
+import org.apache.helix.participant.StateMachineEngine;
+
+/**
+ * Autonomous controller
+ */
+public interface HelixMultiClusterController extends HelixRole, HelixService, HelixConnectionStateListener {
+  /**
+   * get controller id
+   * @return controller id
+   */
+  ControllerId getControllerId();
+
+  /**
+   * get state machine engine
+   * @return state machine engine
+   */
+  StateMachineEngine getStateMachineEngine();
+
+  /**
+   * add pre-connect callback
+   * @param callback
+   */
+  void addPreConnectCallback(PreConnectCallback callback);
+
+  /**
+   * Add a LiveInstanceInfoProvider that is invoked before creating liveInstance.</br>
+   * This allows applications to provide additional information that will be published to zookeeper
+   * and become available for discovery</br>
+   * @see LiveInstanceInfoProvider#getAdditionalLiveInstanceInfo()
+   * @param liveInstanceInfoProvider
+   */
+  void setLiveInstanceInfoProvider(LiveInstanceInfoProvider liveInstanceInfoProvider);
+
+  /**
+   * tell if this controller is leader of cluster
+   * @return
+   */
+  boolean isLeader();
+
+}

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-core/src/main/java/org/apache/helix/HelixRole.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixRole.java b/helix-core/src/main/java/org/apache/helix/HelixRole.java
index ffcb700..dd77cc3 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixRole.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixRole.java
@@ -56,4 +56,9 @@ public interface HelixRole {
    */
   ClusterMessagingService getMessagingService();
 
+  /**
+   * get data accessor
+   * @return
+   */
+  HelixDataAccessor getAccessor();
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-core/src/main/java/org/apache/helix/HelixService.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixService.java b/helix-core/src/main/java/org/apache/helix/HelixService.java
index 40e9bae..37baa42 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixService.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixService.java
@@ -32,4 +32,10 @@ public interface HelixService {
    * stop helix service
    */
   void stop();
+
+  /**
+   * is service started
+   * @return
+   */
+  boolean isStarted();
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-core/src/main/java/org/apache/helix/api/id/AdministratorId.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/id/AdministratorId.java b/helix-core/src/main/java/org/apache/helix/api/id/AdministratorId.java
new file mode 100644
index 0000000..de6bcda
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/api/id/AdministratorId.java
@@ -0,0 +1,51 @@
+package org.apache.helix.api.id;
+
+/*
+ * 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.codehaus.jackson.annotate.JsonCreator;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class AdministratorId extends Id {
+  @JsonProperty("id")
+  private final String _id;
+
+  /**
+   * Create a spectator id
+   * @param id string representing a spectator id
+   */
+  @JsonCreator
+  public AdministratorId(@JsonProperty("id") String id) {
+    _id = id;
+  }
+
+  @Override
+  public String stringify() {
+    return _id;
+  }
+
+  /**
+   * Create a spectator id from a string
+   * @param spectatorId string representing a spectator id
+   * @return SpectatorId
+   */
+  public static AdministratorId from(String spectatorId) {
+    return new AdministratorId(spectatorId);
+  }
+}

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/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 7bb214e..f1c2583 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
@@ -29,7 +29,6 @@ import java.util.TimerTask;
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.I0Itec.zkclient.exception.ZkInterruptedException;
-import org.apache.helix.ConfigChangeListener;
 import org.apache.helix.ControllerChangeListener;
 import org.apache.helix.CurrentStateChangeListener;
 import org.apache.helix.ExternalViewChangeListener;
@@ -86,7 +85,7 @@ import org.apache.log4j.Logger;
  * 4. select the messages that can be sent, needs messages and state model constraints <br>
  * 5. send messages
  */
-public class GenericHelixController implements ConfigChangeListener, IdealStateChangeListener,
+public class GenericHelixController implements IdealStateChangeListener,
     LiveInstanceChangeListener, MessageListener, CurrentStateChangeListener,
     ExternalViewChangeListener, ControllerChangeListener, InstanceConfigChangeListener {
   private static final Logger logger = Logger.getLogger(GenericHelixController.class.getName());
@@ -433,8 +432,8 @@ public class GenericHelixController implements ConfigChangeListener, IdealStateC
   }
 
   @Override
-  public void onConfigChange(List<InstanceConfig> configs, NotificationContext changeContext) {
-    logger.info("START: GenericClusterController.onConfigChange()");
+  public void onInstanceConfigChange(List<InstanceConfig> configs, NotificationContext changeContext) {
+    logger.info("START: GenericClusterController.onInstanceConfigChange()");
     if (changeContext == null || changeContext.getType() != Type.CALLBACK) {
       _cache.requireFullRefresh();
     }
@@ -449,14 +448,6 @@ public class GenericHelixController implements ConfigChangeListener, IdealStateC
     event.addAttribute("helixmanager", changeContext.getManager());
     event.addAttribute("eventData", configs);
     _eventQueue.put(event);
-    logger.info("END: GenericClusterController.onConfigChange()");
-  }
-
-  @Override
-  public void onInstanceConfigChange(List<InstanceConfig> instanceConfigs,
-      NotificationContext changeContext) {
-    logger.info("START: GenericClusterController.onInstanceConfigChange()");
-    onConfigChange(instanceConfigs, changeContext);
     logger.info("END: GenericClusterController.onInstanceConfigChange()");
   }
 

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-core/src/main/java/org/apache/helix/controller/HelixControllerMain.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/HelixControllerMain.java b/helix-core/src/main/java/org/apache/helix/controller/HelixControllerMain.java
index b6c16b5..6aa3ab9 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/HelixControllerMain.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/HelixControllerMain.java
@@ -132,7 +132,7 @@ public class HelixControllerMain {
   public static void addListenersToController(HelixManager manager,
       GenericHelixController controller) {
     try {
-      manager.addConfigChangeListener(controller);
+      manager.addInstanceConfigChangeListener(controller);
       manager.addLiveInstanceChangeListener(controller);
       manager.addIdealStateChangeListener(controller);
       // no need for controller to listen on external-view

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-core/src/main/java/org/apache/helix/controller/stages/BestPossibleStateCalcStage.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/BestPossibleStateCalcStage.java b/helix-core/src/main/java/org/apache/helix/controller/stages/BestPossibleStateCalcStage.java
index 6f34953..d23e011 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/stages/BestPossibleStateCalcStage.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/stages/BestPossibleStateCalcStage.java
@@ -157,7 +157,7 @@ public class BestPossibleStateCalcStage extends AbstractBaseStage {
       Set<ParticipantId> errorParticipants = Sets.newHashSet();
       for (ParticipantId participantId : currentStateMap.keySet()) {
         State state = currentStateMap.get(participantId);
-        if (state.equals(State.from(HelixDefinedState.ERROR))) {
+        if (State.from(HelixDefinedState.ERROR).equals(state)) {
           errorParticipants.add(participantId);
         }
       }

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-core/src/main/java/org/apache/helix/controller/stages/TaskAssignmentStage.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/TaskAssignmentStage.java b/helix-core/src/main/java/org/apache/helix/controller/stages/TaskAssignmentStage.java
index 9d6228e..4057389 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/stages/TaskAssignmentStage.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/stages/TaskAssignmentStage.java
@@ -149,10 +149,10 @@ public class TaskAssignmentStage extends AbstractBaseStage {
           + " transit " + message.getPartitionId() + "|" + message.getPartitionIds() + " from:"
           + message.getTypedFromState() + " to:" + message.getTypedToState());
 
-      // System.out.println("[dbg] Sending Message " + message.getMsgId() + " to "
-      // + message.getTgtName() + " transit " + message.getPartitionId() + "|"
-      // + message.getPartitionIds() + " from: " + message.getFromState() + " to: "
-      // + message.getToState());
+//       System.out.println("[dbg] Sending Message " + message.getMsgId() + " to "
+//       + message.getTgtName() + " transit " + message.getPartitionId() + "|"
+//       + message.getPartitionIds() + " from: " + message.getFromState() + " to: "
+//       + message.getToState());
 
       keys.add(keyBuilder.message(message.getTgtName(), message.getId()));
     }

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java b/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
index 65fe2f9..cdb2845 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
@@ -37,7 +37,6 @@ import org.I0Itec.zkclient.IZkChildListener;
 import org.I0Itec.zkclient.IZkDataListener;
 import org.I0Itec.zkclient.exception.ZkNoNodeException;
 import org.apache.helix.BaseDataAccessor;
-import org.apache.helix.ConfigChangeListener;
 import org.apache.helix.ControllerChangeListener;
 import org.apache.helix.CurrentStateChangeListener;
 import org.apache.helix.ExternalViewChangeListener;
@@ -150,15 +149,9 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener
 
       } else if (_changeType == ChangeType.INSTANCE_CONFIG) {
         subscribeForChanges(changeContext, _path, true, true);
-        if (_listener instanceof ConfigChangeListener) {
-          ConfigChangeListener configChangeListener = (ConfigChangeListener) _listener;
-          List<InstanceConfig> configs = _accessor.getChildValues(_propertyKey);
-          configChangeListener.onConfigChange(configs, changeContext);
-        } else if (_listener instanceof InstanceConfigChangeListener) {
-          InstanceConfigChangeListener listener = (InstanceConfigChangeListener) _listener;
-          List<InstanceConfig> configs = _accessor.getChildValues(_propertyKey);
-          listener.onInstanceConfigChange(configs, changeContext);
-        }
+        InstanceConfigChangeListener listener = (InstanceConfigChangeListener) _listener;
+        List<InstanceConfig> configs = _accessor.getChildValues(_propertyKey);
+        listener.onInstanceConfigChange(configs, changeContext);
       } else if (_changeType == CONFIG) {
         subscribeForChanges(changeContext, _path, true, true);
         ScopedConfigChangeListener listener = (ScopedConfigChangeListener) _listener;

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-core/src/main/java/org/apache/helix/manager/zk/ControllerManagerHelper.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ControllerManagerHelper.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ControllerManagerHelper.java
index 9a817e3..623b874 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ControllerManagerHelper.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ControllerManagerHelper.java
@@ -72,7 +72,7 @@ public class ControllerManagerHelper {
       /**
        * setup generic-controller
        */
-      _manager.addConfigChangeListener(controller);
+      _manager.addInstanceConfigChangeListener(controller);
       _manager.addLiveInstanceChangeListener(controller);
       _manager.addIdealStateChangeListener(controller);
       // no need for controller to listen on external-view

http://git-wip-us.apache.org/repos/asf/helix/blob/02165c52/helix-core/src/main/java/org/apache/helix/manager/zk/HelixConnectionAdaptor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/HelixConnectionAdaptor.java b/helix-core/src/main/java/org/apache/helix/manager/zk/HelixConnectionAdaptor.java
deleted file mode 100644
index ef17715..0000000
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/HelixConnectionAdaptor.java
+++ /dev/null
@@ -1,304 +0,0 @@
-package org.apache.helix.manager.zk;
-
-/*
- * 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.ClusterMessagingService;
-import org.apache.helix.ConfigAccessor;
-import org.apache.helix.ConfigChangeListener;
-import org.apache.helix.ControllerChangeListener;
-import org.apache.helix.CurrentStateChangeListener;
-import org.apache.helix.ExternalViewChangeListener;
-import org.apache.helix.HelixAdmin;
-import org.apache.helix.HelixAutoController;
-import org.apache.helix.HelixConnection;
-import org.apache.helix.HelixController;
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixManager;
-import org.apache.helix.HelixManagerProperties;
-import org.apache.helix.HelixParticipant;
-import org.apache.helix.HelixRole;
-import org.apache.helix.IdealStateChangeListener;
-import org.apache.helix.InstanceConfigChangeListener;
-import org.apache.helix.InstanceType;
-import org.apache.helix.LiveInstanceChangeListener;
-import org.apache.helix.LiveInstanceInfoProvider;
-import org.apache.helix.MessageListener;
-import org.apache.helix.PreConnectCallback;
-import org.apache.helix.PropertyKey;
-import org.apache.helix.ScopedConfigChangeListener;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.api.id.ClusterId;
-import org.apache.helix.api.id.Id;
-import org.apache.helix.api.id.ParticipantId;
-import org.apache.helix.api.id.SessionId;
-import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
-import org.apache.helix.participant.StateMachineEngine;
-import org.apache.helix.store.zk.ZkHelixPropertyStore;
-import org.apache.log4j.Logger;
-
-/**
- * Adapt helix-connection to helix-manager, so we can pass to callback-handler and
- * notification-context
- */
-public class HelixConnectionAdaptor implements HelixManager {
-  private static Logger LOG = Logger.getLogger(HelixConnectionAdaptor.class);
-
-  final HelixRole _role;
-  final HelixConnection _connection;
-  final ClusterId _clusterId;
-  final Id _instanceId;
-  final InstanceType _instanceType;
-  final HelixDataAccessor _accessor;
-  final ClusterMessagingService _messagingService;
-
-  public HelixConnectionAdaptor(HelixRole role) {
-    _role = role;
-    _connection = role.getConnection();
-    _clusterId = role.getClusterId();
-    _accessor = _connection.createDataAccessor(_clusterId);
-
-    _instanceId = role.getId();
-    _instanceType = role.getType();
-    _messagingService = role.getMessagingService();
-  }
-
-  @Override
-  public void connect() throws Exception {
-    _connection.connect();
-  }
-
-  @Override
-  public boolean isConnected() {
-    return _connection.isConnected();
-  }
-
-  @Override
-  public void disconnect() {
-    _connection.disconnect();
-  }
-
-  @Override
-  public void addIdealStateChangeListener(IdealStateChangeListener listener) throws Exception {
-    _connection.addIdealStateChangeListener(_role, listener, _clusterId);
-  }
-
-  @Override
-  public void addLiveInstanceChangeListener(LiveInstanceChangeListener listener) throws Exception {
-    _connection.addLiveInstanceChangeListener(_role, listener, _clusterId);
-  }
-
-  @Override
-  public void addConfigChangeListener(ConfigChangeListener listener) throws Exception {
-    _connection.addConfigChangeListener(_role, listener, _clusterId);
-  }
-
-  @Override
-  public void addInstanceConfigChangeListener(InstanceConfigChangeListener listener)
-      throws Exception {
-    _connection.addInstanceConfigChangeListener(_role, listener, _clusterId);
-  }
-
-  @Override
-  public void addConfigChangeListener(ScopedConfigChangeListener listener, ConfigScopeProperty scope)
-      throws Exception {
-    _connection.addConfigChangeListener(_role, listener, _clusterId, scope);
-  }
-
-  @Override
-  public void addMessageListener(MessageListener listener, String instanceName) throws Exception {
-    _connection.addMessageListener(_role, listener, _clusterId, ParticipantId.from(instanceName));
-  }
-
-  @Override
-  public void addCurrentStateChangeListener(CurrentStateChangeListener listener,
-      String instanceName, String sessionId) throws Exception {
-    _connection.addCurrentStateChangeListener(_role, listener, _clusterId,
-        ParticipantId.from(instanceName), SessionId.from(sessionId));
-  }
-
-  @Override
-  public void addExternalViewChangeListener(ExternalViewChangeListener listener) throws Exception {
-    _connection.addExternalViewChangeListener(_role, listener, _clusterId);
-  }
-
-  @Override
-  public void addControllerListener(ControllerChangeListener listener) {
-    _connection.addControllerListener(_role, listener, _clusterId);
-  }
-
-  @Override
-  public boolean removeListener(PropertyKey key, Object listener) {
-    return _connection.removeListener(_role, listener, key);
-  }
-
-  @Override
-  public HelixDataAccessor getHelixDataAccessor() {
-    return _accessor;
-  }
-
-  @Override
-  public ConfigAccessor getConfigAccessor() {
-    return _connection.getConfigAccessor();
-  }
-
-  @Override
-  public String getClusterName() {
-    return _clusterId.stringify();
-  }
-
-  @Override
-  public String getInstanceName() {
-    return _instanceId.stringify();
-  }
-
-  @Override
-  public String getSessionId() {
-    return _connection.getSessionId().stringify();
-  }
-
-  @Override
-  public long getLastNotificationTime() {
-    return 0;
-  }
-
-  @Override
-  public HelixAdmin getClusterManagmentTool() {
-    return _connection.createClusterManagementTool();
-  }
-
-  @Override
-  public ZkHelixPropertyStore<ZNRecord> getHelixPropertyStore() {
-    return (ZkHelixPropertyStore<ZNRecord>) _connection.createPropertyStore(_clusterId);
-  }
-
-  @Override
-  public ClusterMessagingService getMessagingService() {
-    return _messagingService;
-  }
-
-  @Override
-  public InstanceType getInstanceType() {
-    return _instanceType;
-  }
-
-  @Override
-  public String getVersion() {
-    return _connection.getHelixVersion();
-  }
-
-  @Override
-  public HelixManagerProperties getProperties() {
-    return _connection.getHelixProperties();
-  }
-
-  @Override
-  public StateMachineEngine getStateMachineEngine() {
-    StateMachineEngine engine = null;
-    switch (_role.getType()) {
-    case PARTICIPANT:
-      HelixParticipant participant = (HelixParticipant) _role;
-      engine = participant.getStateMachineEngine();
-      break;
-    case CONTROLLER_PARTICIPANT:
-      HelixAutoController autoController = (HelixAutoController) _role;
-      engine = autoController.getStateMachineEngine();
-      break;
-    default:
-      LOG.info("helix manager type: " + _role.getType() + " does NOT have state-machine-engine");
-      break;
-    }
-
-    return engine;
-  }
-
-  @Override
-  public boolean isLeader() {
-    boolean isLeader = false;
-    switch (_role.getType()) {
-    case CONTROLLER:
-      HelixController controller = (HelixController) _role;
-      isLeader = controller.isLeader();
-      break;
-    case CONTROLLER_PARTICIPANT:
-      HelixAutoController autoController = (HelixAutoController) _role;
-      isLeader = autoController.isLeader();
-      break;
-    default:
-      LOG.info("helix manager type: " + _role.getType() + " does NOT support leadership");
-      break;
-    }
-    return isLeader;
-  }
-
-  @Override
-  public void startTimerTasks() {
-    throw new UnsupportedOperationException(
-        "HelixConnectionAdaptor does NOT support start timer tasks");
-  }
-
-  @Override
-  public void stopTimerTasks() {
-    throw new UnsupportedOperationException(
-        "HelixConnectionAdaptor does NOT support stop timer tasks");
-  }
-
-  @Override
-  public void addPreConnectCallback(PreConnectCallback callback) {
-    switch (_role.getType()) {
-    case PARTICIPANT:
-      HelixParticipant participant = (HelixParticipant) _role;
-      participant.addPreConnectCallback(callback);
-      break;
-    case CONTROLLER_PARTICIPANT:
-      HelixAutoController autoController = (HelixAutoController) _role;
-      autoController.addPreConnectCallback(callback);
-      break;
-    default:
-      LOG.info("helix manager type: " + _role.getType()
-          + " does NOT support add pre-connect callback");
-      break;
-    }
-  }
-
-  @Override
-  public void setLiveInstanceInfoProvider(LiveInstanceInfoProvider liveInstanceInfoProvider) {
-    switch (_role.getType()) {
-    case PARTICIPANT:
-      HelixParticipant participant = (HelixParticipant) _role;
-      participant.setLiveInstanceInfoProvider(liveInstanceInfoProvider);
-      break;
-    case CONTROLLER_PARTICIPANT:
-      HelixAutoController autoController = (HelixAutoController) _role;
-      autoController.setLiveInstanceInfoProvider(liveInstanceInfoProvider);
-      break;
-    default:
-      LOG.info("helix manager type: " + _role.getType()
-          + " does NOT support set additional live instance information");
-      break;
-    }
-  }
-
-  @Override
-  public void addControllerMessageListener(MessageListener listener) {
-    // TODO Auto-generated method stub
-
-  }
-
-}