helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject [48/51] [partial] [HELIX-198] Unify helix code style, rb=13710
Date Wed, 21 Aug 2013 20:44:01 GMT
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestResetPartitionState.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestResetPartitionState.java b/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestResetPartitionState.java
index 0fe4597..c8099a4 100644
--- a/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestResetPartitionState.java
+++ b/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestResetPartitionState.java
@@ -42,170 +42,159 @@ import org.testng.Assert;
 import org.testng.annotations.Test;
 
 public class TestResetPartitionState extends AdminTestBase {
-    private final static Logger LOG = Logger
-	    .getLogger(TestResetPartitionState.class);
+  private final static Logger LOG = Logger.getLogger(TestResetPartitionState.class);
 
-    String getClusterUrl(String cluster) {
-	return "http://localhost:" + ADMIN_PORT + "/clusters" + "/" + cluster;
-    }
+  String getClusterUrl(String cluster) {
+    return "http://localhost:" + ADMIN_PORT + "/clusters" + "/" + cluster;
+  }
+
+  String getInstanceUrl(String cluster, String instance) {
+    return "http://localhost:" + ADMIN_PORT + "/clusters/" + cluster + "/instances/" + instance;
+  }
+
+  String getResourceUrl(String cluster, String resourceGroup) {
+    return "http://localhost:" + ADMIN_PORT + "/clusters/" + cluster + "/resourceGroups/"
+        + resourceGroup;
+  }
+
+  AtomicInteger _errToOfflineInvoked = new AtomicInteger(0);
 
-    String getInstanceUrl(String cluster, String instance) {
-	return "http://localhost:" + ADMIN_PORT + "/clusters/" + cluster
-		+ "/instances/" + instance;
+  class ErrTransitionWithResetCnt extends ErrTransition {
+    public ErrTransitionWithResetCnt(Map<String, Set<String>> errPartitions) {
+      super(errPartitions);
     }
 
-    String getResourceUrl(String cluster, String resourceGroup) {
-	return "http://localhost:" + ADMIN_PORT + "/clusters/" + cluster
-		+ "/resourceGroups/" + resourceGroup;
+    @Override
+    public void doTransition(Message message, NotificationContext context) {
+      super.doTransition(message, context);
+      String fromState = message.getFromState();
+      String toState = message.getToState();
+      if (fromState.equals("ERROR") && toState.equals("OFFLINE")) {
+        // System.err.println("doReset() invoked");
+        _errToOfflineInvoked.incrementAndGet();
+      }
+    }
+  }
+
+  @Test()
+  public void testResetPartitionState() throws Exception {
+    String className = TestHelper.getTestClassName();
+    String methodName = TestHelper.getTestMethodName();
+    String clusterName = className + "_" + methodName;
+    final int n = 5;
+
+    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
+
+    TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
+        "localhost", // participant name prefix
+        "TestDB", // resource name prefix
+        1, // resources
+        10, // partitions per resource
+        n, // number of nodes
+        3, // replicas
+        "MasterSlave", true); // do rebalance
+
+    // start admin thread
+    // AdminThread adminThread = new AdminThread(ZK_ADDR, _port);
+    // adminThread.start();
+
+    // start controller
+    ClusterController controller = new ClusterController(clusterName, "controller_0", ZK_ADDR);
+    controller.syncStart();
+
+    Map<String, Set<String>> errPartitions = new HashMap<String, Set<String>>();
+    errPartitions.put("SLAVE-MASTER", TestHelper.setOf("TestDB0_4"));
+    errPartitions.put("OFFLINE-SLAVE", TestHelper.setOf("TestDB0_8"));
+
+    // start mock participants
+    MockParticipant[] participants = new MockParticipant[n];
+    for (int i = 0; i < n; i++) {
+      String instanceName = "localhost_" + (12918 + i);
+
+      if (i == 0) {
+        participants[i] =
+            new MockParticipant(clusterName, instanceName, ZK_ADDR,
+                new ErrTransition(errPartitions));
+      } else {
+        participants[i] = new MockParticipant(clusterName, instanceName, ZK_ADDR);
+      }
+      participants[i].syncStart();
     }
 
-    AtomicInteger _errToOfflineInvoked = new AtomicInteger(0);
-
-    class ErrTransitionWithResetCnt extends ErrTransition {
-	public ErrTransitionWithResetCnt(Map<String, Set<String>> errPartitions) {
-	    super(errPartitions);
-	}
-
-	@Override
-	public void doTransition(Message message, NotificationContext context) {
-	    super.doTransition(message, context);
-	    String fromState = message.getFromState();
-	    String toState = message.getToState();
-	    if (fromState.equals("ERROR") && toState.equals("OFFLINE")) {
-		// System.err.println("doReset() invoked");
-		_errToOfflineInvoked.incrementAndGet();
-	    }
-	}
+    // verify cluster
+    Map<String, Map<String, String>> errStateMap = new HashMap<String, Map<String, String>>();
+    errStateMap.put("TestDB0", new HashMap<String, String>());
+    errStateMap.get("TestDB0").put("TestDB0_4", "localhost_12918");
+    errStateMap.get("TestDB0").put("TestDB0_8", "localhost_12918");
+    boolean result =
+        ClusterStateVerifier
+            .verifyByZkCallback((new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+                clusterName, errStateMap)));
+    Assert.assertTrue(result, "Cluster verification fails");
+
+    // reset a non-exist partition, should throw exception
+    String hostName = "localhost_12918";
+    String instanceUrl = getInstanceUrl(clusterName, hostName);
+
+    Map<String, String> paramMap = new HashMap<String, String>();
+    paramMap.put(JsonParameters.MANAGEMENT_COMMAND, ClusterSetup.resetPartition);
+    paramMap.put(JsonParameters.PARTITION, "TestDB0_nonExist");
+    paramMap.put(JsonParameters.RESOURCE, "TestDB0");
+    LOG.info("IGNORABLE exception: test reset non-exist partition");
+    TestHelixAdminScenariosRest.assertSuccessPostOperation(instanceUrl, paramMap, true);
+
+    // reset 2 error partitions
+    errPartitions.clear();
+    participants[0].setTransition(new ErrTransitionWithResetCnt(errPartitions));
+    clearStatusUpdate(clusterName, "localhost_12918", "TestDB0", "TestDB0_4");
+    _errToOfflineInvoked.set(0);
+
+    paramMap.put(JsonParameters.PARTITION, "TestDB0_4 TestDB0_8");
+    TestHelixAdminScenariosRest.assertSuccessPostOperation(instanceUrl, paramMap, false);
+
+    for (int i = 0; i < 10; i++) {
+      Thread.sleep(400); // wait reset to be done
+      LOG.info("IGNORABLE exception: test reset non-error partition");
+      TestHelixAdminScenariosRest.assertSuccessPostOperation(instanceUrl, paramMap, true);
+
+      result =
+          ClusterStateVerifier
+              .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+                  clusterName));
+      if (result == true) {
+        break;
+      }
     }
 
-    @Test()
-    public void testResetPartitionState() throws Exception {
-	String className = TestHelper.getTestClassName();
-	String methodName = TestHelper.getTestMethodName();
-	String clusterName = className + "_" + methodName;
-	final int n = 5;
-
-	System.out.println("START " + clusterName + " at "
-		+ new Date(System.currentTimeMillis()));
-
-	TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
-		"localhost", // participant name prefix
-		"TestDB", // resource name prefix
-		1, // resources
-		10, // partitions per resource
-		n, // number of nodes
-		3, // replicas
-		"MasterSlave", true); // do rebalance
-
-	// start admin thread
-	// AdminThread adminThread = new AdminThread(ZK_ADDR, _port);
-	// adminThread.start();
-
-	// start controller
-	ClusterController controller = new ClusterController(clusterName,
-		"controller_0", ZK_ADDR);
-	controller.syncStart();
-
-	Map<String, Set<String>> errPartitions = new HashMap<String, Set<String>>();
-	errPartitions.put("SLAVE-MASTER", TestHelper.setOf("TestDB0_4"));
-	errPartitions.put("OFFLINE-SLAVE", TestHelper.setOf("TestDB0_8"));
-
-	// start mock participants
-	MockParticipant[] participants = new MockParticipant[n];
-	for (int i = 0; i < n; i++) {
-	    String instanceName = "localhost_" + (12918 + i);
-
-	    if (i == 0) {
-		participants[i] = new MockParticipant(clusterName,
-			instanceName, ZK_ADDR, new ErrTransition(errPartitions));
-	    } else {
-		participants[i] = new MockParticipant(clusterName,
-			instanceName, ZK_ADDR);
-	    }
-	    participants[i].syncStart();
-	}
-
-	// verify cluster
-	Map<String, Map<String, String>> errStateMap = new HashMap<String, Map<String, String>>();
-	errStateMap.put("TestDB0", new HashMap<String, String>());
-	errStateMap.get("TestDB0").put("TestDB0_4", "localhost_12918");
-	errStateMap.get("TestDB0").put("TestDB0_8", "localhost_12918");
-	boolean result = ClusterStateVerifier
-		.verifyByZkCallback((new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
-			ZK_ADDR, clusterName, errStateMap)));
-	Assert.assertTrue(result, "Cluster verification fails");
-
-	// reset a non-exist partition, should throw exception
-	String hostName = "localhost_12918";
-	String instanceUrl = getInstanceUrl(clusterName, hostName);
-
-	Map<String, String> paramMap = new HashMap<String, String>();
-	paramMap.put(JsonParameters.MANAGEMENT_COMMAND,
-		ClusterSetup.resetPartition);
-	paramMap.put(JsonParameters.PARTITION, "TestDB0_nonExist");
-	paramMap.put(JsonParameters.RESOURCE, "TestDB0");
-	LOG.info("IGNORABLE exception: test reset non-exist partition");
-	TestHelixAdminScenariosRest.assertSuccessPostOperation(instanceUrl,
-		paramMap, true);
-
-	// reset 2 error partitions
-	errPartitions.clear();
-	participants[0].setTransition(new ErrTransitionWithResetCnt(
-		errPartitions));
-	clearStatusUpdate(clusterName, "localhost_12918", "TestDB0",
-		"TestDB0_4");
-	_errToOfflineInvoked.set(0);
-
-	paramMap.put(JsonParameters.PARTITION, "TestDB0_4 TestDB0_8");
-	TestHelixAdminScenariosRest.assertSuccessPostOperation(instanceUrl,
-		paramMap, false);
-
-	for (int i = 0; i < 10; i++) {
-	    Thread.sleep(400); // wait reset to be done
-	    LOG.info("IGNORABLE exception: test reset non-error partition");
-	    TestHelixAdminScenariosRest.assertSuccessPostOperation(instanceUrl,
-		    paramMap, true);
-
-	    result = ClusterStateVerifier
-		    .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
-			    ZK_ADDR, clusterName));
-	    if (result == true) {
-		break;
-	    }
-	}
-	
-	Assert.assertTrue(result);
-	Assert.assertEquals(_errToOfflineInvoked.get(), 2,
-		"reset() should be invoked 2 times");
-
-	// clean up
-	// wait for all zk callbacks done
-	Thread.sleep(1000);
-	// adminThread.stop();
-	controller.syncStop();
-	for (int i = 0; i < 5; i++) {
-	    participants[i].syncStop();
-	}
-
-	System.out.println("END " + clusterName + " at "
-		+ new Date(System.currentTimeMillis()));
+    Assert.assertTrue(result);
+    Assert.assertEquals(_errToOfflineInvoked.get(), 2, "reset() should be invoked 2 times");
+
+    // clean up
+    // wait for all zk callbacks done
+    Thread.sleep(1000);
+    // adminThread.stop();
+    controller.syncStop();
+    for (int i = 0; i < 5; i++) {
+      participants[i].syncStop();
     }
 
-    private void clearStatusUpdate(String clusterName, String instance,
-	    String resource, String partition) {
-	// clear status update for error partition so verify() will not fail on
-	// old
-	// errors
-	ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName,
-		new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
-	Builder keyBuilder = accessor.keyBuilder();
+    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
+  }
 
-	LiveInstance liveInstance = accessor.getProperty(keyBuilder
-		.liveInstance(instance));
-	accessor.removeProperty(keyBuilder.stateTransitionStatus(instance,
-		liveInstance.getSessionId(), resource, partition));
+  private void clearStatusUpdate(String clusterName, String instance, String resource,
+      String partition) {
+    // clear status update for error partition so verify() will not fail on
+    // old
+    // errors
+    ZKHelixDataAccessor accessor =
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
+    Builder keyBuilder = accessor.keyBuilder();
 
-    }
+    LiveInstance liveInstance = accessor.getProperty(keyBuilder.liveInstance(instance));
+    accessor.removeProperty(keyBuilder.stateTransitionStatus(instance, liveInstance.getSessionId(),
+        resource, partition));
+
+  }
 
-    // TODO: throw exception in reset()
+  // TODO: throw exception in reset()
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestResetResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestResetResource.java b/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestResetResource.java
index bd594f8..96f4f6c 100644
--- a/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestResetResource.java
+++ b/helix-admin-webapp/src/test/java/org/apache/helix/tools/TestResetResource.java
@@ -34,41 +34,34 @@ import org.apache.helix.webapp.resources.JsonParameters;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-
-public class TestResetResource extends AdminTestBase
-{
+public class TestResetResource extends AdminTestBase {
   @Test
-  public void testResetNode() throws Exception
-  {
+  public void testResetNode() throws Exception {
     String className = TestHelper.getTestClassName();
     String methodName = TestHelper.getTestMethodName();
     String clusterName = className + "_" + methodName;
     final int n = 5;
 
-    System.out.println("START " + clusterName + " at "
-        + new Date(System.currentTimeMillis()));
+    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
 
     TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
-                            "localhost", // participant name prefix
-                            "TestDB", // resource name prefix
-                            1, // resources
-                            10, // partitions per resource
-                            n, // number of nodes
-                            3, // replicas
-                            "MasterSlave",
-                            true); // do rebalance
-    
+        "localhost", // participant name prefix
+        "TestDB", // resource name prefix
+        1, // resources
+        10, // partitions per resource
+        n, // number of nodes
+        3, // replicas
+        "MasterSlave", true); // do rebalance
+
     // start admin thread
-//    AdminThread adminThread = new AdminThread(ZK_ADDR, _port);
-//    adminThread.start();
+    // AdminThread adminThread = new AdminThread(ZK_ADDR, _port);
+    // adminThread.start();
 
     // start controller
-    ClusterController controller =
-        new ClusterController(clusterName, "controller_0", ZK_ADDR);
+    ClusterController controller = new ClusterController(clusterName, "controller_0", ZK_ADDR);
     controller.syncStart();
 
-    Map<String, Set<String>> errPartitions = new HashMap<String, Set<String>>()
-    {
+    Map<String, Set<String>> errPartitions = new HashMap<String, Set<String>>() {
       {
         put("SLAVE-MASTER", TestHelper.setOf("TestDB0_4"));
         put("OFFLINE-SLAVE", TestHelper.setOf("TestDB0_8"));
@@ -77,63 +70,57 @@ public class TestResetResource extends AdminTestBase
 
     // start mock participants
     MockParticipant[] participants = new MockParticipant[n];
-    for (int i = 0; i < n; i++)
-    {
+    for (int i = 0; i < n; i++) {
       String instanceName = "localhost_" + (12918 + i);
 
-      if (i == 0)
-      {
+      if (i == 0) {
         participants[i] =
-            new MockParticipant(clusterName,
-                                instanceName,
-                                ZK_ADDR,
-                                new ErrTransition(errPartitions));
-      }
-      else
-      {
+            new MockParticipant(clusterName, instanceName, ZK_ADDR,
+                new ErrTransition(errPartitions));
+      } else {
         participants[i] = new MockParticipant(clusterName, instanceName, ZK_ADDR);
       }
       participants[i].syncStart();
     }
 
     // verify cluster
-    Map<String, Map<String, String>> errStateMap =
-        new HashMap<String, Map<String, String>>();
+    Map<String, Map<String, String>> errStateMap = new HashMap<String, Map<String, String>>();
     errStateMap.put("TestDB0", new HashMap<String, String>());
     errStateMap.get("TestDB0").put("TestDB0_4", "localhost_12918");
     errStateMap.get("TestDB0").put("TestDB0_8", "localhost_12918");
     boolean result =
-        ClusterStateVerifier.verifyByZkCallback((new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
-                                                                                                       clusterName,
-                                                                                                       errStateMap)));
+        ClusterStateVerifier
+            .verifyByZkCallback((new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+                clusterName, errStateMap)));
     Assert.assertTrue(result, "Cluster verification fails");
-    
+
     // reset resource "TestDB0"
     participants[0].setTransition(null);
     String resourceName = "TestDB0";
-    String resourceUrl = "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/resourceGroups/" + resourceName;
+    String resourceUrl =
+        "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/resourceGroups/"
+            + resourceName;
 
     Map<String, String> paramMap = new HashMap<String, String>();
     paramMap.put(JsonParameters.MANAGEMENT_COMMAND, ClusterSetup.resetResource);
     TestHelixAdminScenariosRest.assertSuccessPostOperation(resourceUrl, paramMap, false);
 
     result =
-        ClusterStateVerifier.verifyByZkCallback((new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
-                                                                                                       clusterName)));
+        ClusterStateVerifier
+            .verifyByZkCallback((new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+                clusterName)));
     Assert.assertTrue(result, "Cluster verification fails");
-    
+
     // clean up
     // wait for all zk callbacks done
     Thread.sleep(1000);
-//    adminThread.stop();
+    // adminThread.stop();
     controller.syncStop();
-    for (int i = 0; i < 5; i++)
-    {
+    for (int i = 0; i < 5; i++) {
       participants[i].syncStop();
     }
 
-    System.out.println("END " + clusterName + " at "
-        + new Date(System.currentTimeMillis()));
+    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
 
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java
index 0bd8ef9..236f327 100644
--- a/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java
+++ b/helix-admin-webapp/src/test/java/org/apache/helix/webapp/TestClusterManagementWebapp.java
@@ -52,12 +52,9 @@ import org.testng.Assert;
 import org.testng.AssertJUnit;
 import org.testng.annotations.Test;
 
-
-public class TestClusterManagementWebapp extends AdminTestBase
-{
+public class TestClusterManagementWebapp extends AdminTestBase {
   @Test
-  public void testInvocation() throws Exception
-  {
+  public void testInvocation() throws Exception {
     verifyAddCluster();
     verifyAddStateModel();
     verifyAddHostedEntity();
@@ -75,18 +72,15 @@ public class TestClusterManagementWebapp extends AdminTestBase
   /*
    * Test case as steps
    */
-  String clusterName       = "cluster-12345";
+  String clusterName = "cluster-12345";
   String resourceGroupName = "new-entity-12345";
-  String instance1         = "test-1";
-  String statemodel        = "state_model";
-  int    instancePort      = 9999;
-  int    partitions        = 10;
-  int    replicas          = 3;
-
-  void verifyAddStateModel() throws JsonGenerationException,
-      JsonMappingException,
-      IOException
-  {
+  String instance1 = "test-1";
+  String statemodel = "state_model";
+  int instancePort = 9999;
+  int partitions = 10;
+  int replicas = 3;
+
+  void verifyAddStateModel() throws JsonGenerationException, JsonMappingException, IOException {
     String httpUrlBase =
         "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName
             + "/StateModelDefs/MasterSlave";
@@ -102,22 +96,19 @@ public class TestClusterManagementWebapp extends AdminTestBase
 
     Map<String, String> paraMap = new HashMap<String, String>();
 
-    paraMap.put(JsonParameters.MANAGEMENT_COMMAND,
-                ClusterSetup.addStateModelDef);
+    paraMap.put(JsonParameters.MANAGEMENT_COMMAND, ClusterSetup.addStateModelDef);
 
     ZNRecord r = new ZNRecord("Test");
     r.merge(zn);
     StateModelDefinition newStateModel = new StateModelDefinition(r);
 
-    httpUrlBase =
-        "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/StateModelDefs";
+    httpUrlBase = "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/StateModelDefs";
     resourceRef = new Reference(httpUrlBase);
     request = new Request(Method.POST, resourceRef);
-    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
-                          + ClusterRepresentationUtil.ObjectToJson(paraMap) + "&"
-                          + JsonParameters.NEW_STATE_MODEL_DEF + "="
-                          + ClusterRepresentationUtil.ZNRecordToJson(r),
-                      MediaType.APPLICATION_ALL);
+    request.setEntity(
+        JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap)
+            + "&" + JsonParameters.NEW_STATE_MODEL_DEF + "="
+            + ClusterRepresentationUtil.ZNRecordToJson(r), MediaType.APPLICATION_ALL);
     client = new Client(Protocol.HTTP);
     response = client.handle(request);
 
@@ -130,9 +121,7 @@ public class TestClusterManagementWebapp extends AdminTestBase
     AssertJUnit.assertTrue(sw.toString().contains("Test"));
   }
 
-  void verifyAddCluster() throws IOException,
-      InterruptedException
-  {
+  void verifyAddCluster() throws IOException, InterruptedException {
     String httpUrlBase = "http://localhost:" + ADMIN_PORT + "/clusters";
     Map<String, String> paraMap = new HashMap<String, String>();
 
@@ -143,8 +132,9 @@ public class TestClusterManagementWebapp extends AdminTestBase
 
     Request request = new Request(Method.POST, resourceRef);
 
-    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
-        + ClusterRepresentationUtil.ObjectToJson(paraMap), MediaType.APPLICATION_ALL);
+    request.setEntity(
+        JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
+        MediaType.APPLICATION_ALL);
     Client client = new Client(Protocol.HTTP);
     Response response = client.handle(request);
 
@@ -160,10 +150,7 @@ public class TestClusterManagementWebapp extends AdminTestBase
 
   }
 
-  void verifyAddHostedEntity() throws JsonGenerationException,
-      JsonMappingException,
-      IOException
-  {
+  void verifyAddHostedEntity() throws JsonGenerationException, JsonMappingException, IOException {
     String httpUrlBase =
         "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/resourceGroups";
     Map<String, String> paraMap = new HashMap<String, String>();
@@ -177,8 +164,9 @@ public class TestClusterManagementWebapp extends AdminTestBase
 
     Request request = new Request(Method.POST, resourceRef);
 
-    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
-        + ClusterRepresentationUtil.ObjectToJson(paraMap), MediaType.APPLICATION_ALL);
+    request.setEntity(
+        JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
+        MediaType.APPLICATION_ALL);
     Client client = new Client(Protocol.HTTP);
     Response response = client.handle(request);
 
@@ -209,10 +197,7 @@ public class TestClusterManagementWebapp extends AdminTestBase
     // System.out.println(sw.toString());
   }
 
-  void verifyAddInstance() throws JsonGenerationException,
-      JsonMappingException,
-      IOException
-  {
+  void verifyAddInstance() throws JsonGenerationException, JsonMappingException, IOException {
     String httpUrlBase =
         "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/instances";
     Map<String, String> paraMap = new HashMap<String, String>();
@@ -224,8 +209,9 @@ public class TestClusterManagementWebapp extends AdminTestBase
 
     Request request = new Request(Method.POST, resourceRef);
 
-    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
-        + ClusterRepresentationUtil.ObjectToJson(paraMap), MediaType.APPLICATION_ALL);
+    request.setEntity(
+        JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
+        MediaType.APPLICATION_ALL);
     Client client = new Client(Protocol.HTTP);
     Response response = client.handle(request);
 
@@ -237,8 +223,7 @@ public class TestClusterManagementWebapp extends AdminTestBase
 
     ObjectMapper mapper = new ObjectMapper();
 
-    TypeReference<ArrayList<ZNRecord>> typeRef = new TypeReference<ArrayList<ZNRecord>>()
-    {
+    TypeReference<ArrayList<ZNRecord>> typeRef = new TypeReference<ArrayList<ZNRecord>>() {
     };
     List<ZNRecord> znList = mapper.readValue(new StringReader(sw.toString()), typeRef);
     AssertJUnit.assertTrue(znList.get(0).getId().equals(instance1 + "_" + instancePort));
@@ -247,18 +232,16 @@ public class TestClusterManagementWebapp extends AdminTestBase
     paraMap.clear();
     paraMap.put(JsonParameters.MANAGEMENT_COMMAND, ClusterSetup.addInstance);
 
-    String[] instances = { "test2", "test3", "test4", "test5" };
+    String[] instances = {
+        "test2", "test3", "test4", "test5"
+    };
 
     String instanceNames = "";
     boolean first = true;
-    for (String instance : instances)
-    {
-      if (first == true)
-      {
+    for (String instance : instances) {
+      if (first == true) {
         first = false;
-      }
-      else
-      {
+      } else {
         instanceNames += ";";
       }
       instanceNames += (instance + ":" + instancePort);
@@ -267,8 +250,9 @@ public class TestClusterManagementWebapp extends AdminTestBase
 
     request = new Request(Method.POST, resourceRef);
 
-    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
-        + ClusterRepresentationUtil.ObjectToJson(paraMap), MediaType.APPLICATION_ALL);
+    request.setEntity(
+        JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
+        MediaType.APPLICATION_ALL);
     client = new Client(Protocol.HTTP);
     response = client.handle(request);
 
@@ -282,14 +266,11 @@ public class TestClusterManagementWebapp extends AdminTestBase
 
     znList = mapper.readValue(new StringReader(sw.toString()), typeRef);
 
-    for (String instance : instances)
-    {
+    for (String instance : instances) {
       boolean found = false;
-      for (ZNRecord r : znList)
-      {
+      for (ZNRecord r : znList) {
         String instanceId = instance + "_" + instancePort;
-        if (r.getId().equals(instanceId))
-        {
+        if (r.getId().equals(instanceId)) {
           found = true;
           break;
         }
@@ -298,10 +279,7 @@ public class TestClusterManagementWebapp extends AdminTestBase
     }
   }
 
-  void verifyRebalance() throws JsonGenerationException,
-      JsonMappingException,
-      IOException
-  {
+  void verifyRebalance() throws JsonGenerationException, JsonMappingException, IOException {
     String httpUrlBase =
         "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/resourceGroups/"
             + resourceGroupName + "/idealState";
@@ -314,8 +292,9 @@ public class TestClusterManagementWebapp extends AdminTestBase
 
     Request request = new Request(Method.POST, resourceRef);
 
-    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
-        + ClusterRepresentationUtil.ObjectToJson(paraMap), MediaType.APPLICATION_ALL);
+    request.setEntity(
+        JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
+        MediaType.APPLICATION_ALL);
     Client client = new Client(Protocol.HTTP);
     Response response = client.handle(request);
 
@@ -328,8 +307,7 @@ public class TestClusterManagementWebapp extends AdminTestBase
     ObjectMapper mapper = new ObjectMapper();
     ZNRecord r = mapper.readValue(new StringReader(sw.toString()), ZNRecord.class);
 
-    for (int i = 0; i < partitions; i++)
-    {
+    for (int i = 0; i < partitions; i++) {
       String partitionName = resourceGroupName + "_" + i;
       assert (r.getMapField(partitionName).size() == replicas);
     }
@@ -347,13 +325,10 @@ public class TestClusterManagementWebapp extends AdminTestBase
 
   }
 
-  void verifyEnableInstance() throws JsonGenerationException,
-      JsonMappingException,
-      IOException
-  {
+  void verifyEnableInstance() throws JsonGenerationException, JsonMappingException, IOException {
     String httpUrlBase =
-        "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/instances/"
-            + instance1 + "_" + instancePort;
+        "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/instances/" + instance1
+            + "_" + instancePort;
     Map<String, String> paraMap = new HashMap<String, String>();
     // Add 1 instance
     paraMap.put(JsonParameters.ENABLED, "" + false);
@@ -363,8 +338,9 @@ public class TestClusterManagementWebapp extends AdminTestBase
 
     Request request = new Request(Method.POST, resourceRef);
 
-    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
-        + ClusterRepresentationUtil.ObjectToJson(paraMap), MediaType.APPLICATION_ALL);
+    request.setEntity(
+        JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
+        MediaType.APPLICATION_ALL);
     Client client = new Client(Protocol.HTTP);
     Response response = client.handle(request);
 
@@ -377,14 +353,15 @@ public class TestClusterManagementWebapp extends AdminTestBase
     ObjectMapper mapper = new ObjectMapper();
     ZNRecord r = mapper.readValue(new StringReader(sw.toString()), ZNRecord.class);
     AssertJUnit.assertTrue(r.getSimpleField(InstanceConfigProperty.HELIX_ENABLED.toString())
-                            .equals("" + false));
+        .equals("" + false));
 
     // Then enable it
     paraMap.put(JsonParameters.ENABLED, "" + true);
     request = new Request(Method.POST, resourceRef);
 
-    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
-        + ClusterRepresentationUtil.ObjectToJson(paraMap), MediaType.APPLICATION_ALL);
+    request.setEntity(
+        JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap),
+        MediaType.APPLICATION_ALL);
     client = new Client(Protocol.HTTP);
     response = client.handle(request);
 
@@ -397,11 +374,10 @@ public class TestClusterManagementWebapp extends AdminTestBase
     mapper = new ObjectMapper();
     r = mapper.readValue(new StringReader(sw.toString()), ZNRecord.class);
     AssertJUnit.assertTrue(r.getSimpleField(InstanceConfigProperty.HELIX_ENABLED.toString())
-                            .equals("" + true));
+        .equals("" + true));
   }
 
-  void verifyAlterIdealState() throws IOException
-  {
+  void verifyAlterIdealState() throws IOException {
     String httpUrlBase =
         "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/resourceGroups/"
             + resourceGroupName + "/idealState";
@@ -430,11 +406,10 @@ public class TestClusterManagementWebapp extends AdminTestBase
     resourceRef = new Reference(httpUrlBase);
 
     request = new Request(Method.POST, resourceRef);
-    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
-                          + ClusterRepresentationUtil.ObjectToJson(paraMap) + "&"
-                          + JsonParameters.NEW_IDEAL_STATE + "="
-                          + ClusterRepresentationUtil.ZNRecordToJson(r),
-                      MediaType.APPLICATION_ALL);
+    request.setEntity(
+        JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paraMap)
+            + "&" + JsonParameters.NEW_IDEAL_STATE + "="
+            + ClusterRepresentationUtil.ZNRecordToJson(r), MediaType.APPLICATION_ALL);
     client = new Client(Protocol.HTTP);
     response = client.handle(request);
 
@@ -448,15 +423,13 @@ public class TestClusterManagementWebapp extends AdminTestBase
     ZNRecord r2 = mapper.readValue(new StringReader(sw.toString()), ZNRecord.class);
     AssertJUnit.assertTrue(!r2.getMapFields().containsKey(partitionName));
 
-    for (String key : r2.getMapFields().keySet())
-    {
+    for (String key : r2.getMapFields().keySet()) {
       AssertJUnit.assertTrue(r.getMapFields().containsKey(key));
     }
   }
 
   // verify get/post configs in different scopes
-  void verifyConfigAccessor() throws Exception
-  {
+  void verifyConfigAccessor() throws Exception {
     ObjectMapper mapper = new ObjectMapper();
     Client client = new Client(Protocol.HTTP);
 
@@ -475,8 +448,8 @@ public class TestClusterManagementWebapp extends AdminTestBase
     // set/get participant scope configs
     String participantName = "test2_9999";
     url =
-        "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName
-            + "/configs/participant/" + participantName;
+        "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/configs/participant/"
+            + participantName;
 
     postConfig(client, url, mapper, ClusterSetup.setConfig, "key3=value3,key4=value4");
 
@@ -514,20 +487,17 @@ public class TestClusterManagementWebapp extends AdminTestBase
     record = get(client, url, mapper);
     Assert.assertEquals(record.getListFields().size(), 1);
     Assert.assertTrue(record.getListFields().containsKey("scopes"));
-    Assert.assertTrue(contains(record.getListField("scopes"),
-                               "CLUSTER",
-                               "PARTICIPANT",
-                               "RESOURCE",
-                               "PARTITION"));
-
-//    url = "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/configs/cluster";
-//    record = get(client, url, mapper);
-//    Assert.assertEquals(record.getListFields().size(), 1);
-//    Assert.assertTrue(record.getListFields().containsKey("CLUSTER"));
-//    Assert.assertTrue(contains(record.getListField("CLUSTER"), clusterName), "record: " + record);
+    Assert.assertTrue(contains(record.getListField("scopes"), "CLUSTER", "PARTICIPANT", "RESOURCE",
+        "PARTITION"));
 
-    url =
-        "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/configs/participant";
+    // url = "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/configs/cluster";
+    // record = get(client, url, mapper);
+    // Assert.assertEquals(record.getListFields().size(), 1);
+    // Assert.assertTrue(record.getListFields().containsKey("CLUSTER"));
+    // Assert.assertTrue(contains(record.getListField("CLUSTER"), clusterName), "record: " +
+    // record);
+
+    url = "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/configs/participant";
     record = get(client, url, mapper);
     Assert.assertTrue(record.getListFields().containsKey("PARTICIPANT"));
     Assert.assertTrue(contains(record.getListField("PARTICIPANT"), participantName));
@@ -548,8 +518,7 @@ public class TestClusterManagementWebapp extends AdminTestBase
 
   }
 
-  private ZNRecord get(Client client, String url, ObjectMapper mapper) throws Exception
-  {
+  private ZNRecord get(Client client, String url, ObjectMapper mapper) throws Exception {
     Request request = new Request(Method.GET, new Reference(url));
     Response response = client.handle(request);
     Representation result = response.getEntity();
@@ -563,20 +532,17 @@ public class TestClusterManagementWebapp extends AdminTestBase
     return record;
   }
 
-  private void postConfig(Client client,
-                          String url,
-                          ObjectMapper mapper,
-                          String command,
-                          String configs) throws Exception
-  {
+  private void postConfig(Client client, String url, ObjectMapper mapper, String command,
+      String configs) throws Exception {
     Map<String, String> params = new HashMap<String, String>();
 
     params.put(JsonParameters.MANAGEMENT_COMMAND, command);
     params.put(JsonParameters.CONFIGS, configs);
 
     Request request = new Request(Method.POST, new Reference(url));
-    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
-        + ClusterRepresentationUtil.ObjectToJson(params), MediaType.APPLICATION_ALL);
+    request.setEntity(
+        JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(params),
+        MediaType.APPLICATION_ALL);
 
     Response response = client.handle(request);
     Representation result = response.getEntity();
@@ -587,8 +553,7 @@ public class TestClusterManagementWebapp extends AdminTestBase
     Assert.assertTrue(responseStr.toLowerCase().indexOf("exception") == -1);
   }
 
-  void verifyEnableCluster() throws Exception
-  {
+  void verifyEnableCluster() throws Exception {
     System.out.println("START: verifyEnableCluster()");
     String httpUrlBase =
         "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/Controller";
@@ -601,8 +566,9 @@ public class TestClusterManagementWebapp extends AdminTestBase
 
     Request request = new Request(Method.POST, resourceRef);
 
-    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
-        + ClusterRepresentationUtil.ObjectToJson(paramMap), MediaType.APPLICATION_ALL);
+    request.setEntity(
+        JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paramMap),
+        MediaType.APPLICATION_ALL);
     Client client = new Client(Protocol.HTTP);
     Response response = client.handle(request);
 
@@ -622,8 +588,9 @@ public class TestClusterManagementWebapp extends AdminTestBase
     paramMap.put(JsonParameters.ENABLED, "" + true);
     request = new Request(Method.POST, resourceRef);
 
-    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
-        + ClusterRepresentationUtil.ObjectToJson(paramMap), MediaType.APPLICATION_ALL);
+    request.setEntity(
+        JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paramMap),
+        MediaType.APPLICATION_ALL);
     client = new Client(Protocol.HTTP);
     response = client.handle(request);
 
@@ -640,12 +607,9 @@ public class TestClusterManagementWebapp extends AdminTestBase
     System.out.println("END: verifyEnableCluster()");
   }
 
-  private boolean contains(List<String> list, String... items)
-  {
-    for (String item : items)
-    {
-      if (!list.contains(item))
-      {
+  private boolean contains(List<String> list, String... items) {
+    for (String item : items) {
+      if (!list.contains(item)) {
         return false;
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModel.java
----------------------------------------------------------------------
diff --git a/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModel.java b/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModel.java
index 3e4626c..313f430 100644
--- a/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModel.java
+++ b/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModel.java
@@ -39,55 +39,55 @@ import org.apache.helix.participant.statemachine.Transition;
 import org.apache.log4j.Logger;
 
 @StateModelInfo(initialState = "OFFLINE", states = {})
-public class AgentStateModel extends StateModel
-{
+public class AgentStateModel extends StateModel {
   private static final Logger _logger = Logger.getLogger(AgentStateModel.class);
   private static Pattern pattern = Pattern.compile("(\\{.+?\\})");
 
   private static String buildKey(String fromState, String toState, CommandAttribute attribute) {
     return fromState + "-" + toState + "." + attribute.getName();
   }
-  
+
   private static String instantiateByMessage(String string, Message message) {
     Matcher matcher = pattern.matcher(string);
     String result = string;
     while (matcher.find()) {
       String var = matcher.group();
-      result = result.replace(var, message.getAttribute(Message.Attributes.valueOf(var.substring(1, var.length() - 1))));
+      result =
+          result.replace(var,
+              message.getAttribute(Message.Attributes.valueOf(var.substring(1, var.length() - 1))));
     }
 
     return result;
   }
-    
+
   @Transition(to = "*", from = "*")
-  public void genericStateTransitionHandler(Message message,
-      NotificationContext context) throws Exception
-  {
+  public void genericStateTransitionHandler(Message message, NotificationContext context)
+      throws Exception {
     // first try get command from message
     String cmd = message.getRecord().getSimpleField(CommandAttribute.COMMAND.getName());
     String workingDir = message.getRecord().getSimpleField(CommandAttribute.WORKING_DIR.getName());
     String timeout = message.getRecord().getSimpleField(CommandAttribute.TIMEOUT.getName());
     String pidFile = message.getRecord().getSimpleField(CommandAttribute.PID_FILE.getName());
-    
+
     HelixManager manager = context.getManager();
     String clusterName = manager.getClusterName();
     String fromState = message.getFromState();
     String toState = message.getToState();
-    
+
     // construct keys for command-config
     String cmdKey = buildKey(fromState, toState, CommandAttribute.COMMAND);
     String workingDirKey = buildKey(fromState, toState, CommandAttribute.WORKING_DIR);
     String timeoutKey = buildKey(fromState, toState, CommandAttribute.TIMEOUT);
     String pidFileKey = buildKey(fromState, toState, CommandAttribute.PID_FILE);
     List<String> cmdConfigKeys = Arrays.asList(cmdKey, workingDirKey, timeoutKey, pidFileKey);
-    
+
     // read command from resource-scope configures
     if (cmd == null) {
-      HelixConfigScope resourceScope = new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE)
-                                          .forCluster(clusterName)
-                                          .forResource(message.getResourceName())
-                                          .build();
-      Map<String, String> cmdKeyValueMap = manager.getConfigAccessor().get(resourceScope, cmdConfigKeys);
+      HelixConfigScope resourceScope =
+          new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE).forCluster(clusterName)
+              .forResource(message.getResourceName()).build();
+      Map<String, String> cmdKeyValueMap =
+          manager.getConfigAccessor().get(resourceScope, cmdConfigKeys);
       if (cmdKeyValueMap != null) {
         cmd = cmdKeyValueMap.get(cmdKey);
         workingDir = cmdKeyValueMap.get(workingDirKey);
@@ -95,14 +95,14 @@ public class AgentStateModel extends StateModel
         pidFile = cmdKeyValueMap.get(pidFileKey);
       }
     }
-    
+
     // if resource-scope doesn't contain command, fall back to cluster-scope configures
     if (cmd == null) {
-      HelixConfigScope clusterScope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER)
-                                          .forCluster(clusterName)
-                                          .build();
-      Map<String, String> cmdKeyValueMap = manager.getConfigAccessor().get(clusterScope, cmdConfigKeys);
-      
+      HelixConfigScope clusterScope =
+          new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(clusterName).build();
+      Map<String, String> cmdKeyValueMap =
+          manager.getConfigAccessor().get(clusterScope, cmdConfigKeys);
+
       if (cmdKeyValueMap != null) {
         cmd = cmdKeyValueMap.get(cmdKey);
         workingDir = cmdKeyValueMap.get(workingDirKey);
@@ -111,24 +111,23 @@ public class AgentStateModel extends StateModel
       }
     }
 
-    if (cmd == null)
-    {
-      throw new Exception("Unable to find command for transition from:"
-          + message.getFromState() + " to:" + message.getToState());
+    if (cmd == null) {
+      throw new Exception("Unable to find command for transition from:" + message.getFromState()
+          + " to:" + message.getToState());
     }
-    _logger.info("Executing command: " + cmd + ", using workingDir: " + workingDir
-        + ", timeout: " + timeout + ", on " + manager.getInstanceName());
-    
+    _logger.info("Executing command: " + cmd + ", using workingDir: " + workingDir + ", timeout: "
+        + timeout + ", on " + manager.getInstanceName());
+
     // skip nop command
     if (cmd.equals(CommandAttribute.NOP.getName())) {
       return;
     }
-    
+
     // split the cmd to actual cmd and args[]
     String cmdSplits[] = cmd.trim().split("\\s+");
     String cmdValue = cmdSplits[0];
     String args[] = Arrays.copyOfRange(cmdSplits, 1, cmdSplits.length);
-    
+
     // get the command-execution timeout
     long timeoutValue = 0; // 0 means wait for ever
     if (timeout != null) {
@@ -138,26 +137,26 @@ public class AgentStateModel extends StateModel
         // OK to use 0
       }
     }
-    ExternalCommand externalCmd = ExternalCommand.executeWithTimeout(new File(workingDir), 
-        cmdValue, timeoutValue, args);
-        
+    ExternalCommand externalCmd =
+        ExternalCommand.executeWithTimeout(new File(workingDir), cmdValue, timeoutValue, args);
+
     int exitValue = externalCmd.exitValue();
-    
+
     // debug
-//    System.out.println("command: " + cmd + ", exitValue: " + exitValue
-//        + " output:\n" + externalCmd.getStringOutput());
-    
+    // System.out.println("command: " + cmd + ", exitValue: " + exitValue
+    // + " output:\n" + externalCmd.getStringOutput());
+
     if (_logger.isDebugEnabled()) {
-      _logger.debug("command: " + cmd + ", exitValue: " + exitValue
-        + " output:\n" + externalCmd.getStringOutput());
+      _logger.debug("command: " + cmd + ", exitValue: " + exitValue + " output:\n"
+          + externalCmd.getStringOutput());
     }
-    
+
     // monitor pid if pidFile exists
     if (pidFile == null) {
       // no pid to monitor
       return;
     }
-    
+
     String pidFileValue = instantiateByMessage(pidFile, message);
     String pid = SystemUtil.getPidFromFile(new File(pidFileValue));
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModelFactory.java
----------------------------------------------------------------------
diff --git a/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModelFactory.java b/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModelFactory.java
index 99ff884..a0e00a3 100644
--- a/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModelFactory.java
+++ b/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModelFactory.java
@@ -21,11 +21,10 @@ package org.apache.helix.agent;
 
 import org.apache.helix.participant.statemachine.StateModelFactory;
 
-public class AgentStateModelFactory extends StateModelFactory<AgentStateModel>{
-  
+public class AgentStateModelFactory extends StateModelFactory<AgentStateModel> {
+
   @Override
-  public AgentStateModel createNewStateModel(String partitionKey)
-  {
+  public AgentStateModel createNewStateModel(String partitionKey) {
     AgentStateModel model = new AgentStateModel();
     return model;
   }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-agent/src/main/java/org/apache/helix/agent/CommandAttribute.java
----------------------------------------------------------------------
diff --git a/helix-agent/src/main/java/org/apache/helix/agent/CommandAttribute.java b/helix-agent/src/main/java/org/apache/helix/agent/CommandAttribute.java
index 3f09123..4420dce 100644
--- a/helix-agent/src/main/java/org/apache/helix/agent/CommandAttribute.java
+++ b/helix-agent/src/main/java/org/apache/helix/agent/CommandAttribute.java
@@ -23,12 +23,12 @@ import java.util.HashMap;
 import java.util.Map;
 
 public enum CommandAttribute {
-  COMMAND ("command"),
-  WORKING_DIR ("command.workingDir"),
-  TIMEOUT ("command.timeout"),
+  COMMAND("command"),
+  WORKING_DIR("command.workingDir"),
+  TIMEOUT("command.timeout"),
   PID_FILE("command.pidFile"),
-  NOP ("nop");
-  
+  NOP("nop");
+
   // map from name to value
   private static final Map<String, CommandAttribute> map = new HashMap<String, CommandAttribute>();
   static {
@@ -36,9 +36,9 @@ public enum CommandAttribute {
       map.put(attr.getName(), attr);
     }
   }
-  
+
   private final String _name;
-  
+
   private CommandAttribute(String name) {
     _name = name;
   }
@@ -46,7 +46,7 @@ public enum CommandAttribute {
   public String getName() {
     return _name;
   }
-  
+
   public static CommandAttribute getCommandAttributeByName(String name) {
     return map.get(name);
   }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-agent/src/main/java/org/apache/helix/agent/CommandConfig.java
----------------------------------------------------------------------
diff --git a/helix-agent/src/main/java/org/apache/helix/agent/CommandConfig.java b/helix-agent/src/main/java/org/apache/helix/agent/CommandConfig.java
index 4f700c0..bf3945d 100644
--- a/helix-agent/src/main/java/org/apache/helix/agent/CommandConfig.java
+++ b/helix-agent/src/main/java/org/apache/helix/agent/CommandConfig.java
@@ -30,13 +30,13 @@ public class CommandConfig {
   private final String _timeout;
   private final String _pidFile;
 
-  public CommandConfig(String fromState, String toState, String command,
-      String workingDir, String timeout, String pidFile) {
+  public CommandConfig(String fromState, String toState, String command, String workingDir,
+      String timeout, String pidFile) {
     if (command == null) {
       throw new IllegalArgumentException("command is null");
-      
+
     }
-    
+
     _fromState = fromState;
     _toState = toState;
     _command = command;
@@ -45,7 +45,7 @@ public class CommandConfig {
     _pidFile = pidFile;
 
   }
-  
+
   private String buildKey(String fromState, String toState, CommandAttribute attribute) {
     return fromState + "-" + toState + "." + attribute.getName();
   }
@@ -57,21 +57,20 @@ public class CommandConfig {
       if (_workingDir != null) {
         map.put(buildKey(_fromState, _toState, CommandAttribute.WORKING_DIR), _workingDir);
       }
-      
+
       if (_timeout != null) {
         map.put(buildKey(_fromState, _toState, CommandAttribute.TIMEOUT), _timeout);
       }
-      
+
       if (_pidFile != null) {
         map.put(buildKey(_fromState, _toState, CommandAttribute.PID_FILE), _pidFile);
       }
-    }  
+    }
     return map;
   }
-  
+
   /**
    * builder for command-config
-   *
    */
   public static class Builder {
     private String _fromState;
@@ -80,36 +79,35 @@ public class CommandConfig {
     private String _workingDir;
     private String _timeout;
     private String _pidFile;
-    
+
     public Builder setTransition(String fromState, String toState) {
       _fromState = fromState;
       _toState = toState;
       return this;
     }
-    
+
     public Builder setCommand(String command) {
       _command = command;
       return this;
     }
-    
+
     public Builder setCommandWorkingDir(String workingDir) {
       _workingDir = workingDir;
       return this;
     }
-    
+
     public Builder setCommandTimeout(String timeout) {
       _timeout = timeout;
       return this;
     }
-    
+
     public Builder setPidFile(String pidFile) {
       _pidFile = pidFile;
       return this;
     }
-    
+
     public CommandConfig build() {
-      return new CommandConfig(_fromState, _toState, _command, _workingDir, 
-          _timeout, _pidFile);
+      return new CommandConfig(_fromState, _toState, _command, _workingDir, _timeout, _pidFile);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-agent/src/main/java/org/apache/helix/agent/HelixAgentMain.java
----------------------------------------------------------------------
diff --git a/helix-agent/src/main/java/org/apache/helix/agent/HelixAgentMain.java b/helix-agent/src/main/java/org/apache/helix/agent/HelixAgentMain.java
index 6568d73..c900546 100644
--- a/helix-agent/src/main/java/org/apache/helix/agent/HelixAgentMain.java
+++ b/helix-agent/src/main/java/org/apache/helix/agent/HelixAgentMain.java
@@ -46,34 +46,30 @@ public class HelixAgentMain {
 
   // hack: OptionalBuilder is not thread safe
   @SuppressWarnings("static-access")
-  synchronized private static Options constructCommandLineOptions()
-  {
-    Option helpOption = OptionBuilder.withLongOpt(help)
-        .withDescription("Prints command-line options info").create();
-
-    Option zkAddrOption = OptionBuilder.withLongOpt(zkAddr)
-        .hasArgs(1)
-        .isRequired(true)
-        .withArgName("ZookeeperServerAddress(Required)")
-        .withDescription("Provide zookeeper address").create();
-
-    Option clusterOption = OptionBuilder.withLongOpt(cluster)
-        .hasArgs(1)
-        .isRequired(true)
-        .withArgName("Cluster name (Required)")
-        .withDescription("Provide cluster name").create();
-
-    Option instanceNameOption = OptionBuilder.withLongOpt(instanceName)
-        .hasArgs(1)
-        .isRequired(true)
-        .withArgName("Helix agent name (Required)")
-        .withDescription("Provide Helix agent name").create();
-
-    Option stateModelOption = OptionBuilder.withLongOpt(stateModel)
-        .hasArgs(1)
-        .isRequired(true)
-        .withArgName("State model name (Required)")
-        .withDescription("Provide state model name").create();
+  synchronized private static Options constructCommandLineOptions() {
+    Option helpOption =
+        OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info")
+            .create();
+
+    Option zkAddrOption =
+        OptionBuilder.withLongOpt(zkAddr).hasArgs(1).isRequired(true)
+            .withArgName("ZookeeperServerAddress(Required)")
+            .withDescription("Provide zookeeper address").create();
+
+    Option clusterOption =
+        OptionBuilder.withLongOpt(cluster).hasArgs(1).isRequired(true)
+            .withArgName("Cluster name (Required)").withDescription("Provide cluster name")
+            .create();
+
+    Option instanceNameOption =
+        OptionBuilder.withLongOpt(instanceName).hasArgs(1).isRequired(true)
+            .withArgName("Helix agent name (Required)").withDescription("Provide Helix agent name")
+            .create();
+
+    Option stateModelOption =
+        OptionBuilder.withLongOpt(stateModel).hasArgs(1).isRequired(true)
+            .withArgName("State model name (Required)").withDescription("Provide state model name")
+            .create();
 
     Options options = new Options();
     options.addOption(helpOption);
@@ -85,23 +81,19 @@ public class HelixAgentMain {
     return options;
   }
 
-  public static void printUsage(Options cliOptions)
-  {
+  public static void printUsage(Options cliOptions) {
     HelpFormatter helpFormatter = new HelpFormatter();
     helpFormatter.setWidth(1000);
     helpFormatter.printHelp("java " + HelixAgentMain.class.getName(), cliOptions);
   }
 
-  public static CommandLine processCommandLineArgs(String[] cliArgs) throws Exception
-  {
+  public static CommandLine processCommandLineArgs(String[] cliArgs) throws Exception {
     CommandLineParser cliParser = new GnuParser();
     Options cliOptions = constructCommandLineOptions();
 
-    try
-    {
+    try {
       return cliParser.parse(cliOptions, cliArgs);
-    } catch (ParseException pe)
-    {
+    } catch (ParseException pe) {
       LOG.error("fail to parse command-line options. cliArgs: " + Arrays.toString(cliArgs), pe);
       printUsage(cliOptions);
       System.exit(1);
@@ -110,21 +102,18 @@ public class HelixAgentMain {
   }
 
   // NOT working for kill -9, working for kill -2/-15
-  static class HelixAgentShutdownHook extends Thread
-  {
+  static class HelixAgentShutdownHook extends Thread {
     final HelixManager _manager;
 
-    HelixAgentShutdownHook(HelixManager manager)
-    {
+    HelixAgentShutdownHook(HelixManager manager) {
       _manager = manager;
     }
 
     @Override
-    public void run()
-    {
+    public void run() {
       LOG.info("HelixAgentShutdownHook invoked. agent: " + _manager.getInstanceName());
       if (_manager != null && _manager.isConnected())
-      _manager.disconnect();
+        _manager.disconnect();
     }
   }
 
@@ -135,9 +124,9 @@ public class HelixAgentMain {
     String instance = cmd.getOptionValue(instanceName);
     String stateModelName = cmd.getOptionValue(stateModel);
 
-    HelixManager manager = new ZKHelixManager(clusterName, 
-        instance, InstanceType.PARTICIPANT, zkAddress);
-    
+    HelixManager manager =
+        new ZKHelixManager(clusterName, instance, InstanceType.PARTICIPANT, zkAddress);
+
     StateMachineEngine stateMach = manager.getStateMachineEngine();
     stateMach.registerStateModelFactory(stateModelName, new AgentStateModelFactory());
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-agent/src/main/java/org/apache/helix/agent/ProcessMonitorThread.java
----------------------------------------------------------------------
diff --git a/helix-agent/src/main/java/org/apache/helix/agent/ProcessMonitorThread.java b/helix-agent/src/main/java/org/apache/helix/agent/ProcessMonitorThread.java
index 6058b55..e1a3d72 100644
--- a/helix-agent/src/main/java/org/apache/helix/agent/ProcessMonitorThread.java
+++ b/helix-agent/src/main/java/org/apache/helix/agent/ProcessMonitorThread.java
@@ -27,22 +27,21 @@ import org.apache.log4j.Logger;
  */
 
 /**
- * thread for monitoring a pid 
- *
+ * thread for monitoring a pid
  */
 public class ProcessMonitorThread extends Thread {
   private static final Logger LOG = Logger.getLogger(ProcessMonitorThread.class);
-  private static final int MONITOR_PERIOD_BASE = 1000;  // 1 second
+  private static final int MONITOR_PERIOD_BASE = 1000; // 1 second
 
   private final String _pid;
-  
+
   public ProcessMonitorThread(String pid) {
     _pid = pid;
   }
-  
+
   @Override
   public void run() {
-    
+
     // monitor pid
     try {
       ProcessStateCode processState = SystemUtil.getProcessState(_pid);
@@ -51,13 +50,14 @@ public class ProcessMonitorThread extends Thread {
           LOG.error("process: " + _pid + " is in zombie state");
           break;
         }
-        TimeUnit.MILLISECONDS.sleep(new Random().nextInt(MONITOR_PERIOD_BASE) + MONITOR_PERIOD_BASE);
+        TimeUnit.MILLISECONDS
+            .sleep(new Random().nextInt(MONITOR_PERIOD_BASE) + MONITOR_PERIOD_BASE);
         processState = SystemUtil.getProcessState(_pid);
       }
     } catch (Exception e) {
       LOG.error("fail to monitor process: " + _pid, e);
     }
-    
+
     // TODO need to find the exit value of pid and kill the pid on timeout
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-agent/src/main/java/org/apache/helix/agent/SystemUtil.java
----------------------------------------------------------------------
diff --git a/helix-agent/src/main/java/org/apache/helix/agent/SystemUtil.java b/helix-agent/src/main/java/org/apache/helix/agent/SystemUtil.java
index 81e6056..db92ac8 100644
--- a/helix-agent/src/main/java/org/apache/helix/agent/SystemUtil.java
+++ b/helix-agent/src/main/java/org/apache/helix/agent/SystemUtil.java
@@ -35,32 +35,33 @@ public class SystemUtil {
    * PROCESS STATE CODES
    */
   public static enum ProcessStateCode {
-    // Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") 
-    //   will display to describe the state of a process.
-    D ("Uninterruptible sleep (usually IO)"),
-    R ("Running or runnable (on run queue)"),
-    S ("Interruptible sleep (waiting for an event to complete)"),
-    T ("Stopped, either by a job control signal or because it is being traced."),
-    W ("paging (not valid since the 2.6.xx kernel)"),
-    X ("dead (should never be seen)"),
-    Z ("Defunct (\"zombie\") process, terminated but not reaped by its parent.");
+    // Here are the different values that the s, stat and state output specifiers (header "STAT" or
+    // "S")
+    // will display to describe the state of a process.
+    D("Uninterruptible sleep (usually IO)"),
+    R("Running or runnable (on run queue)"),
+    S("Interruptible sleep (waiting for an event to complete)"),
+    T("Stopped, either by a job control signal or because it is being traced."),
+    W("paging (not valid since the 2.6.xx kernel)"),
+    X("dead (should never be seen)"),
+    Z("Defunct (\"zombie\") process, terminated but not reaped by its parent.");
 
     private final String _description;
-        
+
     private ProcessStateCode(String description) {
       _description = description;
     }
-    
+
     public String getDescription() {
       return _description;
     }
   }
-  
+
   public static ProcessStateCode getProcessState(String processId) throws Exception {
     if (OS_NAME.equals("Mac OS X") || OS_NAME.equals("Linux")) {
       ExternalCommand cmd = ExternalCommand.start("ps", processId);
       cmd.waitFor();
-      
+
       // split by new lines
       // should return 2 lines for an existing process, or 1 line for a non-existing process
       String lines[] = cmd.getStringOutput().split("[\\r\\n]+");
@@ -68,12 +69,12 @@ public class SystemUtil {
         LOG.info("process: " + processId + " not exist");
         return null;
       }
-      
+
       // split by whitespace, 1st line is attributes, 2nd line is actual values
       // should be parallel arrays
       String attributes[] = lines[0].trim().split("\\s+");
       String values[] = lines[1].trim().split("\\s+");
-      
+
       Character processStateCodeChar = null;
       for (int i = 0; i < attributes.length; i++) {
         String attribute = attributes[i];
@@ -84,13 +85,13 @@ public class SystemUtil {
           break;
         }
       }
-      
+
       return ProcessStateCode.valueOf(Character.toString(processStateCodeChar));
     } else {
       throw new UnsupportedOperationException("Not supported OS: " + OS_NAME);
     }
   }
-  
+
   public static String getPidFromFile(File file) {
     BufferedReader br = null;
     try {

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/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 6097456..e723296 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
@@ -51,22 +51,22 @@ public class TestHelixAgent extends ZkUnitTestBase {
   public void beforeMethod() throws Exception {
     serverCmd = ExternalCommand.start(workingDir + "/simpleHttpServer.py");
   }
-  
+
   @AfterMethod
   public void afterMethod() throws Exception {
     if (serverCmd != null) {
       // shutdown server
       ExternalCommand.execute(new File(workingDir), "simpleHttpClient.py", "exit");
-//      System.out.println("simpleHttpServer output: \n" + serverCmd.getStringOutput());
-      
+      // System.out.println("simpleHttpServer output: \n" + serverCmd.getStringOutput());
+
       // check server has received all the requests
       String serverOutput = serverCmd.getStringOutput();
       int idx = serverOutput.indexOf("requestPath: /OFFLINE-SLAVE");
       Assert.assertTrue(idx > 0, "server should receive OFFINE->SLAVE transition");
-      
+
       idx = serverOutput.indexOf("requestPath: /SLAVE-MASTER", idx);
       Assert.assertTrue(idx > 0, "server should receive SLAVE-MASTER transition");
-      
+
       idx = serverOutput.indexOf("requestPath: /MASTER-SLAVE", idx);
       Assert.assertTrue(idx > 0, "server should receive MASTER-SLAVE transition");
 
@@ -75,7 +75,7 @@ public class TestHelixAgent extends ZkUnitTestBase {
 
     }
   }
-  
+
   @Test
   public void test() throws Exception {
     String className = TestHelper.getTestClassName();
@@ -84,86 +84,75 @@ public class TestHelixAgent extends ZkUnitTestBase {
     final int n = 1;
     final String zkAddr = ZK_ADDR;
 
-    System.out.println("START " + clusterName + " at "
-        + new Date(System.currentTimeMillis()));
-
+    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
 
-    TestHelper.setupCluster(clusterName, 
-                            zkAddr, 
-                            12918, // participant port
-                            "localhost", // participant name prefix
-                            "TestDB", // resource name prefix
-                            1, // resources
-                            1, // partitions per resource
-                            n, // number of nodes
-                            1, // replicas
-                            "MasterSlave",
-                            true); // do rebalance
+    TestHelper.setupCluster(clusterName, zkAddr, 12918, // participant port
+        "localhost", // participant name prefix
+        "TestDB", // resource name prefix
+        1, // resources
+        1, // partitions per resource
+        n, // number of nodes
+        1, // replicas
+        "MasterSlave", true); // do rebalance
 
     // set cluster config
-    ZkClient client = new ZkClient(zkAddr,
-                                   ZkClient.DEFAULT_SESSION_TIMEOUT,
-                                   ZkClient.DEFAULT_CONNECTION_TIMEOUT,
-                                   new ZNRecordSerializer());
-
-    HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER)
-                                    .forCluster(clusterName)
-                                    .build();
+    ZkClient client =
+        new ZkClient(zkAddr, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT,
+            new ZNRecordSerializer());
+
+    HelixConfigScope scope =
+        new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(clusterName).build();
     ConfigAccessor configAccessor = new ConfigAccessor(client);
-    
-    // String pidFile = ScriptTestHelper.getPrefix() + ScriptTestHelper.INTEGRATION_LOG_DIR + "/default/foo_{PARTITION_NAME}_pid.txt";
-    
+
+    // String pidFile = ScriptTestHelper.getPrefix() + ScriptTestHelper.INTEGRATION_LOG_DIR +
+    // "/default/foo_{PARTITION_NAME}_pid.txt";
+
     // the pid file path for the first partition
     // delete it if exists
-//    String pidFileFirstPartition = ScriptTestHelper.getPrefix() + ScriptTestHelper.INTEGRATION_LOG_DIR + "/default/foo_TestDB0_0_pid.txt";
-//    File file = new File(pidFileFirstPartition);
-//    if (file.exists()) {
-//      file.delete();
-//    }
-    
+    // String pidFileFirstPartition = ScriptTestHelper.getPrefix() +
+    // ScriptTestHelper.INTEGRATION_LOG_DIR + "/default/foo_TestDB0_0_pid.txt";
+    // File file = new File(pidFileFirstPartition);
+    // if (file.exists()) {
+    // file.delete();
+    // }
+
     // set commands for state-transitions
     CommandConfig.Builder builder = new CommandConfig.Builder();
-    CommandConfig cmdConfig = builder.setTransition("SLAVE", "MASTER")
-                                     .setCommand("simpleHttpClient.py SLAVE-MASTER")
-                                     .setCommandWorkingDir(workingDir)
-                                     .setCommandTimeout("0")
-    //                                 .setPidFile(pidFile)
-                                     .build();
+    CommandConfig cmdConfig =
+        builder.setTransition("SLAVE", "MASTER").setCommand("simpleHttpClient.py SLAVE-MASTER")
+            .setCommandWorkingDir(workingDir).setCommandTimeout("0")
+            // .setPidFile(pidFile)
+            .build();
     configAccessor.set(scope, cmdConfig.toKeyValueMap());
-    
+
     builder = new CommandConfig.Builder();
-    cmdConfig = builder.setTransition("OFFLINE", "SLAVE")
-                       .setCommand("simpleHttpClient.py OFFLINE-SLAVE")
-                       .setCommandWorkingDir(workingDir)
-                       .build();
+    cmdConfig =
+        builder.setTransition("OFFLINE", "SLAVE").setCommand("simpleHttpClient.py OFFLINE-SLAVE")
+            .setCommandWorkingDir(workingDir).build();
     configAccessor.set(scope, cmdConfig.toKeyValueMap());
 
     builder = new CommandConfig.Builder();
-    cmdConfig = builder.setTransition("MASTER", "SLAVE")
-                       .setCommand("simpleHttpClient.py MASTER-SLAVE")
-                       .setCommandWorkingDir(workingDir)
-                       .build();
+    cmdConfig =
+        builder.setTransition("MASTER", "SLAVE").setCommand("simpleHttpClient.py MASTER-SLAVE")
+            .setCommandWorkingDir(workingDir).build();
     configAccessor.set(scope, cmdConfig.toKeyValueMap());
-    
+
     builder = new CommandConfig.Builder();
-    cmdConfig = builder.setTransition("SLAVE", "OFFLINE")
-                       .setCommand("simpleHttpClient.py SLAVE-OFFLINE")
-                       .setCommandWorkingDir(workingDir)
-                       .build();
+    cmdConfig =
+        builder.setTransition("SLAVE", "OFFLINE").setCommand("simpleHttpClient.py SLAVE-OFFLINE")
+            .setCommandWorkingDir(workingDir).build();
     configAccessor.set(scope, cmdConfig.toKeyValueMap());
-    
+
     builder = new CommandConfig.Builder();
-    cmdConfig = builder.setTransition("OFFLINE", "DROPPED")
-                       .setCommand(CommandAttribute.NOP.getName())
-                       .build();
+    cmdConfig =
+        builder.setTransition("OFFLINE", "DROPPED").setCommand(CommandAttribute.NOP.getName())
+            .build();
     configAccessor.set(scope, cmdConfig.toKeyValueMap());
 
-
     // start controller
-    ClusterController controller =
-        new ClusterController(clusterName, "controller_0", zkAddr);
+    ClusterController controller = new ClusterController(clusterName, "controller_0", zkAddr);
     controller.syncStart();
-    
+
     // start helix-agent
     for (int i = 0; i < n; i++) {
       final String instanceName = "localhost_" + (12918 + i);
@@ -171,8 +160,10 @@ public class TestHelixAgent extends ZkUnitTestBase {
         @Override
         public void run() {
           try {
-            HelixAgentMain.main(new String[]{"--zkSvr", zkAddr, "--cluster", clusterName,
-                "--instanceName", instanceName, "--stateModel", "MasterSlave"});
+            HelixAgentMain.main(new String[] {
+                "--zkSvr", zkAddr, "--cluster", clusterName, "--instanceName", instanceName,
+                "--stateModel", "MasterSlave"
+            });
           } catch (Exception e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
@@ -180,34 +171,35 @@ public class TestHelixAgent extends ZkUnitTestBase {
         }
       };
       agentThread.start();
-      
+
       // wait participant thread to start
       Thread.sleep(100);
     }
-    
+
     boolean result =
         ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
-                                                                                 clusterName));
+            clusterName));
     Assert.assertTrue(result);
 
     // read the pid file should get current process id
-//    String readPid = SystemUtil.getPidFromFile(new File(pidFileFirstPartition));
-//    Assert.assertNotNull(readPid, "readPid is the pid for foo_test.py. should NOT be null");
-    
+    // String readPid = SystemUtil.getPidFromFile(new File(pidFileFirstPartition));
+    // Assert.assertNotNull(readPid, "readPid is the pid for foo_test.py. should NOT be null");
+
     // String name = ManagementFactory.getRuntimeMXBean().getName();
     // String currentPid = name.substring(0,name.indexOf("@"));
-    
+
     // System.out.println("read-pid: " + readPid + ", current-pid: " + currentPid);
-    
+
     // drop resource will trigger M->S and S->O transitions
-    ClusterSetup.processCommandLineArgs(new String[]{"--zkSvr", ZK_ADDR, "--dropResource", clusterName, "TestDB0"});
+    ClusterSetup.processCommandLineArgs(new String[] {
+        "--zkSvr", ZK_ADDR, "--dropResource", clusterName, "TestDB0"
+    });
     result =
         ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
-                                                                                 clusterName));
-    Assert.assertTrue(result);      
+            clusterName));
+    Assert.assertTrue(result);
 
-    System.out.println("END " + clusterName + " at "
-        + new Date(System.currentTimeMillis()));
+    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
 
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/AccessOption.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/AccessOption.java b/helix-core/src/main/java/org/apache/helix/AccessOption.java
index 8bb5506..1740304 100644
--- a/helix-core/src/main/java/org/apache/helix/AccessOption.java
+++ b/helix-core/src/main/java/org/apache/helix/AccessOption.java
@@ -21,8 +21,7 @@ package org.apache.helix;
 
 import org.apache.zookeeper.CreateMode;
 
-public class AccessOption
-{
+public class AccessOption {
   public static int PERSISTENT = 0x1;
   public static int EPHEMERAL = 0x2;
   public static int PERSISTENT_SEQUENTIAL = 0x4;
@@ -31,26 +30,17 @@ public class AccessOption
 
   /**
    * Helper method to get zookeeper create mode from options
-   * 
    * @param options bitmask representing mode; least significant set flag is selected
    * @return zookeeper create mode
    */
-  public static CreateMode getMode(int options)
-  {
-    if ((options & PERSISTENT) > 0)
-    {
+  public static CreateMode getMode(int options) {
+    if ((options & PERSISTENT) > 0) {
       return CreateMode.PERSISTENT;
-    }
-    else if ((options & EPHEMERAL) > 0)
-    {
+    } else if ((options & EPHEMERAL) > 0) {
       return CreateMode.EPHEMERAL;
-    }
-    else if ((options & PERSISTENT_SEQUENTIAL) > 0)
-    {
+    } else if ((options & PERSISTENT_SEQUENTIAL) > 0) {
       return CreateMode.PERSISTENT_SEQUENTIAL;
-    }
-    else if ((options & EPHEMERAL_SEQUENTIAL) > 0)
-    {
+    } else if ((options & EPHEMERAL_SEQUENTIAL) > 0) {
       return CreateMode.EPHEMERAL_SEQUENTIAL;
     }
 
@@ -59,12 +49,10 @@ public class AccessOption
 
   /**
    * Helper method to get is-throw-exception-on-node-not-exist from options
-   * 
    * @param options bitmask containing Zookeeper mode options
    * @return true if in is-throw-exception-on-node-not-exist, false otherwise
    */
-  public static boolean isThrowExceptionIfNotExist(int options)
-  {
+  public static boolean isThrowExceptionIfNotExist(int options) {
     return (options & THROW_EXCEPTION_IFNOTEXIST) > 0;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/BaseDataAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/BaseDataAccessor.java b/helix-core/src/main/java/org/apache/helix/BaseDataAccessor.java
index 9154724..32510c0 100644
--- a/helix-core/src/main/java/org/apache/helix/BaseDataAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/BaseDataAccessor.java
@@ -28,16 +28,13 @@ import org.apache.zookeeper.data.Stat;
 
 /**
  * Generic interface for accessing and manipulating data on a backing store like Zookeeper.
- *
  * @param <T> The type of record to use
  */
-public interface BaseDataAccessor<T>
-{
+public interface BaseDataAccessor<T> {
   /**
    * This will always attempt to create the znode, if it exists it will return false. Will
    * create parents if they do not exist. For performance reasons, it may try to create
    * child first and only if it fails it will try to create parents
-   * 
    * @param path path to the ZNode to create
    * @param record the data to write to the ZNode
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
@@ -48,7 +45,6 @@ public interface BaseDataAccessor<T>
   /**
    * This will always attempt to set the data on existing node. If the ZNode does not
    * exist it will create it and all its parents ZNodes if necessary
-   * 
    * @param path path to the ZNode to set
    * @param record the data to write to the ZNode
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
@@ -58,21 +54,21 @@ public interface BaseDataAccessor<T>
 
   /**
    * This will attempt to set the data on existing node only if version matches.
-   * If the ZNode does not exist it will create it and all its parent ZNodes only if expected version is -1
-   * 
+   * If the ZNode does not exist it will create it and all its parent ZNodes only if expected
+   * version is -1
    * @param path path to the ZNode to set
    * @param record the data to write to the ZNode
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
-   * @param expectVersion the expected version of the data to be overwritten, -1 means match any version
+   * @param expectVersion the expected version of the data to be overwritten, -1 means match any
+   *          version
    * @return true if data was successfully set, false otherwise (e.g. if the version mismatches)
    */
   boolean set(String path, T record, int expectVersion, int options);
-  
+
   /**
    * This will attempt to update the data using the updater. If the ZNode
    * does not exist it will create it and all its parent ZNodes.
    * Updater will be invoked with null value if node does not exist.
-   * 
    * @param path path to the ZNode to update
    * @param updater an update routine for the data to merge in
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
@@ -82,7 +78,6 @@ public interface BaseDataAccessor<T>
 
   /**
    * This will remove the ZNode and all its descendants if any
-   * 
    * @param path path to the root ZNode to remove
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
    * @return true if the removal succeeded, false otherwise
@@ -92,7 +87,6 @@ public interface BaseDataAccessor<T>
   /**
    * Use it when creating children under a parent node. This will use async api for better
    * performance. If the child already exists it will return false.
-   * 
    * @param paths the paths to the children ZNodes
    * @param record List of data to write to each of the path
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
@@ -103,7 +97,6 @@ public interface BaseDataAccessor<T>
   /**
    * can set multiple children under a parent node. This will use async api for better
    * performance. If this child does not exist it will create it.
-   * 
    * @param paths the paths to the children ZNodes
    * @param record List of data with which to overwrite the corresponding ZNodes
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
@@ -114,7 +107,6 @@ public interface BaseDataAccessor<T>
   /**
    * Can update multiple nodes using async api for better performance. If a child does not
    * exist it will create it.
-   * 
    * @param the paths to the children ZNodes
    * @param updaters List of update routines for records to update
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
@@ -124,7 +116,6 @@ public interface BaseDataAccessor<T>
 
   /**
    * remove multiple paths using async api. will remove any child nodes if any
-   * 
    * @param paths paths to the ZNodes to remove
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
    * @return For each ZNode, true if successfully removed, false otherwise
@@ -133,7 +124,6 @@ public interface BaseDataAccessor<T>
 
   /**
    * Get the {@link T} corresponding to the path
-   * 
    * @param path path to the ZNode
    * @param stat retrieve the stat of the ZNode
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
@@ -143,7 +133,6 @@ public interface BaseDataAccessor<T>
 
   /**
    * Get List of {@link T} corresponding to the paths using async api
-   * 
    * @param paths paths to the ZNodes
    * @param stats retrieve a list of stats for the ZNodes
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
@@ -153,7 +142,6 @@ public interface BaseDataAccessor<T>
 
   /**
    * Get the children under a parent path using async api
-   * 
    * @param path path to the immediate parent ZNode
    * @param stats Zookeeper Stat objects corresponding to each child
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
@@ -163,7 +151,6 @@ public interface BaseDataAccessor<T>
 
   /**
    * Returns the child names given a parent path
-   * 
    * @param parentPath path to the immediate parent ZNode
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
    * @return a list of the names of all of the parent ZNode's children
@@ -172,7 +159,6 @@ public interface BaseDataAccessor<T>
 
   /**
    * checks if the path exists in zk
-   * 
    * @param path path to the ZNode to test
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
    * @return true if the ZNode exists, false otherwise
@@ -181,7 +167,6 @@ public interface BaseDataAccessor<T>
 
   /**
    * checks if the all the paths exists
-   * 
    * @param paths paths to the ZNodes to test
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
    * @return for each path, true if a valid ZNode exists, false otherwise
@@ -190,7 +175,6 @@ public interface BaseDataAccessor<T>
 
   /**
    * Get the stats of all the paths
-   * 
    * @param paths paths of the ZNodes to query
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
    * @return Zookeeper Stat object for each path
@@ -199,7 +183,6 @@ public interface BaseDataAccessor<T>
 
   /**
    * Get the stats of a single path
-   * 
    * @param path path of the ZNode to query
    * @param options Set the type of ZNode see the valid values in {@link AccessOption}
    * @return Zookeeper Stat object corresponding to the ZNode
@@ -208,7 +191,6 @@ public interface BaseDataAccessor<T>
 
   /**
    * Subscribe data listener to path
-   * 
    * @param path path to the ZNode to listen to
    * @param listener the listener to register for changes
    */
@@ -216,7 +198,6 @@ public interface BaseDataAccessor<T>
 
   /**
    * Unsubscribe data listener to path
-   * 
    * @param path path to the ZNode to stop listening to
    * @param listener the listener currently subscribed to the ZNode
    */
@@ -224,7 +205,6 @@ public interface BaseDataAccessor<T>
 
   /**
    * Subscribe child listener to path
-   * 
    * @param path path to the immediate parent ZNode
    * @param listener the listener to register for changes
    * @return
@@ -233,7 +213,6 @@ public interface BaseDataAccessor<T>
 
   /**
    * Unsubscribe child listener to path
-   * 
    * @param path path to the immediate parent ZNode
    * @param listener the listener currently subscribed to the children
    */


Mime
View raw message