helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject [13/51] [partial] [HELIX-198] Unify helix code style, rb=13710
Date Wed, 21 Aug 2013 20:43:26 GMT
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java b/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
index 3bbfc7e..bf2de1e 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessage.java
@@ -46,49 +46,42 @@ import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-
-public class TestBatchMessage extends ZkIntegrationTestBase
-{
-  class TestZkChildListener implements IZkChildListener
-  {
+public class TestBatchMessage extends ZkIntegrationTestBase {
+  class TestZkChildListener implements IZkChildListener {
     int _maxNbOfChilds = 0;
-    
+
     @Override
-    public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception
-    {
+    public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
       System.out.println(parentPath + " has " + currentChilds.size() + " messages");
-      if (currentChilds.size() > _maxNbOfChilds)
-      {
+      if (currentChilds.size() > _maxNbOfChilds) {
         _maxNbOfChilds = currentChilds.size();
       }
     }
-    
+
   }
-  
+
   @Test
-  public void testBasic() throws Exception
-  {
+  public void testBasic() throws Exception {
     // Logger.getRootLogger().setLevel(Level.INFO);
     String className = TestHelper.getTestClassName();
     String methodName = TestHelper.getTestMethodName();
     String clusterName = className + "_" + methodName;
     int n = 2;
 
-    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
-                            32, // partitions per resource
-                            n, // number of nodes
-                            2, // replicas
-                            "MasterSlave",
-                            true); // do rebalance
-    
+        "localhost", // participant name prefix
+        "TestDB", // resource name prefix
+        1, // resources
+        32, // partitions per resource
+        n, // number of nodes
+        2, // replicas
+        "MasterSlave", true); // do rebalance
+
     // enable batch message
-    ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
+    ZKHelixDataAccessor accessor =
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
     Builder keyBuilder = accessor.keyBuilder();
     IdealState idealState = accessor.getProperty(keyBuilder.idealStates("TestDB0"));
     idealState.setBatchMessageMode(true);
@@ -98,15 +91,12 @@ public class TestBatchMessage extends ZkIntegrationTestBase
     TestZkChildListener listener = new TestZkChildListener();
     _gZkClient.subscribeChildChanges(keyBuilder.messages("localhost_12918").getPath(), listener);
 
-    
-    ClusterController controller =
-        new ClusterController(clusterName, "controller_0", ZK_ADDR);
+    ClusterController controller = new ClusterController(clusterName, "controller_0", ZK_ADDR);
     controller.syncStart();
 
     // start 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);
 
       participants[i] = new MockParticipant(clusterName, instanceName, ZK_ADDR, null);
@@ -115,54 +105,48 @@ public class TestBatchMessage extends ZkIntegrationTestBase
 
     boolean result =
         ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
-                                                                                 clusterName));
+            clusterName));
     Assert.assertTrue(result);
-    Assert.assertTrue(listener._maxNbOfChilds <= 2, "Should get no more than 2 messages (O->S and S->M)");
-    
+    Assert.assertTrue(listener._maxNbOfChilds <= 2,
+        "Should get no more than 2 messages (O->S and S->M)");
+
     // clean up
     // wait for all zk callbacks done
     Thread.sleep(1000);
     controller.syncStop();
-    for (int i = 0; i < n; i++)
-    {
+    for (int i = 0; i < n; i++) {
       participants[i].syncStop();
     }
 
-    System.out.println("END " + clusterName + " at "
-        + new Date(System.currentTimeMillis()));
+    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
   }
-  
+
   // a non-batch-message run followed by a batch-message-enabled run
   @Test
-  public void testChangeBatchMessageMode() throws Exception
-  {
+  public void testChangeBatchMessageMode() throws Exception {
     // Logger.getRootLogger().setLevel(Level.INFO);
     String className = TestHelper.getTestClassName();
     String methodName = TestHelper.getTestMethodName();
     String clusterName = className + "_" + methodName;
     int n = 2;
 
-    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
-                            32, // partitions per resource
-                            n, // number of nodes
-                            2, // replicas
-                            "MasterSlave",
-                            true); // do rebalance
-    
-    ClusterController controller =
-        new ClusterController(clusterName, "controller_0", ZK_ADDR);
+        "localhost", // participant name prefix
+        "TestDB", // resource name prefix
+        1, // resources
+        32, // partitions per resource
+        n, // number of nodes
+        2, // replicas
+        "MasterSlave", true); // do rebalance
+
+    ClusterController controller = new ClusterController(clusterName, "controller_0", ZK_ADDR);
     controller.syncStart();
 
     // start 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);
 
       participants[i] = new MockParticipant(clusterName, instanceName, ZK_ADDR, null);
@@ -171,18 +155,18 @@ public class TestBatchMessage extends ZkIntegrationTestBase
 
     boolean result =
         ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
-                                                                                 clusterName));
+            clusterName));
     Assert.assertTrue(result);
-    
+
     // stop all participants
     Thread.sleep(1000);
-    for (int i = 0; i < n; i++)
-    {
+    for (int i = 0; i < n; i++) {
       participants[i].syncStop();
     }
-    
+
     // enable batch message
-    ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
+    ZKHelixDataAccessor accessor =
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
     Builder keyBuilder = accessor.keyBuilder();
     IdealState idealState = accessor.getProperty(keyBuilder.idealStates("TestDB0"));
     idealState.setBatchMessageMode(true);
@@ -193,113 +177,92 @@ public class TestBatchMessage extends ZkIntegrationTestBase
     _gZkClient.subscribeChildChanges(keyBuilder.messages("localhost_12918").getPath(), listener);
 
     // restart all participants
-    for (int i = 0; i < n; i++)
-    {
+    for (int i = 0; i < n; i++) {
       String instanceName = "localhost_" + (12918 + i);
 
       participants[i] = new MockParticipant(clusterName, instanceName, ZK_ADDR, null);
       participants[i].syncStart();
     }
-    
+
     result =
         ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
-                                                                                 clusterName));
+            clusterName));
     Assert.assertTrue(result);
-    Assert.assertTrue(listener._maxNbOfChilds <= 2, "Should get no more than 2 messages (O->S and S->M)");
+    Assert.assertTrue(listener._maxNbOfChilds <= 2,
+        "Should get no more than 2 messages (O->S and S->M)");
 
-    
     // clean up
     // wait for all zk callbacks done
     Thread.sleep(1000);
     controller.syncStop();
-    for (int i = 0; i < n; i++)
-    {
+    for (int i = 0; i < n; i++) {
       participants[i].syncStop();
     }
 
-    System.out.println("END " + clusterName + " at "
-        + new Date(System.currentTimeMillis()));
+    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
   }
-  
+
   @Test
-  public void testSubMsgExecutionFail() throws Exception
-  {
-	    String className = TestHelper.getTestClassName();
-	    String methodName = TestHelper.getTestMethodName();
-	    String clusterName = className + "_" + methodName;
-	    
-	    final int n = 5;
-	    MockParticipant[] participants = new MockParticipant[n];
-
-	    System.out.println("START " + clusterName + " at "
-	        + new Date(System.currentTimeMillis()));
-//	    ZKHelixAdmin tool = new ZKHelixAdmin(_gZkClient);
-
-	    TestHelper.setupCluster(clusterName,
-	                            ZK_ADDR,
-	                            12918,
-	                            "localhost",
-	                            "TestDB",
-	                            1,	// resource#
-	                            6,	// partition#
-	                            n,	// nodes#
-	                            3,  // replicas#
-	                            "MasterSlave",
-	                            true);
-
-	    // enable batch message
-	    ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
-	    Builder keyBuilder = accessor.keyBuilder();
-	    IdealState idealState = accessor.getProperty(keyBuilder.idealStates("TestDB0"));
-	    idealState.setBatchMessageMode(true);
-	    accessor.setProperty(keyBuilder.idealStates("TestDB0"), idealState);
-
-	    TestHelper.startController(clusterName,
-	                               "controller_0",
-	                               ZK_ADDR,
-	                               HelixControllerMain.STANDALONE);
-	    for (int i = 0; i < n; i++)
-	    {
-	      String instanceName = "localhost_" + (12918 + i);
-
-	      if (i == 1)
-	      {
-	        Map<String, Set<String>> errPartitions = new HashMap<String, Set<String>>();
-	        errPartitions.put("SLAVE-MASTER", TestHelper.setOf("TestDB0_4"));
-	        participants[i] =
-	            new MockParticipant(clusterName,
-	                                instanceName,
-	                                ZK_ADDR,
-	                                new ErrTransition(errPartitions));
-	      }
-	      else
-	      {
-	        participants[i] = new MockParticipant(clusterName, instanceName, ZK_ADDR);
-	      }
-	      participants[i].syncStart();
-	    }
-
-	    Map<String, Map<String, String>> errStates =
-	        new HashMap<String, Map<String, String>>();
-	    errStates.put("TestDB0", new HashMap<String, String>());
-	    errStates.get("TestDB0").put("TestDB0_4", "localhost_12919");
-	    boolean result =
-	        ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
-	                                                                                          clusterName,
-	                                                                                          errStates));
-	    Assert.assertTrue(result);
-
-	    Map<String, Set<String>> errorStateMap = new HashMap<String, Set<String>>();
-	    errorStateMap.put("TestDB0_4", TestHelper.setOf("localhost_12919"));
-
-	    // verify "TestDB0_4", "localhost_12919" is in ERROR state
-	    TestHelper.verifyState(clusterName, ZK_ADDR, errorStateMap, "ERROR");
-	    
-	    System.out.println("END " + clusterName + " at "
-	            + new Date(System.currentTimeMillis()));
+  public void testSubMsgExecutionFail() throws Exception {
+    String className = TestHelper.getTestClassName();
+    String methodName = TestHelper.getTestMethodName();
+    String clusterName = className + "_" + methodName;
+
+    final int n = 5;
+    MockParticipant[] participants = new MockParticipant[n];
+
+    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
+    // ZKHelixAdmin tool = new ZKHelixAdmin(_gZkClient);
+
+    TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, "localhost", "TestDB", 1, // resource#
+        6, // partition#
+        n, // nodes#
+        3, // replicas#
+        "MasterSlave", true);
+
+    // enable batch message
+    ZKHelixDataAccessor accessor =
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
+    Builder keyBuilder = accessor.keyBuilder();
+    IdealState idealState = accessor.getProperty(keyBuilder.idealStates("TestDB0"));
+    idealState.setBatchMessageMode(true);
+    accessor.setProperty(keyBuilder.idealStates("TestDB0"), idealState);
+
+    TestHelper
+        .startController(clusterName, "controller_0", ZK_ADDR, HelixControllerMain.STANDALONE);
+    for (int i = 0; i < n; i++) {
+      String instanceName = "localhost_" + (12918 + i);
+
+      if (i == 1) {
+        Map<String, Set<String>> errPartitions = new HashMap<String, Set<String>>();
+        errPartitions.put("SLAVE-MASTER", TestHelper.setOf("TestDB0_4"));
+        participants[i] =
+            new MockParticipant(clusterName, instanceName, ZK_ADDR,
+                new ErrTransition(errPartitions));
+      } else {
+        participants[i] = new MockParticipant(clusterName, instanceName, ZK_ADDR);
+      }
+      participants[i].syncStart();
+    }
+
+    Map<String, Map<String, String>> errStates = new HashMap<String, Map<String, String>>();
+    errStates.put("TestDB0", new HashMap<String, String>());
+    errStates.get("TestDB0").put("TestDB0_4", "localhost_12919");
+    boolean result =
+        ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
+            ZK_ADDR, clusterName, errStates));
+    Assert.assertTrue(result);
+
+    Map<String, Set<String>> errorStateMap = new HashMap<String, Set<String>>();
+    errorStateMap.put("TestDB0_4", TestHelper.setOf("localhost_12919"));
+
+    // verify "TestDB0_4", "localhost_12919" is in ERROR state
+    TestHelper.verifyState(clusterName, ZK_ADDR, errorStateMap, "ERROR");
+
+    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
 
   }
-  
+
   @Test
   public void testParticipantIncompatibleWithBatchMsg() throws Exception {
     // Logger.getRootLogger().setLevel(Level.INFO);
@@ -308,77 +271,76 @@ public class TestBatchMessage extends ZkIntegrationTestBase
     String clusterName = className + "_" + methodName;
     int n = 2;
 
-    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
-                            32, // partitions per resource
-                            n, // number of nodes
-                            2, // replicas
-                            "MasterSlave",
-                            true); // do rebalance
-    
+        "localhost", // participant name prefix
+        "TestDB", // resource name prefix
+        1, // resources
+        32, // partitions per resource
+        n, // number of nodes
+        2, // replicas
+        "MasterSlave", true); // do rebalance
+
     // enable batch message
     // --addResourceProperty <clusterName resourceName propertyName propertyValue>
-    ClusterSetup.processCommandLineArgs(new String[] {"--zkSvr", ZK_ADDR, "--addResourceProperty", clusterName, 
-                  "TestDB0", HelixPropertyAttribute.BATCH_MESSAGE_MODE.toString(), 
-                  "true"});
-    
-    
-    ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
+    ClusterSetup.processCommandLineArgs(new String[] {
+        "--zkSvr", ZK_ADDR, "--addResourceProperty", clusterName, "TestDB0",
+        HelixPropertyAttribute.BATCH_MESSAGE_MODE.toString(), "true"
+    });
+
+    ZKHelixDataAccessor accessor =
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
     Builder keyBuilder = accessor.keyBuilder();
 
     // register a message listener so we know how many message generated
     TestZkChildListener listener = new TestZkChildListener();
     _gZkClient.subscribeChildChanges(keyBuilder.messages("localhost_12918").getPath(), listener);
 
-    
-    ClusterController controller =
-        new ClusterController(clusterName, "controller_0", ZK_ADDR);
+    ClusterController controller = new ClusterController(clusterName, "controller_0", ZK_ADDR);
     controller.syncStart();
-    
+
     // pause controller
-    // --enableCluster <clusterName true/false>  
-    ClusterSetup.processCommandLineArgs(new String[]{"--zkSvr", ZK_ADDR, "--enableCluster", clusterName, "false"});
+    // --enableCluster <clusterName true/false>
+    ClusterSetup.processCommandLineArgs(new String[] {
+        "--zkSvr", ZK_ADDR, "--enableCluster", clusterName, "false"
+    });
 
     // start 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);
 
       participants[i] = new MockParticipant(clusterName, instanceName, ZK_ADDR, null);
       participants[i].syncStart();
     }
-    
+
     // change localhost_12918 version to 0.5, so batch-message-mode will be ignored
     LiveInstance liveInstance = accessor.getProperty(keyBuilder.liveInstance("localhost_12918"));
     liveInstance.setHelixVersion("0.5");
     accessor.setProperty(keyBuilder.liveInstance("localhost_12918"), liveInstance);
 
     // resume controller
-    // --enableCluster <clusterName true/false>  
-    ClusterSetup.processCommandLineArgs(new String[]{"--zkSvr", ZK_ADDR, "--enableCluster", clusterName, "true"});
+    // --enableCluster <clusterName true/false>
+    ClusterSetup.processCommandLineArgs(new String[] {
+        "--zkSvr", ZK_ADDR, "--enableCluster", clusterName, "true"
+    });
 
     boolean result =
         ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
-                                                                                 clusterName));
+            clusterName));
     Assert.assertTrue(result);
-    Assert.assertTrue(listener._maxNbOfChilds > 16, "Should see more than 16 messages at the same time (32 O->S and 32 S->M)");
-    
+    Assert.assertTrue(listener._maxNbOfChilds > 16,
+        "Should see more than 16 messages at the same time (32 O->S and 32 S->M)");
+
     // clean up
     // wait for all zk callbacks done
     Thread.sleep(1000);
     controller.syncStop();
-    for (int i = 0; i < n; i++)
-    {
+    for (int i = 0; i < n; 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-core/src/test/java/org/apache/helix/integration/TestBatchMessageWrapper.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessageWrapper.java b/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessageWrapper.java
index 88873a8..2ae8bf3 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessageWrapper.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestBatchMessageWrapper.java
@@ -43,93 +43,97 @@ public class TestBatchMessageWrapper extends ZkUnitTestBase {
   class MockBatchMsgWrapper extends BatchMessageWrapper {
     int _startCount = 0;
     int _endCount = 0;
-  
+
     @Override
     public void start(Message batchMsg, NotificationContext context) {
       // System.out.println("test batchMsg.start() invoked, " + batchMsg.getTgtName());
       _startCount++;
     }
-    
+
     @Override
     public void end(Message batchMsg, NotificationContext context) {
       // System.out.println("test batchMsg.end() invoked, " + batchMsg.getTgtName());
       _endCount++;
     }
   }
-  
+
   class TestMockMSModelFactory extends MockMSModelFactory {
     @Override
     public BatchMessageWrapper createBatchMessageWrapper(String resourceName) {
       return new MockBatchMsgWrapper();
     }
   }
-  
+
   @Test
   public void testBasic() throws Exception {
     String className = TestHelper.getTestClassName();
     String methodName = TestHelper.getTestMethodName();
     String clusterName = className + "_" + methodName;
     final int n = 2;
-    
+
     System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
-    
-    TestHelper.setupCluster(clusterName, 
-                            ZK_ADDR, 
-                            12918, // startPort
-                            "localhost", // participantNamePrefix
-                            "TestDB", // resourceNamePrefix
-                            1, // resourceNb
-                            2, // partitionNb
-                            n, // nodesNb
-                            2, // replica
-                            "MasterSlave", 
-                            true);
-    
+
+    TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // startPort
+        "localhost", // participantNamePrefix
+        "TestDB", // resourceNamePrefix
+        1, // resourceNb
+        2, // partitionNb
+        n, // nodesNb
+        2, // replica
+        "MasterSlave", true);
+
     // enable batch-message
-    ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, 
-                                    new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
+    ZKHelixDataAccessor accessor =
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
     Builder keyBuilder = accessor.keyBuilder();
     IdealState idealState = accessor.getProperty(keyBuilder.idealStates("TestDB0"));
     idealState.setBatchMessageMode(true);
     accessor.setProperty(keyBuilder.idealStates("TestDB0"), idealState);
-    
+
     ClusterController controller = new ClusterController(clusterName, "controller_0", ZK_ADDR);
     controller.syncStart();
-    
+
     // start participants
     MockParticipant[] participants = new MockParticipant[n];
     TestMockMSModelFactory[] ftys = new TestMockMSModelFactory[n];
-    
+
     for (int i = 0; i < n; i++) {
       String instanceName = "localhost_" + (12918 + i);
       ftys[i] = new TestMockMSModelFactory();
       participants[i] = new MockParticipant(ftys[i], clusterName, instanceName, ZK_ADDR, null);
       participants[i].syncStart();
-      
+
       // wait for each participant to complete state transitions, so we have deterministic results
       boolean result = false;
       do {
         Thread.sleep(100);
-        result = ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR, clusterName));
+        result =
+            ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
+                clusterName));
       } while (result == false);
-      
-      Assert.assertTrue(result, "participant: " + instanceName + " fails to complete all transitions");
+
+      Assert.assertTrue(result, "participant: " + instanceName
+          + " fails to complete all transitions");
     }
-    
+
     // check batch-msg-wrapper counts
     MockBatchMsgWrapper wrapper = (MockBatchMsgWrapper) ftys[0].getBatchMessageWrapper("TestDB0");
     // System.out.println("startCount: " + wrapper._startCount);
-    Assert.assertEquals(wrapper._startCount, 3, "Expect 3 batch.start: O->S, S->M, and M->S for 1st participant");
+    Assert.assertEquals(wrapper._startCount, 3,
+        "Expect 3 batch.start: O->S, S->M, and M->S for 1st participant");
     // System.out.println("endCount: " + wrapper._endCount);
-    Assert.assertEquals(wrapper._endCount, 3, "Expect 3 batch.end: O->S, S->M, and M->S for 1st participant");
-    
+    Assert.assertEquals(wrapper._endCount, 3,
+        "Expect 3 batch.end: O->S, S->M, and M->S for 1st participant");
+
     wrapper = (MockBatchMsgWrapper) ftys[1].getBatchMessageWrapper("TestDB0");
     // System.out.println("startCount: " + wrapper._startCount);
-    Assert.assertEquals(wrapper._startCount, 2, "Expect 2 batch.start: O->S and S->M for 2nd participant");
+    Assert.assertEquals(wrapper._startCount, 2,
+        "Expect 2 batch.start: O->S and S->M for 2nd participant");
     // System.out.println("endCount: " + wrapper._endCount);
-    Assert.assertEquals(wrapper._startCount, 2, "Expect 2 batch.end: O->S and S->M for 2nd participant");
-    
+    Assert.assertEquals(wrapper._startCount, 2,
+        "Expect 2 batch.end: O->S and S->M for 2nd participant");
+
     System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
   }
-  
-}
\ No newline at end of file
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/test/java/org/apache/helix/integration/TestBucketizedResource.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestBucketizedResource.java b/helix-core/src/test/java/org/apache/helix/integration/TestBucketizedResource.java
index d103c1a..8e75537 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestBucketizedResource.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestBucketizedResource.java
@@ -35,49 +35,41 @@ import org.apache.helix.tools.ClusterStateVerifier.MasterNbInExtViewVerifier;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-
-public class TestBucketizedResource extends ZkIntegrationTestBase
-{
+public class TestBucketizedResource extends ZkIntegrationTestBase {
   @Test()
-  public void testBucketizedResource() throws Exception
-  {
+  public void testBucketizedResource() throws Exception {
     // Logger.getRootLogger().setLevel(Level.INFO);
     String className = TestHelper.getTestClassName();
     String methodName = TestHelper.getTestMethodName();
     String clusterName = className + "_" + methodName;
-    
-    System.out.println("START " + clusterName + " at "
-        + new Date(System.currentTimeMillis()));
 
-    
+    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
+
     MockParticipant[] participants = new MockParticipant[5];
-//    ClusterSetup setupTool = new ClusterSetup(ZK_ADDR);
+    // ClusterSetup setupTool = new ClusterSetup(ZK_ADDR);
 
     TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
-                            "localhost", // participant name prefix
-                            "TestDB", // resource name prefix
-                            1, // resources
-                            10, // partitions per resource
-                            5, // number of nodes
-                            3, // replicas
-                            "MasterSlave",
-                            true); // do rebalance
-    
+        "localhost", // participant name prefix
+        "TestDB", // resource name prefix
+        1, // resources
+        10, // partitions per resource
+        5, // number of nodes
+        3, // replicas
+        "MasterSlave", true); // do rebalance
+
     ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
     ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, baseAccessor);
-    // String idealStatePath = PropertyPathConfig.getPath(PropertyType.IDEALSTATES, clusterName, "TestDB0");
+    // String idealStatePath = PropertyPathConfig.getPath(PropertyType.IDEALSTATES, clusterName,
+    // "TestDB0");
     Builder keyBuilder = accessor.keyBuilder();
     IdealState idealState = accessor.getProperty(keyBuilder.idealStates("TestDB0"));
     idealState.setBucketSize(1);
     accessor.setProperty(keyBuilder.idealStates("TestDB0"), idealState);
 
-    TestHelper.startController(clusterName,
-                               "controller_0",
-                               ZK_ADDR,
-                               HelixControllerMain.STANDALONE);
+    TestHelper
+        .startController(clusterName, "controller_0", ZK_ADDR, HelixControllerMain.STANDALONE);
     // start participants
-    for (int i = 0; i < 5; i++)
-    {
+    for (int i = 0; i < 5; i++) {
       String instanceName = "localhost_" + (12918 + i);
 
       participants[i] = new MockParticipant(clusterName, instanceName, ZK_ADDR, null);
@@ -85,22 +77,20 @@ public class TestBucketizedResource extends ZkIntegrationTestBase
     }
 
     boolean result =
-        ClusterStateVerifier.verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR,
-                                                                              clusterName));
+        ClusterStateVerifier
+            .verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR, clusterName));
     Assert.assertTrue(result);
 
     result =
         ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
-                                                                                 clusterName));
+            clusterName));
     Assert.assertTrue(result);
-    
+
     // clean up
-    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-core/src/test/java/org/apache/helix/integration/TestCMWithFailParticipant.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestCMWithFailParticipant.java b/helix-core/src/test/java/org/apache/helix/integration/TestCMWithFailParticipant.java
index e523e00..453bea6 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestCMWithFailParticipant.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestCMWithFailParticipant.java
@@ -23,8 +23,7 @@ import java.util.Date;
 
 import org.testng.annotations.Test;
 
-public class TestCMWithFailParticipant extends ZkIntegrationTestBase
-{
+public class TestCMWithFailParticipant extends ZkIntegrationTestBase {
   // ZkClient _zkClient;
   //
   // @BeforeClass ()
@@ -42,22 +41,21 @@ public class TestCMWithFailParticipant extends ZkIntegrationTestBase
   // }
 
   @Test()
-  public void testCMWithFailParticipant() throws Exception
-  {
+  public void testCMWithFailParticipant() throws Exception {
     int numResources = 1;
     int numPartitionsPerResource = 10;
     int numInstance = 5;
     int replica = 3;
 
-    String uniqClusterName = "TestFail_" + "rg" + numResources + "_p" + numPartitionsPerResource
-        + "_n" + numInstance + "_r" + replica;
+    String uniqClusterName =
+        "TestFail_" + "rg" + numResources + "_p" + numPartitionsPerResource + "_n" + numInstance
+            + "_r" + replica;
     System.out.println("START " + uniqClusterName + " at " + new Date(System.currentTimeMillis()));
 
     TestDriver.setupCluster(uniqClusterName, ZK_ADDR, numResources, numPartitionsPerResource,
         numInstance, replica);
 
-    for (int i = 0; i < numInstance; i++)
-    {
+    for (int i = 0; i < numInstance; i++) {
       TestDriver.startDummyParticipant(uniqClusterName, i);
     }
     TestDriver.startController(uniqClusterName);

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/test/java/org/apache/helix/integration/TestCarryOverBadCurState.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestCarryOverBadCurState.java b/helix-core/src/test/java/org/apache/helix/integration/TestCarryOverBadCurState.java
index 8df8520..9d63a65 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestCarryOverBadCurState.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestCarryOverBadCurState.java
@@ -1,4 +1,3 @@
-
 package org.apache.helix.integration;
 
 /*
@@ -34,42 +33,35 @@ import org.apache.helix.tools.ClusterStateVerifier.MasterNbInExtViewVerifier;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-
-public class TestCarryOverBadCurState extends ZkIntegrationTestBase
-{
+public class TestCarryOverBadCurState extends ZkIntegrationTestBase {
   @Test
-  public void testCarryOverBadCurState() throws Exception
-  {
-    System.out.println("START testCarryOverBadCurState at "
-        + new Date(System.currentTimeMillis()));
+  public void testCarryOverBadCurState() throws Exception {
+    System.out.println("START testCarryOverBadCurState at " + new Date(System.currentTimeMillis()));
 
     String clusterName = getShortClassName();
     MockParticipant[] participants = new MockParticipant[5];
 
     TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
-                            "localhost", // participant name prefix
-                            "TestDB", // resource name prefix
-                            1, // resources
-                            10, // partitions per resource
-                            5, // number of nodes
-                            3, // replicas
-                            "MasterSlave",
-                            true); // do rebalance
+        "localhost", // participant name prefix
+        "TestDB", // resource name prefix
+        1, // resources
+        10, // partitions per resource
+        5, // number of nodes
+        3, // replicas
+        "MasterSlave", true); // do rebalance
 
     // add a bad current state
     ZNRecord badCurState = new ZNRecord("TestDB0");
-    String path = PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_12918", "session_0", "TestDB0");
+    String path =
+        PropertyPathConfig.getPath(PropertyType.CURRENTSTATES, clusterName, "localhost_12918",
+            "session_0", "TestDB0");
     _gZkClient.createPersistent(path, true);
     _gZkClient.writeData(path, badCurState);
-    
-    
-    TestHelper.startController(clusterName,
-                               "controller_0",
-                               ZK_ADDR,
-                               HelixControllerMain.STANDALONE);
+
+    TestHelper
+        .startController(clusterName, "controller_0", ZK_ADDR, HelixControllerMain.STANDALONE);
     // start participants
-    for (int i = 0; i < 5; i++)
-    {
+    for (int i = 0; i < 5; i++) {
       String instanceName = "localhost_" + (12918 + i);
 
       participants[i] = new MockParticipant(clusterName, instanceName, ZK_ADDR, null);
@@ -77,17 +69,16 @@ public class TestCarryOverBadCurState extends ZkIntegrationTestBase
     }
 
     boolean result =
-        ClusterStateVerifier.verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR,
-                                                                              clusterName));
+        ClusterStateVerifier
+            .verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR, clusterName));
     Assert.assertTrue(result);
 
     result =
         ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
-                                                                                 clusterName));
+            clusterName));
     Assert.assertTrue(result);
-    
-    System.out.println("END testCarryOverBadCurState at "
-        + new Date(System.currentTimeMillis()));
+
+    System.out.println("END testCarryOverBadCurState at " + new Date(System.currentTimeMillis()));
 
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/test/java/org/apache/helix/integration/TestCleanupExternalView.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestCleanupExternalView.java b/helix-core/src/test/java/org/apache/helix/integration/TestCleanupExternalView.java
index 5f1a7b6..781aa89 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestCleanupExternalView.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestCleanupExternalView.java
@@ -34,91 +34,91 @@ import org.testng.annotations.Test;
 import java.util.Date;
 
 /**
- *
- * Test clean external-view - if current-state is remove externally, controller should remove the orphan external-view
+ * Test clean external-view - if current-state is remove externally, controller should remove the
+ * orphan external-view
  */
 public class TestCleanupExternalView extends ZkUnitTestBase {
-    @Test
-    public void test() throws Exception {
-        // Logger.getRootLogger().setLevel(Level.INFO);
-        String className = TestHelper.getTestClassName();
-        String methodName = TestHelper.getTestMethodName();
-        String clusterName = className + "_" + methodName;
-        int n = 2;
-
-        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
-                2, // partitions per resource
-                n, // number of nodes
-                2, // replicas
-                "MasterSlave",
-                true); // do rebalance
-
-        ClusterController controller =
-                new ClusterController(clusterName, "controller_0", ZK_ADDR);
-        controller.syncStart();
-
-        // start participants
-        MockParticipant[] participants = new MockParticipant[n];
-        for (int i = 0; i < n; i++)
-        {
-            String instanceName = "localhost_" + (12918 + i);
-
-            participants[i] = new MockParticipant(clusterName, instanceName, ZK_ADDR, null);
-            participants[i].syncStart();
-        }
-
-        boolean result =
-                ClusterStateVerifier.verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
-                        clusterName));
-        Assert.assertTrue(result);
-
-        // disable controller
-        ZKHelixAdmin admin = new ZKHelixAdmin(_gZkClient);
-        admin.enableCluster(clusterName, false);
-        // wait all pending zk-events being processed, otherwise remove current-state will cause controller send O->S message
-        ZkTestHelper.tryWaitZkEventsCleaned(controller.getManager().getZkClient());
-        // System.out.println("paused controller");
-
-        // drop resource
-        admin.dropResource(clusterName, "TestDB0");
-
-        // delete current-state manually, controller shall remove external-view when cluster is enabled again
-        ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
-        PropertyKey.Builder keyBuilder = accessor.keyBuilder();
-
-        // System.out.println("remove current-state");
-        LiveInstance liveInstance = accessor.getProperty(keyBuilder.liveInstance("localhost_12918"));
-        accessor.removeProperty(keyBuilder.currentState("localhost_12918", liveInstance.getSessionId(), "TestDB0"));
-        liveInstance = accessor.getProperty(keyBuilder.liveInstance("localhost_12919"));
-        accessor.removeProperty(keyBuilder.currentState("localhost_12919", liveInstance.getSessionId(), "TestDB0"));
-
-        // re-enable controller shall remove orphan external-view
-        // System.out.println("re-enabling controller");
-        admin.enableCluster(clusterName, true);
-
-        ExternalView externalView = null;
-        for (int i = 0; i < 10; i++) {
-            Thread.sleep(100);
-            externalView = accessor.getProperty(keyBuilder.externalView("TestDB0"));
-            // System.out.println("externalView: " + externalView);
-            if (externalView == null) {
-                break;
-            }
-        }
-
-        Assert.assertNull(externalView, "external-view for TestDB0 should be removed, but was: " + externalView);
-
-        System.out.println("END " + clusterName + " at "
-                + new Date(System.currentTimeMillis()));
+  @Test
+  public void test() throws Exception {
+    // Logger.getRootLogger().setLevel(Level.INFO);
+    String className = TestHelper.getTestClassName();
+    String methodName = TestHelper.getTestMethodName();
+    String clusterName = className + "_" + methodName;
+    int n = 2;
+
+    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
+        2, // partitions per resource
+        n, // number of nodes
+        2, // replicas
+        "MasterSlave", true); // do rebalance
+
+    ClusterController controller = new ClusterController(clusterName, "controller_0", ZK_ADDR);
+    controller.syncStart();
+
+    // start participants
+    MockParticipant[] participants = new MockParticipant[n];
+    for (int i = 0; i < n; i++) {
+      String instanceName = "localhost_" + (12918 + i);
+
+      participants[i] = new MockParticipant(clusterName, instanceName, ZK_ADDR, null);
+      participants[i].syncStart();
+    }
 
+    boolean result =
+        ClusterStateVerifier
+            .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
+                clusterName));
+    Assert.assertTrue(result);
+
+    // disable controller
+    ZKHelixAdmin admin = new ZKHelixAdmin(_gZkClient);
+    admin.enableCluster(clusterName, false);
+    // wait all pending zk-events being processed, otherwise remove current-state will cause
+    // controller send O->S message
+    ZkTestHelper.tryWaitZkEventsCleaned(controller.getManager().getZkClient());
+    // System.out.println("paused controller");
+
+    // drop resource
+    admin.dropResource(clusterName, "TestDB0");
+
+    // delete current-state manually, controller shall remove external-view when cluster is enabled
+    // again
+    ZKHelixDataAccessor accessor =
+        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
+    PropertyKey.Builder keyBuilder = accessor.keyBuilder();
+
+    // System.out.println("remove current-state");
+    LiveInstance liveInstance = accessor.getProperty(keyBuilder.liveInstance("localhost_12918"));
+    accessor.removeProperty(keyBuilder.currentState("localhost_12918", liveInstance.getSessionId(),
+        "TestDB0"));
+    liveInstance = accessor.getProperty(keyBuilder.liveInstance("localhost_12919"));
+    accessor.removeProperty(keyBuilder.currentState("localhost_12919", liveInstance.getSessionId(),
+        "TestDB0"));
+
+    // re-enable controller shall remove orphan external-view
+    // System.out.println("re-enabling controller");
+    admin.enableCluster(clusterName, true);
+
+    ExternalView externalView = null;
+    for (int i = 0; i < 10; i++) {
+      Thread.sleep(100);
+      externalView = accessor.getProperty(keyBuilder.externalView("TestDB0"));
+      // System.out.println("externalView: " + externalView);
+      if (externalView == null) {
+        break;
+      }
     }
 
+    Assert.assertNull(externalView, "external-view for TestDB0 should be removed, but was: "
+        + externalView);
+
+    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/test/java/org/apache/helix/integration/TestClusterStartsup.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestClusterStartsup.java b/helix-core/src/test/java/org/apache/helix/integration/TestClusterStartsup.java
index 6caff9a..c0ced72 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestClusterStartsup.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestClusterStartsup.java
@@ -35,16 +35,12 @@ import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-
-public class TestClusterStartsup extends ZkStandAloneCMTestBase
-{
-  void setupCluster() throws HelixException
-  {
+public class TestClusterStartsup extends ZkStandAloneCMTestBase {
+  void setupCluster() throws HelixException {
     System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));
 
     String namespace = "/" + CLUSTER_NAME;
-    if (_zkClient.exists(namespace))
-    {
+    if (_zkClient.exists(namespace)) {
       _zkClient.deleteRecursive(namespace);
     }
     _setupTool = new ClusterSetup(ZK_ADDR);
@@ -52,72 +48,59 @@ public class TestClusterStartsup extends ZkStandAloneCMTestBase
     // setup storage cluster
     _setupTool.addCluster(CLUSTER_NAME, true);
     _setupTool.addResourceToCluster(CLUSTER_NAME, TEST_DB, 20, STATE_MODEL);
-    for (int i = 0; i < NODE_NR; i++)
-    {
+    for (int i = 0; i < NODE_NR; i++) {
       String storageNodeName = "localhost_" + (START_PORT + i);
       _setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
     }
     _setupTool.rebalanceStorageCluster(CLUSTER_NAME, TEST_DB, 3);
   }
 
-
   @Override
   @BeforeClass()
-  public void beforeClass() throws Exception
-  {
-  	_zkClient = new ZkClient(ZK_ADDR);
+  public void beforeClass() throws Exception {
+    _zkClient = new ZkClient(ZK_ADDR);
   }
 
   @Override
-	@AfterClass()
-  public void afterClass()
-  {
-  	_zkClient.close();
+  @AfterClass()
+  public void afterClass() {
+    _zkClient.close();
   }
 
   @Test()
-  public void testParticipantStartUp() throws Exception
-  {
+  public void testParticipantStartUp() throws Exception {
     setupCluster();
-    String controllerMsgPath = HelixUtil.getControllerPropertyPath(CLUSTER_NAME, PropertyType.MESSAGES_CONTROLLER);
+    String controllerMsgPath =
+        HelixUtil.getControllerPropertyPath(CLUSTER_NAME, PropertyType.MESSAGES_CONTROLLER);
     _zkClient.deleteRecursive(controllerMsgPath);
-    HelixManager manager = null;;
-
-    try
-    {
-      manager = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME,
-                                                          "localhost_" + (START_PORT + 1),
-                                                          InstanceType.PARTICIPANT,
-                                                          ZK_ADDR);
+    HelixManager manager = null;
+    ;
+
+    try {
+      manager =
+          HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, "localhost_" + (START_PORT + 1),
+              InstanceType.PARTICIPANT, ZK_ADDR);
       manager.connect();
       Assert.fail("Should fail on connect() since cluster structure is not set up");
-    }
-    catch(HelixException e)
-    {
+    } catch (HelixException e) {
       // OK
     }
 
-    if(manager != null)
-    {
+    if (manager != null) {
       AssertJUnit.assertFalse(manager.isConnected());
     }
 
-    try
-    {
-      manager = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME,
-                                                          "localhost_" + (START_PORT + 3),
-                                                          InstanceType.PARTICIPANT,
-                                                          ZK_ADDR);
+    try {
+      manager =
+          HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, "localhost_" + (START_PORT + 3),
+              InstanceType.PARTICIPANT, ZK_ADDR);
       manager.connect();
       Assert.fail("Should fail on connect() since cluster structure is not set up");
-    }
-    catch(HelixException e)
-    {
+    } catch (HelixException e) {
       // OK
     }
 
-    if(manager != null)
-    {
+    if (manager != null) {
       AssertJUnit.assertFalse(manager.isConnected());
     }
 
@@ -125,43 +108,35 @@ public class TestClusterStartsup extends ZkStandAloneCMTestBase
     String stateModelPath = HelixUtil.getStateModelDefinitionPath(CLUSTER_NAME);
     _zkClient.deleteRecursive(stateModelPath);
 
-    try
-    {
-      manager = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME,
-                                                          "localhost_" + (START_PORT + 1),
-                                                          InstanceType.PARTICIPANT,
-                                                          ZK_ADDR);
+    try {
+      manager =
+          HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, "localhost_" + (START_PORT + 1),
+              InstanceType.PARTICIPANT, ZK_ADDR);
       manager.connect();
       Assert.fail("Should fail on connect() since cluster structure is not set up");
-    }
-    catch(HelixException e)
-    {
+    } catch (HelixException e) {
       // OK
     }
-    if(manager != null)
-    {
+    if (manager != null) {
       AssertJUnit.assertFalse(manager.isConnected());
     }
 
     setupCluster();
-    String instanceStatusUpdatePath = HelixUtil.getInstancePropertyPath(CLUSTER_NAME, "localhost_" + (START_PORT + 1), PropertyType.STATUSUPDATES);
+    String instanceStatusUpdatePath =
+        HelixUtil.getInstancePropertyPath(CLUSTER_NAME, "localhost_" + (START_PORT + 1),
+            PropertyType.STATUSUPDATES);
     _zkClient.deleteRecursive(instanceStatusUpdatePath);
 
-    try
-    {
-      manager = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME,
-                                                          "localhost_" + (START_PORT + 1),
-                                                          InstanceType.PARTICIPANT,
-                                                          ZK_ADDR);
+    try {
+      manager =
+          HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, "localhost_" + (START_PORT + 1),
+              InstanceType.PARTICIPANT, ZK_ADDR);
       manager.connect();
       Assert.fail("Should fail on connect() since cluster structure is not set up");
-    }
-    catch(HelixException e)
-    {
+    } catch (HelixException e) {
       // OK
     }
-    if(manager != null)
-    {
+    if (manager != null) {
       AssertJUnit.assertFalse(manager.isConnected());
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/test/java/org/apache/helix/integration/TestCustomIdealState.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestCustomIdealState.java b/helix-core/src/test/java/org/apache/helix/integration/TestCustomIdealState.java
index 130b467..43cfa5a 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestCustomIdealState.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestCustomIdealState.java
@@ -30,43 +30,38 @@ import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-
-public class TestCustomIdealState extends ZkIntegrationTestBase
-{
+public class TestCustomIdealState extends ZkIntegrationTestBase {
   private static Logger LOG = Logger.getLogger(TestCustomIdealState.class);
   ZkClient _zkClient;
 
   @BeforeClass
-  public void beforeClass() throws Exception
-  {
+  public void beforeClass() throws Exception {
     _zkClient = new ZkClient(ZK_ADDR);
     _zkClient.setZkSerializer(new ZNRecordSerializer());
   }
 
   @AfterClass
-  public void afterClass()
-  {
+  public void afterClass() {
     _zkClient.close();
   }
 
   @Test
-  public void testBasic() throws Exception
-  {
+  public void testBasic() throws Exception {
 
     int numResources = 2;
     int numPartitionsPerResource = 100;
     int numInstance = 5;
     int replica = 3;
 
-    String uniqClusterName = "TestCustomIS_" + "rg" + numResources + "_p" + numPartitionsPerResource
-        + "_n" + numInstance + "_r" + replica + "_basic";
+    String uniqClusterName =
+        "TestCustomIS_" + "rg" + numResources + "_p" + numPartitionsPerResource + "_n"
+            + numInstance + "_r" + replica + "_basic";
     System.out.println("START " + uniqClusterName + " at " + new Date(System.currentTimeMillis()));
 
     TestDriver.setupClusterWithoutRebalance(uniqClusterName, ZK_ADDR, numResources,
         numPartitionsPerResource, numInstance, replica);
 
-    for (int i = 0; i < numInstance; i++)
-    {
+    for (int i = 0; i < numInstance; i++) {
       TestDriver.startDummyParticipant(uniqClusterName, i);
     }
     TestDriver.startController(uniqClusterName);
@@ -80,22 +75,21 @@ public class TestCustomIdealState extends ZkIntegrationTestBase
   }
 
   @Test
-  public void testNonAliveInstances() throws Exception
-  {
+  public void testNonAliveInstances() throws Exception {
     int numResources = 2;
     int numPartitionsPerResource = 50;
     int numInstance = 5;
     int replica = 3;
 
-    String uniqClusterName = "TestCustomIS_" + "rg" + numResources + "_p" + numPartitionsPerResource
-        + "_n" + numInstance + "_r" + replica + "_nonalive";
+    String uniqClusterName =
+        "TestCustomIS_" + "rg" + numResources + "_p" + numPartitionsPerResource + "_n"
+            + numInstance + "_r" + replica + "_nonalive";
     System.out.println("START " + uniqClusterName + " at " + new Date(System.currentTimeMillis()));
 
     TestDriver.setupClusterWithoutRebalance(uniqClusterName, ZK_ADDR, numResources,
         numPartitionsPerResource, numInstance, replica);
 
-    for (int i = 0; i < numInstance / 2; i++)
-    {
+    for (int i = 0; i < numInstance / 2; i++) {
       TestDriver.startDummyParticipant(uniqClusterName, i);
     }
 
@@ -106,8 +100,7 @@ public class TestCustomIdealState extends ZkIntegrationTestBase
     Thread.sleep(1000);
 
     // start the rest of participants after ideal state is set
-    for (int i = numInstance / 2; i < numInstance; i++)
-    {
+    for (int i = numInstance / 2; i < numInstance; i++) {
       TestDriver.startDummyParticipant(uniqClusterName, i);
     }
 
@@ -120,22 +113,21 @@ public class TestCustomIdealState extends ZkIntegrationTestBase
   }
 
   @Test()
-  public void testDrop() throws Exception
-  {
+  public void testDrop() throws Exception {
     int numResources = 2;
     int numPartitionsPerResource = 50;
     int numInstance = 5;
     int replica = 3;
 
-    String uniqClusterName = "TestCustomIS_" + "rg" + numResources + "_p" + numPartitionsPerResource
-        + "_n" + numInstance + "_r" + replica + "_drop";
+    String uniqClusterName =
+        "TestCustomIS_" + "rg" + numResources + "_p" + numPartitionsPerResource + "_n"
+            + numInstance + "_r" + replica + "_drop";
 
     System.out.println("START " + uniqClusterName + " at " + new Date(System.currentTimeMillis()));
     TestDriver.setupClusterWithoutRebalance(uniqClusterName, ZK_ADDR, numResources,
         numPartitionsPerResource, numInstance, replica);
 
-    for (int i = 0; i < numInstance; i++)
-    {
+    for (int i = 0; i < numInstance; i++) {
       TestDriver.startDummyParticipant(uniqClusterName, i);
     }
     TestDriver.startController(uniqClusterName);
@@ -146,9 +138,9 @@ public class TestCustomIdealState extends ZkIntegrationTestBase
     ClusterSetup setup = new ClusterSetup(ZK_ADDR);
     setup.dropResourceFromCluster(uniqClusterName, "TestDB0");
 
-    TestHelper.verifyWithTimeout("verifyEmptyCurStateAndExtView", 30 * 1000, uniqClusterName, "TestDB0",
-        TestHelper.<String> setOf("localhost_12918", "localhost_12919", "localhost_12920",
-            "localhost_12921", "localhost_12922"), ZK_ADDR);
+    TestHelper.verifyWithTimeout("verifyEmptyCurStateAndExtView", 30 * 1000, uniqClusterName,
+        "TestDB0", TestHelper.<String> setOf("localhost_12918", "localhost_12919",
+            "localhost_12920", "localhost_12921", "localhost_12922"), ZK_ADDR);
 
     TestDriver.stopCluster(uniqClusterName);
     System.out.println("STOP " + uniqClusterName + " at " + new Date(System.currentTimeMillis()));

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/test/java/org/apache/helix/integration/TestCustomizedIdealStateRebalancer.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestCustomizedIdealStateRebalancer.java b/helix-core/src/test/java/org/apache/helix/integration/TestCustomizedIdealStateRebalancer.java
index 291bfcf..7811c0d 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestCustomizedIdealStateRebalancer.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestCustomizedIdealStateRebalancer.java
@@ -1,4 +1,5 @@
 package org.apache.helix.integration;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -40,31 +41,26 @@ import org.apache.helix.tools.ClusterStateVerifier.ZkVerifier;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-public class TestCustomizedIdealStateRebalancer extends ZkStandAloneCMTestBaseWithPropertyServerCheck
-{
-  String db2 = TEST_DB+"2";
+public class TestCustomizedIdealStateRebalancer extends
+    ZkStandAloneCMTestBaseWithPropertyServerCheck {
+  String db2 = TEST_DB + "2";
   static boolean testRebalancerCreated = false;
 
-  public static class TestRebalancer extends SemiAutoRebalancer
-  {
+  public static class TestRebalancer extends SemiAutoRebalancer {
 
     @Override
-    public void init(HelixManager manager)
-    {
+    public void init(HelixManager manager) {
       testRebalancerCreated = true;
     }
 
     @Override
-    public IdealState computeNewIdealState(String resourceName,
-        IdealState currentIdealState, CurrentStateOutput currentStateOutput,
-        ClusterDataCache clusterData)
-    {
-      for(String partition : currentIdealState.getPartitionSet())
-      {
+    public IdealState computeNewIdealState(String resourceName, IdealState currentIdealState,
+        CurrentStateOutput currentStateOutput, ClusterDataCache clusterData) {
+      for (String partition : currentIdealState.getPartitionSet()) {
         String instance = currentIdealState.getPreferenceList(partition).get(0);
         currentIdealState.getPreferenceList(partition).clear();
         currentIdealState.getPreferenceList(partition).add(instance);
-        
+
         currentIdealState.getInstanceStateMap(partition).clear();
         currentIdealState.getInstanceStateMap(partition).put(instance, "MASTER");
       }
@@ -74,8 +70,7 @@ public class TestCustomizedIdealStateRebalancer extends ZkStandAloneCMTestBaseWi
   }
 
   @Test
-  public void testCustomizedIdealStateRebalancer() throws InterruptedException
-  {
+  public void testCustomizedIdealStateRebalancer() throws InterruptedException {
     _setupTool.addResourceToCluster(CLUSTER_NAME, db2, 60, "MasterSlave");
     _setupTool.addResourceProperty(CLUSTER_NAME, db2,
         IdealStateProperty.REBALANCER_CLASS_NAME.toString(),
@@ -84,133 +79,119 @@ public class TestCustomizedIdealStateRebalancer extends ZkStandAloneCMTestBaseWi
         RebalanceMode.USER_DEFINED.toString());
 
     _setupTool.rebalanceStorageCluster(CLUSTER_NAME, db2, 3);
-    
+
     boolean result =
         ClusterStateVerifier.verifyByZkCallback(new ExternalViewBalancedVerifier(_zkClient,
-                                                                              CLUSTER_NAME, db2));
+            CLUSTER_NAME, db2));
     Assert.assertTrue(result);
     Thread.sleep(1000);
-    HelixDataAccessor accessor = new ZKHelixDataAccessor( CLUSTER_NAME, new ZkBaseDataAccessor(_zkClient));
+    HelixDataAccessor accessor =
+        new ZKHelixDataAccessor(CLUSTER_NAME, new ZkBaseDataAccessor(_zkClient));
     Builder keyBuilder = accessor.keyBuilder();
     ExternalView ev = accessor.getProperty(keyBuilder.externalView(db2));
     Assert.assertEquals(ev.getPartitionSet().size(), 60);
-    for(String partition: ev.getPartitionSet())
-    {
+    for (String partition : ev.getPartitionSet()) {
       Assert.assertEquals(ev.getStateMap(partition).size(), 1);
     }
     IdealState is = accessor.getProperty(keyBuilder.idealStates(db2));
-    for(String partition: is.getPartitionSet())
-    {
+    for (String partition : is.getPartitionSet()) {
       Assert.assertEquals(is.getPreferenceList(partition).size(), 3);
       Assert.assertEquals(is.getInstanceStateMap(partition).size(), 3);
     }
     Assert.assertTrue(testRebalancerCreated);
   }
 
-  public static class ExternalViewBalancedVerifier implements ZkVerifier
-  {
+  public static class ExternalViewBalancedVerifier implements ZkVerifier {
     ZkClient _client;
     String _clusterName;
     String _resourceName;
-    
-    public ExternalViewBalancedVerifier(ZkClient client, String clusterName, String resourceName)
-    {
+
+    public ExternalViewBalancedVerifier(ZkClient client, String clusterName, String resourceName) {
       _client = client;
       _clusterName = clusterName;
       _resourceName = resourceName;
     }
+
     @Override
-    public boolean verify()
-    {
-      try
-      {
-        HelixDataAccessor accessor = new ZKHelixDataAccessor( _clusterName, new ZkBaseDataAccessor(_client));
+    public boolean verify() {
+      try {
+        HelixDataAccessor accessor =
+            new ZKHelixDataAccessor(_clusterName, new ZkBaseDataAccessor(_client));
         Builder keyBuilder = accessor.keyBuilder();
-        int numberOfPartitions = accessor.getProperty(keyBuilder.idealStates(_resourceName)).getRecord().getListFields().size();
+        int numberOfPartitions =
+            accessor.getProperty(keyBuilder.idealStates(_resourceName)).getRecord().getListFields()
+                .size();
         ClusterDataCache cache = new ClusterDataCache();
         cache.refresh(accessor);
-        String masterValue = cache.getStateModelDef(cache.getIdealState(_resourceName).getStateModelDefRef()).getStatesPriorityList().get(0);
+        String masterValue =
+            cache.getStateModelDef(cache.getIdealState(_resourceName).getStateModelDefRef())
+                .getStatesPriorityList().get(0);
         int replicas = Integer.parseInt(cache.getIdealState(_resourceName).getReplicas());
         String instanceGroupTag = cache.getIdealState(_resourceName).getInstanceGroupTag();
         int instances = 0;
-        for(String  liveInstanceName : cache.getLiveInstances().keySet())
-        {
-          if(cache.getInstanceConfigMap().get(liveInstanceName).containsTag(instanceGroupTag))
-          {
-            instances ++;
+        for (String liveInstanceName : cache.getLiveInstances().keySet()) {
+          if (cache.getInstanceConfigMap().get(liveInstanceName).containsTag(instanceGroupTag)) {
+            instances++;
           }
         }
-        if(instances == 0)
-        {
+        if (instances == 0) {
           instances = cache.getLiveInstances().size();
         }
-        return verifyBalanceExternalView(accessor.getProperty(keyBuilder.externalView(_resourceName)).getRecord(), numberOfPartitions, masterValue, replicas, instances);
-      }
-      catch(Exception e)
-      {
+        return verifyBalanceExternalView(
+            accessor.getProperty(keyBuilder.externalView(_resourceName)).getRecord(),
+            numberOfPartitions, masterValue, replicas, instances);
+      } catch (Exception e) {
         return false;
       }
     }
 
     @Override
-    public ZkClient getZkClient()
-    {
+    public ZkClient getZkClient() {
       return _client;
     }
 
     @Override
-    public String getClusterName()
-    {
+    public String getClusterName() {
       return _clusterName;
     }
-    
+
   }
-  
 
-  static boolean verifyBalanceExternalView(ZNRecord externalView, int partitionCount, String masterState, int replica, int instances)
-  {
+  static boolean verifyBalanceExternalView(ZNRecord externalView, int partitionCount,
+      String masterState, int replica, int instances) {
     Map<String, Integer> masterPartitionsCountMap = new HashMap<String, Integer>();
-    for(String partitionName : externalView.getMapFields().keySet())
-    {
+    for (String partitionName : externalView.getMapFields().keySet()) {
       Map<String, String> assignmentMap = externalView.getMapField(partitionName);
-      //Assert.assertTrue(assignmentMap.size() >= replica);
-      for(String instance : assignmentMap.keySet())
-      {
-        if(assignmentMap.get(instance).equals(masterState))
-        {
-          if(!masterPartitionsCountMap.containsKey(instance))
-          {
+      // Assert.assertTrue(assignmentMap.size() >= replica);
+      for (String instance : assignmentMap.keySet()) {
+        if (assignmentMap.get(instance).equals(masterState)) {
+          if (!masterPartitionsCountMap.containsKey(instance)) {
             masterPartitionsCountMap.put(instance, 0);
           }
           masterPartitionsCountMap.put(instance, masterPartitionsCountMap.get(instance) + 1);
         }
       }
     }
-    
+
     int perInstancePartition = partitionCount / instances;
-    
+
     int totalCount = 0;
-    for(String instanceName : masterPartitionsCountMap.keySet())
-    {
+    for (String instanceName : masterPartitionsCountMap.keySet()) {
       int instancePartitionCount = masterPartitionsCountMap.get(instanceName);
       totalCount += instancePartitionCount;
-      if(!(instancePartitionCount == perInstancePartition || instancePartitionCount == perInstancePartition +1 ))
-      {
+      if (!(instancePartitionCount == perInstancePartition || instancePartitionCount == perInstancePartition + 1)) {
         return false;
       }
-      if(instancePartitionCount == perInstancePartition +1)
-      {
-        if(partitionCount % instances == 0)
-        {
+      if (instancePartitionCount == perInstancePartition + 1) {
+        if (partitionCount % instances == 0) {
           return false;
         }
       }
     }
-    if(partitionCount != totalCount)
-    {
+    if (partitionCount != totalCount) {
       return false;
     }
     return true;
-    
+
   }
 }


Mime
View raw message