helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject [23/51] [partial] [HELIX-198] Unify helix code style, rb=13710
Date Wed, 21 Aug 2013 20:43:36 GMT
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/tools/ZkLogAnalyzer.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/tools/ZkLogAnalyzer.java b/helix-core/src/main/java/org/apache/helix/tools/ZkLogAnalyzer.java
index 9c10422..11e1b66 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/ZkLogAnalyzer.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/ZkLogAnalyzer.java
@@ -41,38 +41,31 @@ import org.apache.helix.model.Message;
 import org.apache.helix.model.Message.MessageState;
 import org.apache.log4j.Logger;
 
-
-public class ZkLogAnalyzer
-{
-  private static Logger           LOG           = Logger.getLogger(ZkLogAnalyzer.class);
-  private static boolean          dump          = false;                                 ;
+public class ZkLogAnalyzer {
+  private static Logger LOG = Logger.getLogger(ZkLogAnalyzer.class);
+  private static boolean dump = false;;
   final static ZNRecordSerializer _deserializer = new ZNRecordSerializer();
 
-  static class Stats
-  {
-    int msgSentCount        = 0;
-    int msgSentCount_O2S    = 0; // Offline to Slave
-    int msgSentCount_S2M    = 0; // Slave to Master
-    int msgSentCount_M2S    = 0; // Master to Slave
-    int msgDeleteCount      = 0;
-    int msgModifyCount      = 0;
+  static class Stats {
+    int msgSentCount = 0;
+    int msgSentCount_O2S = 0; // Offline to Slave
+    int msgSentCount_S2M = 0; // Slave to Master
+    int msgSentCount_M2S = 0; // Master to Slave
+    int msgDeleteCount = 0;
+    int msgModifyCount = 0;
     int curStateCreateCount = 0;
     int curStateUpdateCount = 0;
-    int extViewCreateCount  = 0;
-    int extViewUpdateCount  = 0;
+    int extViewCreateCount = 0;
+    int extViewUpdateCount = 0;
   }
 
-  static String getAttributeValue(String line, String attribute)
-  {
+  static String getAttributeValue(String line, String attribute) {
     if (line == null)
       return null;
     String[] parts = line.split("\\s");
-    if (parts != null && parts.length > 0)
-    {
-      for (int i = 0; i < parts.length; i++)
-      {
-        if (parts[i].startsWith(attribute))
-        {
+    if (parts != null && parts.length > 0) {
+      for (int i = 0; i < parts.length; i++) {
+        if (parts[i].startsWith(attribute)) {
           String val = parts[i].substring(attribute.length());
           return val;
         }
@@ -81,16 +74,13 @@ public class ZkLogAnalyzer
     return null;
   }
 
-  static String findLastCSUpdateBetween(List<String> csUpdateLines, long start, long end)
-  {
+  static String findLastCSUpdateBetween(List<String> csUpdateLines, long start, long end) {
     long lastCSUpdateTimestamp = Long.MIN_VALUE;
     String lastCSUpdateLine = null;
-    for (String line : csUpdateLines)
-    {
+    for (String line : csUpdateLines) {
       // ZNRecord record = getZNRecord(line);
       long timestamp = Long.parseLong(getAttributeValue(line, "time:"));
-      if (timestamp >= start && timestamp <= end && timestamp > lastCSUpdateTimestamp)
-      {
+      if (timestamp >= start && timestamp <= end && timestamp > lastCSUpdateTimestamp) {
         lastCSUpdateTimestamp = timestamp;
         lastCSUpdateLine = line;
       }
@@ -99,12 +89,10 @@ public class ZkLogAnalyzer
     return lastCSUpdateLine;
   }
 
-  static ZNRecord getZNRecord(String line)
-  {
+  static ZNRecord getZNRecord(String line) {
     ZNRecord record = null;
     String value = getAttributeValue(line, "data:");
-    if (value != null)
-    {
+    if (value != null) {
       record = (ZNRecord) _deserializer.deserialize(value.getBytes());
       // if (record == null)
       // {
@@ -114,11 +102,10 @@ public class ZkLogAnalyzer
     return record;
   }
 
-  public static void main(String[] args) throws Exception
-  {
-    if (args.length != 3)
-    {
-      System.err.println("USAGE: ZkLogAnalyzer zkLogDir clusterName testStartTime (yyMMdd_hhmmss_SSS)");
+  public static void main(String[] args) throws Exception {
+    if (args.length != 3) {
+      System.err
+          .println("USAGE: ZkLogAnalyzer zkLogDir clusterName testStartTime (yyMMdd_hhmmss_SSS)");
       System.exit(1);
     }
 
@@ -138,48 +125,42 @@ public class ZkLogAnalyzer
     long startTimeStamp = date.getTime();
 
     System.out.println(clusterName + " created at " + date);
-    while (zkLogDir.endsWith("/"))
-    {
+    while (zkLogDir.endsWith("/")) {
       zkLogDir = zkLogDir.substring(0, zkLogDir.length() - 1);
     }
-    if (!zkLogDir.endsWith("/version-2"))
-    {
+    if (!zkLogDir.endsWith("/version-2")) {
       zkLogDir = zkLogDir + "/version-2";
     }
     File dir = new File(zkLogDir);
-    File[] zkLogs = dir.listFiles(new FileFilter()
-    {
+    File[] zkLogs = dir.listFiles(new FileFilter() {
 
       @Override
-      public boolean accept(File file)
-      {
+      public boolean accept(File file) {
         return file.isFile() && (file.getName().indexOf("log") != -1);
       }
     });
 
     // lastModified time -> zkLog
     TreeMap<Long, String> lastZkLogs = new TreeMap<Long, String>();
-    for (File file : zkLogs)
-    {
-      if (file.lastModified() > startTimeStamp)
-      {
+    for (File file : zkLogs) {
+      if (file.lastModified() > startTimeStamp) {
         lastZkLogs.put(file.lastModified(), file.getAbsolutePath());
       }
     }
 
     List<String> parsedZkLogs = new ArrayList<String>();
     int i = 0;
-    System.out.println("zk logs last modified later than "
-        + new Timestamp(startTimeStamp));
-    for (Long lastModified : lastZkLogs.keySet())
-    {
+    System.out.println("zk logs last modified later than " + new Timestamp(startTimeStamp));
+    for (Long lastModified : lastZkLogs.keySet()) {
       String fileName = lastZkLogs.get(lastModified);
       System.out.println(new Timestamp(lastModified) + ": "
           + (fileName.substring(fileName.lastIndexOf('/') + 1)));
 
       String parsedFileName = "zkLogAnalyzor_zklog.parsed" + i;
       i++;
-      ZKLogFormatter.main(new String[] { "log", fileName, parsedFileName });
+      ZKLogFormatter.main(new String[] {
+          "log", fileName, parsedFileName
+      });
       parsedZkLogs.add(parsedFileName);
     }
 
@@ -198,48 +179,40 @@ public class ZkLogAnalyzer
     Stats stats = new Stats();
     long lastTestStartTimestamp = Long.MAX_VALUE;
     long controllerStartTime = 0;
-    for (String parsedZkLog : parsedZkLogs)
-    {
+    for (String parsedZkLog : parsedZkLogs) {
 
       FileInputStream fis = new FileInputStream(parsedZkLog);
       BufferedReader br = new BufferedReader(new InputStreamReader(fis));
 
       String inputLine;
-      while ((inputLine = br.readLine()) != null)
-      {
+      while ((inputLine = br.readLine()) != null) {
         String timestamp = getAttributeValue(inputLine, "time:");
-        if (timestamp == null)
-        {
+        if (timestamp == null) {
           continue;
         }
         long timestampVal = Long.parseLong(timestamp);
-        if (timestampVal < startTimeStamp)
-        {
+        if (timestampVal < startTimeStamp) {
           continue;
         }
 
-        if (dump == true)
-        {
+        if (dump == true) {
           String printLine = inputLine.replaceAll("data:.*", "");
-          printLine = new Timestamp(timestampVal) + " " + printLine.substring(printLine.indexOf("session:"));
+          printLine =
+              new Timestamp(timestampVal) + " "
+                  + printLine.substring(printLine.indexOf("session:"));
           System.err.println(printLine);
         }
 
-        if (inputLine.indexOf("/start_disable") != -1)
-        {
+        if (inputLine.indexOf("/start_disable") != -1) {
           dump = true;
         }
-        if (inputLine.indexOf("/" + clusterName + "/CONFIGS/CLUSTER/verify") != -1)
-        {
+        if (inputLine.indexOf("/" + clusterName + "/CONFIGS/CLUSTER/verify") != -1) {
           String type = getAttributeValue(inputLine, "type:");
-          if (type.equals("delete"))
-          {
+          if (type.equals("delete")) {
             System.out.println(timestamp + ": verify done");
             System.out.println("lastTestStartTimestamp:" + lastTestStartTimestamp);
             String lastCSUpdateLine =
-                findLastCSUpdateBetween(csUpdateLines,
-                                        lastTestStartTimestamp,
-                                        timestampVal);
+                findLastCSUpdateBetween(csUpdateLines, lastTestStartTimestamp, timestampVal);
             long lastCSUpdateTimestamp =
                 Long.parseLong(getAttributeValue(lastCSUpdateLine, "time:"));
             System.out.println("Last CS Update:" + lastCSUpdateTimestamp);
@@ -250,9 +223,8 @@ public class ZkLogAnalyzer
             System.out.println("state transition latency since controller start: "
                 + +(lastCSUpdateTimestamp - controllerStartTime) + "ms");
 
-            System.out.println("Create MSG\t" + stats.msgSentCount + "\t"
-                + stats.msgSentCount_O2S + "\t" + stats.msgSentCount_S2M + "\t"
-                + stats.msgSentCount_M2S);
+            System.out.println("Create MSG\t" + stats.msgSentCount + "\t" + stats.msgSentCount_O2S
+                + "\t" + stats.msgSentCount_S2M + "\t" + stats.msgSentCount_M2S);
             System.out.println("Modify MSG\t" + stats.msgModifyCount);
             System.out.println("Delete MSG\t" + stats.msgDeleteCount);
             System.out.println("Create CS\t" + stats.curStateCreateCount);
@@ -264,12 +236,9 @@ public class ZkLogAnalyzer
             stats = new Stats();
             lastTestStartTimestamp = Long.MAX_VALUE;
           }
-        }
-        else if (inputLine.indexOf("/" + clusterName + "/LIVEINSTANCES/") != -1)
-        {
+        } else if (inputLine.indexOf("/" + clusterName + "/LIVEINSTANCES/") != -1) {
           // cluster startup
-          if (timestampVal < lastTestStartTimestamp)
-          {
+          if (timestampVal < lastTestStartTimestamp) {
             System.out.println("START cluster. SETTING lastTestStartTimestamp to "
                 + new Timestamp(timestampVal) + "\nline:" + inputLine);
             lastTestStartTimestamp = timestampVal;
@@ -281,15 +250,11 @@ public class ZkLogAnalyzer
           sessionMap.put(session, inputLine);
           System.out.println(new Timestamp(Long.parseLong(timestamp)) + ": create LIVEINSTANCE "
               + liveInstance.getInstanceName());
-        }
-        else if (inputLine.indexOf("closeSession") != -1)
-        {
+        } else if (inputLine.indexOf("closeSession") != -1) {
           // kill any instance
           String session = getAttributeValue(inputLine, "session:");
-          if (sessionMap.containsKey(session))
-          {
-            if (timestampVal < lastTestStartTimestamp)
-            {
+          if (sessionMap.containsKey(session)) {
+            if (timestampVal < lastTestStartTimestamp) {
               System.out.println("KILL node. SETTING lastTestStartTimestamp to " + timestampVal
                   + " line:" + inputLine);
               lastTestStartTimestamp = timestampVal;
@@ -302,22 +267,17 @@ public class ZkLogAnalyzer
                 + liveInstance.getInstanceName());
             dump = true;
           }
-        }
-        else if (inputLine.indexOf("/" + clusterName + "/CONFIGS/PARTICIPANT") != -1)
-        {
+        } else if (inputLine.indexOf("/" + clusterName + "/CONFIGS/PARTICIPANT") != -1) {
           // disable a partition
           String type = getAttributeValue(inputLine, "type:");
-          if (type.equals("setData") && inputLine.indexOf("HELIX_DISABLED_PARTITION") != -1)
-          {
-            if (timestampVal < lastTestStartTimestamp)
-            {
-              System.out.println("DISABLE partition. SETTING lastTestStartTimestamp to " + timestampVal
-                  + " line:" + inputLine);
+          if (type.equals("setData") && inputLine.indexOf("HELIX_DISABLED_PARTITION") != -1) {
+            if (timestampVal < lastTestStartTimestamp) {
+              System.out.println("DISABLE partition. SETTING lastTestStartTimestamp to "
+                  + timestampVal + " line:" + inputLine);
               lastTestStartTimestamp = timestampVal;
             }
           }
-        } else if (inputLine.indexOf("/" + clusterName + "/CONTROLLER/LEADER") != -1)
-        {
+        } else if (inputLine.indexOf("/" + clusterName + "/CONTROLLER/LEADER") != -1) {
           // leaderLine = inputLine;
           ZNRecord record = getZNRecord(inputLine);
           LiveInstance liveInstance = new LiveInstance(record);
@@ -327,38 +287,26 @@ public class ZkLogAnalyzer
           sessionMap.put(session, inputLine);
           System.out.println(new Timestamp(Long.parseLong(timestamp)) + ": create LEADER "
               + liveInstance.getInstanceName());
-        }
-        else if (inputLine.indexOf("/" + clusterName + "/") != -1
-            && inputLine.indexOf("/CURRENTSTATES/") != -1)
-        {
+        } else if (inputLine.indexOf("/" + clusterName + "/") != -1
+            && inputLine.indexOf("/CURRENTSTATES/") != -1) {
           String type = getAttributeValue(inputLine, "type:");
-          if (type.equals("create"))
-          {
+          if (type.equals("create")) {
             stats.curStateCreateCount++;
-          }
-          else if (type.equals("setData"))
-          {
+          } else if (type.equals("setData")) {
             String path = getAttributeValue(inputLine, "path:");
             csUpdateLines.add(inputLine);
             stats.curStateUpdateCount++;
             // getAttributeValue(line, "data");
-            System.out.println("Update currentstate:"
-                + new Timestamp(Long.parseLong(timestamp)) + ":" + timestamp + " path:"
-                + path);
+            System.out.println("Update currentstate:" + new Timestamp(Long.parseLong(timestamp))
+                + ":" + timestamp + " path:" + path);
           }
-        }
-        else if (inputLine.indexOf("/" + clusterName + "/EXTERNALVIEW/") != -1)
-        {
+        } else if (inputLine.indexOf("/" + clusterName + "/EXTERNALVIEW/") != -1) {
           String session = getAttributeValue(inputLine, "session:");
-          if (session.equals(leaderSession))
-          {
+          if (session.equals(leaderSession)) {
             String type = getAttributeValue(inputLine, "type:");
-            if (type.equals("create"))
-            {
+            if (type.equals("create")) {
               stats.extViewCreateCount++;
-            }
-            else if (type.equals("setData"))
-            {
+            } else if (type.equals("setData")) {
               stats.extViewUpdateCount++;
             }
           }
@@ -381,37 +329,24 @@ public class ZkLogAnalyzer
           // + " has " + masterCnt + " MASTER, " + slaveCnt + " SLAVE");
           // }
           // }
-        }
-        else if (inputLine.indexOf("/" + clusterName + "/") != -1
-            && inputLine.indexOf("/MESSAGES/") != -1)
-        {
+        } else if (inputLine.indexOf("/" + clusterName + "/") != -1
+            && inputLine.indexOf("/MESSAGES/") != -1) {
           String type = getAttributeValue(inputLine, "type:");
 
-          if (type.equals("create"))
-          {
+          if (type.equals("create")) {
             ZNRecord record = getZNRecord(inputLine);
             Message msg = new Message(record);
             String sendSession = getAttributeValue(inputLine, "session:");
-            if (sendSession.equals(leaderSession)
-                && msg.getMsgType().equals("STATE_TRANSITION")
-                && msg.getMsgState() == MessageState.NEW)
-            {
+            if (sendSession.equals(leaderSession) && msg.getMsgType().equals("STATE_TRANSITION")
+                && msg.getMsgState() == MessageState.NEW) {
               // sendMessageLines.add(inputLine);
               stats.msgSentCount++;
 
-              if (msg.getFromState().equals("OFFLINE")
-                  && msg.getToState().equals("SLAVE"))
-              {
+              if (msg.getFromState().equals("OFFLINE") && msg.getToState().equals("SLAVE")) {
                 stats.msgSentCount_O2S++;
-              }
-              else if (msg.getFromState().equals("SLAVE")
-                  && msg.getToState().equals("MASTER"))
-              {
+              } else if (msg.getFromState().equals("SLAVE") && msg.getToState().equals("MASTER")) {
                 stats.msgSentCount_S2M++;
-              }
-              else if (msg.getFromState().equals("MASTER")
-                  && msg.getToState().equals("SLAVE"))
-              {
+              } else if (msg.getFromState().equals("MASTER") && msg.getToState().equals("SLAVE")) {
                 stats.msgSentCount_M2S++;
               }
               // System.out.println("Message create:"+new
@@ -444,9 +379,7 @@ public class ZkLogAnalyzer
             // + msg.getTgtName() + ", size: " + msgBytes.length);
             // }
             // }
-          }
-          else if (type.equals("setData"))
-          {
+          } else if (type.equals("setData")) {
             stats.msgModifyCount++;
             // pos = inputLine.indexOf("MESSAGES");
             // pos = inputLine.indexOf("data:{", pos);
@@ -481,9 +414,7 @@ public class ZkLogAnalyzer
             //
             // }
             // }
-          }
-          else if (type.equals("delete"))
-          {
+          } else if (type.equals("delete")) {
             stats.msgDeleteCount++;
             // String msgId = path.substring(path.lastIndexOf('/') + 1);
             // if (msgs.containsKey(msgId))

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/tools/ZkLogCSVFormatter.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/tools/ZkLogCSVFormatter.java b/helix-core/src/main/java/org/apache/helix/tools/ZkLogCSVFormatter.java
index 04c503a..fde9615 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/ZkLogCSVFormatter.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/ZkLogCSVFormatter.java
@@ -37,70 +37,53 @@ import org.apache.helix.manager.zk.ZNRecordSerializer;
 import org.apache.helix.model.IdealState.IdealStateProperty;
 import org.apache.helix.util.HelixUtil;
 
-
-public class ZkLogCSVFormatter
-{
+public class ZkLogCSVFormatter {
   private static final ZNRecordSerializer _deserializer = new ZNRecordSerializer();
   private static String _fieldDelim = ",";
 
   /**
    * @param args
    */
-  public static void main(String[] args) throws Exception
-  {
-    if (args.length != 2)
-    {
+  public static void main(String[] args) throws Exception {
+    if (args.length != 2) {
       System.err.println("USAGE: ZkLogCSVFormatter log_file output_dir");
       System.exit(2);
     }
     File outputDir = new File(args[1]);
-    if (!outputDir.exists() || !outputDir.isDirectory())
-    {
+    if (!outputDir.exists() || !outputDir.isDirectory()) {
       System.err.println(outputDir.getAbsolutePath() + " does NOT exist or is NOT a directory");
       System.exit(2);
     }
     format(args[0], args[1]);
   }
 
-  private static void formatter(BufferedWriter bw, String... args)
-  {
+  private static void formatter(BufferedWriter bw, String... args) {
     StringBuffer sb = new StringBuffer();
 
-    if (args.length == 0)
-    {
+    if (args.length == 0) {
       return;
-    }
-    else
-    {
+    } else {
       sb.append(args[0]);
-      for (int i = 1; i < args.length; i++)
-      {
+      for (int i = 1; i < args.length; i++) {
         sb.append(_fieldDelim).append(args[i]);
       }
     }
 
-    try
-    {
+    try {
       bw.write(sb.toString());
       bw.newLine();
       // System.out.println(sb.toString());
-    }
-    catch (IOException e)
-    {
+    } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
 
-  private static String getAttributeValue(String line, String attribute)
-  {
+  private static String getAttributeValue(String line, String attribute) {
     String[] parts = line.split("\\s");
-    if (parts != null && parts.length > 0)
-    {
-      for (int i = 0; i < parts.length; i++)
-      {
-        if (parts[i].startsWith(attribute))
-        {
+    if (parts != null && parts.length > 0) {
+      for (int i = 0; i < parts.length; i++) {
+        if (parts[i].startsWith(attribute)) {
           String val = parts[i].substring(attribute.length());
           return val;
         }
@@ -109,10 +92,8 @@ public class ZkLogCSVFormatter
     return null;
   }
 
-  private static void format(String logfilepath, String outputDir) throws FileNotFoundException
-  {
-    try
-    {
+  private static void format(String logfilepath, String outputDir) throws FileNotFoundException {
+    try {
       // input file
       FileInputStream fis = new FileInputStream(logfilepath);
       BufferedReader br = new BufferedReader(new InputStreamReader(fis));
@@ -141,290 +122,182 @@ public class ZkLogCSVFormatter
       FileOutputStream msgFos = new FileOutputStream(outputDir + "/" + "messages.csv");
       BufferedWriter msgBw = new BufferedWriter(new OutputStreamWriter(msgFos));
 
-      FileOutputStream hrPerfFos = new FileOutputStream(outputDir + "/" + "healthReportDefaultPerfCounters.csv");
+      FileOutputStream hrPerfFos =
+          new FileOutputStream(outputDir + "/" + "healthReportDefaultPerfCounters.csv");
       BufferedWriter hrPerfBw = new BufferedWriter(new OutputStreamWriter(hrPerfFos));
 
-      FileOutputStream liFos =
-          new FileOutputStream(outputDir + "/" + "liveInstances.csv");
+      FileOutputStream liFos = new FileOutputStream(outputDir + "/" + "liveInstances.csv");
       BufferedWriter liBw = new BufferedWriter(new OutputStreamWriter(liFos));
 
       formatter(cfgBw, "timestamp", "instanceName", "host", "port", "enabled");
-      formatter(isBw,
-                "timestamp",
-                "resourceName",
-                "partitionNumber",
-                "mode",
-                "partition",
-                "instanceName",
-                "priority");
+      formatter(isBw, "timestamp", "resourceName", "partitionNumber", "mode", "partition",
+          "instanceName", "priority");
       formatter(evBw, "timestamp", "resourceName", "partition", "instanceName", "state");
       formatter(smdCntBw, "timestamp", "stateModel", "state", "count");
       formatter(smdNextBw, "timestamp", "stateModel", "from", "to", "next");
       formatter(liBw, "timestamp", "instanceName", "sessionId", "Operation");
-      formatter(csBw,
-                "timestamp",
-                "resourceName",
-                "partition",
-                "instanceName",
-                "sessionId",
-                "state");
-      formatter(msgBw,
-                "timestamp",
-                "resourceName",
-                "partition",
-                "instanceName",
-                "sessionId",
-                "from",
-                "to",
-                "messageType",
-                "messageState");
-      formatter(hrPerfBw,
-                "timestamp",
-                "instanceName",
-                "availableCPUs",
-                "averageSystemLoad",
-                "freeJvmMemory",
-                "freePhysicalMemory",
-                "totalJvmMemory");
+      formatter(csBw, "timestamp", "resourceName", "partition", "instanceName", "sessionId",
+          "state");
+      formatter(msgBw, "timestamp", "resourceName", "partition", "instanceName", "sessionId",
+          "from", "to", "messageType", "messageState");
+      formatter(hrPerfBw, "timestamp", "instanceName", "availableCPUs", "averageSystemLoad",
+          "freeJvmMemory", "freePhysicalMemory", "totalJvmMemory");
 
       Map<String, ZNRecord> liveInstanceSessionMap = new HashMap<String, ZNRecord>();
 
       int pos;
       String inputLine;
-      while ((inputLine = br.readLine()) != null)
-      {
-        if (inputLine.indexOf("CONFIGS") != -1)
-        {
+      while ((inputLine = br.readLine()) != null) {
+        if (inputLine.indexOf("CONFIGS") != -1) {
           pos = inputLine.indexOf("CONFIGS");
           pos = inputLine.indexOf("data:{", pos);
-          if (pos != -1)
-          {
+          if (pos != -1) {
             String timestamp = getAttributeValue(inputLine, "time:");
             ZNRecord record =
-                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5)
-                                                              .getBytes());
+                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5).getBytes());
 
-            formatter(cfgBw,
-                      timestamp,
-                      record.getId(),
-                      record.getSimpleField("HOST"),
-                      record.getSimpleField("PORT"),
-                      record.getSimpleField("ENABLED"));
+            formatter(cfgBw, timestamp, record.getId(), record.getSimpleField("HOST"),
+                record.getSimpleField("PORT"), record.getSimpleField("ENABLED"));
 
           }
-        }
-        else if (inputLine.indexOf("IDEALSTATES") != -1)
-        {
+        } else if (inputLine.indexOf("IDEALSTATES") != -1) {
           pos = inputLine.indexOf("IDEALSTATES");
           pos = inputLine.indexOf("data:{", pos);
-          if (pos != -1)
-          {
+          if (pos != -1) {
             String timestamp = getAttributeValue(inputLine, "time:");
             ZNRecord record =
-                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5)
-                                                              .getBytes());
+                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5).getBytes());
             // System.out.println("record=" + record);
-            for (String partition : record.getListFields().keySet())
-            {
+            for (String partition : record.getListFields().keySet()) {
               List<String> preferenceList = record.getListFields().get(partition);
-              for (int i = 0; i < preferenceList.size(); i++)
-              {
+              for (int i = 0; i < preferenceList.size(); i++) {
                 String instance = preferenceList.get(i);
-                formatter(isBw,
-                          timestamp,
-                          record.getId(),
-                          record.getSimpleField(IdealStateProperty.NUM_PARTITIONS.toString()),
-                          record.getSimpleField(IdealStateProperty.REBALANCE_MODE.toString()),
-                          partition,
-                          instance,
-                          Integer.toString(i));
+                formatter(isBw, timestamp, record.getId(),
+                    record.getSimpleField(IdealStateProperty.NUM_PARTITIONS.toString()),
+                    record.getSimpleField(IdealStateProperty.REBALANCE_MODE.toString()), partition,
+                    instance, Integer.toString(i));
               }
             }
           }
-        }
-        else if (inputLine.indexOf("LIVEINSTANCES") != -1)
-        {
+        } else if (inputLine.indexOf("LIVEINSTANCES") != -1) {
           pos = inputLine.indexOf("LIVEINSTANCES");
           pos = inputLine.indexOf("data:{", pos);
-          if (pos != -1)
-          {
+          if (pos != -1) {
             String timestamp = getAttributeValue(inputLine, "time:");
             ZNRecord record =
-                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5)
-                                                              .getBytes());
+                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5).getBytes());
             formatter(liBw, timestamp, record.getId(), record.getSimpleField("SESSION_ID"), "ADD");
             String zkSessionId = getAttributeValue(inputLine, "session:");
-            if (zkSessionId == null)
-            {
+            if (zkSessionId == null) {
               System.err.println("no zk session id associated with the adding of live instance: "
                   + inputLine);
-            }
-            else
-            {
+            } else {
               liveInstanceSessionMap.put(zkSessionId, record);
             }
           }
 
-        }
-        else if (inputLine.indexOf("EXTERNALVIEW") != -1)
-        {
+        } else if (inputLine.indexOf("EXTERNALVIEW") != -1) {
           pos = inputLine.indexOf("EXTERNALVIEW");
           pos = inputLine.indexOf("data:{", pos);
-          if (pos != -1)
-          {
+          if (pos != -1) {
             String timestamp = getAttributeValue(inputLine, "time:");
             ZNRecord record =
-                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5)
-                                                              .getBytes());
+                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5).getBytes());
             // System.out.println("record=" + record);
-            for (String partition : record.getMapFields().keySet())
-            {
+            for (String partition : record.getMapFields().keySet()) {
               Map<String, String> stateMap = record.getMapFields().get(partition);
-              for (String instance : stateMap.keySet())
-              {
+              for (String instance : stateMap.keySet()) {
                 String state = stateMap.get(instance);
                 formatter(evBw, timestamp, record.getId(), partition, instance, state);
               }
             }
           }
-        }
-        else if (inputLine.indexOf("STATEMODELDEFS") != -1)
-        {
+        } else if (inputLine.indexOf("STATEMODELDEFS") != -1) {
           pos = inputLine.indexOf("STATEMODELDEFS");
           pos = inputLine.indexOf("data:{", pos);
-          if (pos != -1)
-          {
+          if (pos != -1) {
             String timestamp = getAttributeValue(inputLine, "time:");
             ZNRecord record =
-                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5)
-                                                              .getBytes());
+                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5).getBytes());
 
-            for (String stateInfo : record.getMapFields().keySet())
-            {
-              if (stateInfo.endsWith(".meta"))
-              {
+            for (String stateInfo : record.getMapFields().keySet()) {
+              if (stateInfo.endsWith(".meta")) {
                 Map<String, String> metaMap = record.getMapFields().get(stateInfo);
-                formatter(smdCntBw,
-                          timestamp,
-                          record.getId(),
-                          stateInfo.substring(0, stateInfo.indexOf('.')),
-                          metaMap.get("count"));
-              }
-              else if (stateInfo.endsWith(".next"))
-              {
+                formatter(smdCntBw, timestamp, record.getId(),
+                    stateInfo.substring(0, stateInfo.indexOf('.')), metaMap.get("count"));
+              } else if (stateInfo.endsWith(".next")) {
                 Map<String, String> nextMap = record.getMapFields().get(stateInfo);
-                for (String destState : nextMap.keySet())
-                {
-                  formatter(smdNextBw,
-                            timestamp,
-                            record.getId(),
-                            stateInfo.substring(0, stateInfo.indexOf('.')),
-                            destState,
-                            nextMap.get(destState));
+                for (String destState : nextMap.keySet()) {
+                  formatter(smdNextBw, timestamp, record.getId(),
+                      stateInfo.substring(0, stateInfo.indexOf('.')), destState,
+                      nextMap.get(destState));
                 }
               }
             }
           }
-        }
-        else if (inputLine.indexOf("CURRENTSTATES") != -1)
-        {
+        } else if (inputLine.indexOf("CURRENTSTATES") != -1) {
           pos = inputLine.indexOf("CURRENTSTATES");
           pos = inputLine.indexOf("data:{", pos);
-          if (pos != -1)
-          {
+          if (pos != -1) {
             String timestamp = getAttributeValue(inputLine, "time:");
             ZNRecord record =
-                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5)
-                                                              .getBytes());
+                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5).getBytes());
             // System.out.println("record=" + record);
-            for (String partition : record.getMapFields().keySet())
-            {
+            for (String partition : record.getMapFields().keySet()) {
               Map<String, String> stateMap = record.getMapFields().get(partition);
               String path = getAttributeValue(inputLine, "path:");
-              if (path != null)
-              {
+              if (path != null) {
                 String instance = HelixUtil.getInstanceNameFromPath(path);
-                formatter(csBw,
-                          timestamp,
-                          record.getId(),
-                          partition,
-                          instance,
-                          record.getSimpleField("SESSION_ID"),
-                          stateMap.get("CURRENT_STATE"));
+                formatter(csBw, timestamp, record.getId(), partition, instance,
+                    record.getSimpleField("SESSION_ID"), stateMap.get("CURRENT_STATE"));
               }
             }
           }
-        }
-        else if (inputLine.indexOf("MESSAGES") != -1)
-        {
+        } else if (inputLine.indexOf("MESSAGES") != -1) {
           pos = inputLine.indexOf("MESSAGES");
           pos = inputLine.indexOf("data:{", pos);
-          if (pos != -1)
-          {
+          if (pos != -1) {
             String timestamp = getAttributeValue(inputLine, "time:");
             ZNRecord record =
-                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5)
-                                                              .getBytes());
+                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5).getBytes());
 
-            formatter(msgBw,
-                      timestamp,
-                      record.getSimpleField("RESOURCE_NAME"),
-                      record.getSimpleField("PARTITION_NAME"),
-                      record.getSimpleField("TGT_NAME"),
-                      record.getSimpleField("TGT_SESSION_ID"),
-                      record.getSimpleField("FROM_STATE"),
-                      record.getSimpleField("TO_STATE"),
-                      record.getSimpleField("MSG_TYPE"),
-                      record.getSimpleField("MSG_STATE"));
+            formatter(msgBw, timestamp, record.getSimpleField("RESOURCE_NAME"),
+                record.getSimpleField("PARTITION_NAME"), record.getSimpleField("TGT_NAME"),
+                record.getSimpleField("TGT_SESSION_ID"), record.getSimpleField("FROM_STATE"),
+                record.getSimpleField("TO_STATE"), record.getSimpleField("MSG_TYPE"),
+                record.getSimpleField("MSG_STATE"));
           }
 
-        }
-        else if (inputLine.indexOf("closeSession") != -1)
-        {
+        } else if (inputLine.indexOf("closeSession") != -1) {
           String zkSessionId = getAttributeValue(inputLine, "session:");
-          if (zkSessionId == null)
-          {
+          if (zkSessionId == null) {
             System.err.println("no zk session id associated with the closing of zk session: "
                 + inputLine);
-          }
-          else
-          {
+          } else {
             ZNRecord record = liveInstanceSessionMap.remove(zkSessionId);
             // System.err.println("zkSessionId:" + zkSessionId + ", record:" + record);
-            if (record != null)
-            {
+            if (record != null) {
               String timestamp = getAttributeValue(inputLine, "time:");
-              formatter(liBw,
-                        timestamp,
-                        record.getId(),
-                        record.getSimpleField("SESSION_ID"),
-                        "DELETE");
+              formatter(liBw, timestamp, record.getId(), record.getSimpleField("SESSION_ID"),
+                  "DELETE");
             }
           }
-        }
-        else if (inputLine.indexOf("HEALTHREPORT/defaultPerfCounters") != -1)
-        {
+        } else if (inputLine.indexOf("HEALTHREPORT/defaultPerfCounters") != -1) {
           pos = inputLine.indexOf("HEALTHREPORT/defaultPerfCounters");
           pos = inputLine.indexOf("data:{", pos);
-          if (pos != -1)
-          {
+          if (pos != -1) {
             String timestamp = getAttributeValue(inputLine, "time:");
             ZNRecord record =
-                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5)
-                                                              .getBytes());
+                (ZNRecord) _deserializer.deserialize(inputLine.substring(pos + 5).getBytes());
 
             String path = getAttributeValue(inputLine, "path:");
-            if (path != null)
-            {
+            if (path != null) {
               String instance = HelixUtil.getInstanceNameFromPath(path);
-              formatter(hrPerfBw,
-                        timestamp,
-                        instance,
-                        record.getSimpleField("availableCPUs"),
-                        record.getSimpleField("averageSystemLoad"),
-                        record.getSimpleField("freeJvmMemory"),
-                        record.getSimpleField("freePhysicalMemory"),
-                        record.getSimpleField("totalJvmMemory"));
+              formatter(hrPerfBw, timestamp, instance, record.getSimpleField("availableCPUs"),
+                  record.getSimpleField("averageSystemLoad"),
+                  record.getSimpleField("freeJvmMemory"),
+                  record.getSimpleField("freePhysicalMemory"),
+                  record.getSimpleField("totalJvmMemory"));
             }
           }
         }
@@ -440,9 +313,7 @@ public class ZkLogCSVFormatter
       msgBw.close();
       liBw.close();
       hrPerfBw.close();
-    }
-    catch (Exception e)
-    {
+    } catch (Exception e) {
       System.err.println("Error: " + e.getMessage());
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/tools/ZnodeOpArg.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/tools/ZnodeOpArg.java b/helix-core/src/main/java/org/apache/helix/tools/ZnodeOpArg.java
index 3dc34a3..e60ce8e 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/ZnodeOpArg.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/ZnodeOpArg.java
@@ -25,26 +25,23 @@ import java.util.Map;
 import org.apache.helix.ZNRecord;
 import org.apache.helix.tools.TestExecutor.ZnodePropertyType;
 
-
-public class ZnodeOpArg
-{
+public class ZnodeOpArg {
   public String _znodePath;
   public ZnodePropertyType _propertyType;
-  
+
   /**
-   *  "+" for update/create if not exist
-   *  '-' for remove
+   * "+" for update/create if not exist
+   * '-' for remove
    * "==" for test equals
    * "!=" for test not equal
-   */ 
+   */
   public String _operation;
   public String _key;
   public ZnodeValue _updateValue;
-  
-  public ZnodeOpArg()
-  {
+
+  public ZnodeOpArg() {
   }
-  
+
   /**
    * verify simple/list/map field: no update value
    * @param znodePath
@@ -52,22 +49,20 @@ public class ZnodeOpArg
    * @param op
    * @param key
    */
-  public ZnodeOpArg(String znodePath, ZnodePropertyType type, String op, String key)
-  {
+  public ZnodeOpArg(String znodePath, ZnodePropertyType type, String op, String key) {
     this(znodePath, type, op, key, new ZnodeValue());
   }
-  
+
   /**
    * verify znode: no update value
    * @param znodePath
    * @param type
    * @param op
    */
-  public ZnodeOpArg(String znodePath, ZnodePropertyType type, String op)
-  {
+  public ZnodeOpArg(String znodePath, ZnodePropertyType type, String op) {
     this(znodePath, type, op, null, new ZnodeValue());
   }
-  
+
   /**
    * simple field change
    * @param znodePath
@@ -76,8 +71,7 @@ public class ZnodeOpArg
    * @param key
    * @param update
    */
-  public ZnodeOpArg(String znodePath, ZnodePropertyType type, String op, String key, String update)
-  {
+  public ZnodeOpArg(String znodePath, ZnodePropertyType type, String op, String key, String update) {
     this(znodePath, type, op, key, new ZnodeValue(update));
   }
 
@@ -89,8 +83,8 @@ public class ZnodeOpArg
    * @param key
    * @param update
    */
-  public ZnodeOpArg(String znodePath, ZnodePropertyType type, String op, String key, List<String> update)
-  {
+  public ZnodeOpArg(String znodePath, ZnodePropertyType type, String op, String key,
+      List<String> update) {
     this(znodePath, type, op, key, new ZnodeValue(update));
   }
 
@@ -102,8 +96,8 @@ public class ZnodeOpArg
    * @param key
    * @param update
    */
-  public ZnodeOpArg(String znodePath, ZnodePropertyType type, String op, String key, Map<String, String> update)
-  {
+  public ZnodeOpArg(String znodePath, ZnodePropertyType type, String op, String key,
+      Map<String, String> update) {
     this(znodePath, type, op, key, new ZnodeValue(update));
   }
 
@@ -115,71 +109,63 @@ public class ZnodeOpArg
    * @param key
    * @param update
    */
-  public ZnodeOpArg(String znodePath, ZnodePropertyType type, String op, ZNRecord update)
-  {
+  public ZnodeOpArg(String znodePath, ZnodePropertyType type, String op, ZNRecord update) {
     this(znodePath, type, op, null, new ZnodeValue(update));
   }
 
   /**
-   * 
    * @param znodePath
    * @param type
    * @param op
    * @param key
    * @param update
    */
-  public ZnodeOpArg(String znodePath, ZnodePropertyType type, String op, String key, ZnodeValue update)
-  {
+  public ZnodeOpArg(String znodePath, ZnodePropertyType type, String op, String key,
+      ZnodeValue update) {
     _znodePath = znodePath;
     _propertyType = type;
     _operation = op;
     _key = key;
     _updateValue = update;
   }
-  
+
   @Override
-  public String toString()
-  {
-    String ret = "={\"" + 
-                 _znodePath + "\", " + _propertyType + "/" + _key + " " + _operation + " " +
-                 _updateValue + "}";
+  public String toString() {
+    String ret =
+        "={\"" + _znodePath + "\", " + _propertyType + "/" + _key + " " + _operation + " "
+            + _updateValue + "}";
     return ret;
   }
 
-  
   // TODO temp test; remove it
   /*
-  public static void main(String[] args) 
-  {
-    // null modification command
-    ZnodeOpArg command = new ZnodeOpArg();
-    System.out.println(command);
-    
-    // simple modification command
-    command = new ZnodeOpArg("/testPath", ZnodePropertyType.SIMPLE, "+", "key1", "simpleValue1");
-    System.out.println(command);
-    
-    // list modification command
-    List<String> list = new ArrayList<String>();
-    list.add("listValue1");
-    list.add("listValue2");
-    command = new ZnodeOpArg("/testPath", ZnodePropertyType.LIST, "+", "key1", list);
-    System.out.println(command);
-    
-    // map modification command
-    Map<String, String> map = new HashMap<String, String>();
-    map.put("mapKey1", "mapValue1");
-    map.put("mapKey2", "mapValue2");
-    command = new ZnodeOpArg("/testPath", ZnodePropertyType.MAP, "+", "key1", map);
-    System.out.println(command);
-
-    // map modification command
-    ZNRecord record = new ZNRecord("znrecord");
-    record.setSimpleField("key1", "simpleValue1");
-    record.setListField("key1", list);
-    record.setMapField("key1", map);
-    command = new ZnodeOpArg("/testPath", ZnodePropertyType.ZNODE, "+", record);
-    System.out.println(command);
-  }
-  */
+   * public static void main(String[] args)
+   * {
+   * // null modification command
+   * ZnodeOpArg command = new ZnodeOpArg();
+   * System.out.println(command);
+   * // simple modification command
+   * command = new ZnodeOpArg("/testPath", ZnodePropertyType.SIMPLE, "+", "key1", "simpleValue1");
+   * System.out.println(command);
+   * // list modification command
+   * List<String> list = new ArrayList<String>();
+   * list.add("listValue1");
+   * list.add("listValue2");
+   * command = new ZnodeOpArg("/testPath", ZnodePropertyType.LIST, "+", "key1", list);
+   * System.out.println(command);
+   * // map modification command
+   * Map<String, String> map = new HashMap<String, String>();
+   * map.put("mapKey1", "mapValue1");
+   * map.put("mapKey2", "mapValue2");
+   * command = new ZnodeOpArg("/testPath", ZnodePropertyType.MAP, "+", "key1", map);
+   * System.out.println(command);
+   * // map modification command
+   * ZNRecord record = new ZNRecord("znrecord");
+   * record.setSimpleField("key1", "simpleValue1");
+   * record.setListField("key1", list);
+   * record.setMapField("key1", map);
+   * command = new ZnodeOpArg("/testPath", ZnodePropertyType.ZNODE, "+", record);
+   * System.out.println(command);
+   * }
+   */
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/tools/ZnodeValue.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/tools/ZnodeValue.java b/helix-core/src/main/java/org/apache/helix/tools/ZnodeValue.java
index 7098fce..c975b6f 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/ZnodeValue.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/ZnodeValue.java
@@ -24,58 +24,43 @@ import java.util.Map;
 
 import org.apache.helix.ZNRecord;
 
-
-public class ZnodeValue
-{
+public class ZnodeValue {
   public String _singleValue;
   public List<String> _listValue;
   public Map<String, String> _mapValue;
   public ZNRecord _znodeValue;
-  
-  public ZnodeValue()
-  {
+
+  public ZnodeValue() {
   }
-  
-  public ZnodeValue(String value)
-  {
+
+  public ZnodeValue(String value) {
     _singleValue = value;
   }
-  
-  public ZnodeValue(List<String> value)
-  {
+
+  public ZnodeValue(List<String> value) {
     _listValue = value;
   }
-  
-  public ZnodeValue(Map<String, String> value)
-  {
+
+  public ZnodeValue(Map<String, String> value) {
     _mapValue = value;
   }
-  
-  public ZnodeValue(ZNRecord value)
-  {
+
+  public ZnodeValue(ZNRecord value) {
     _znodeValue = value;
   }
-  
+
   @Override
-  public String toString()
-  {
-    if (_singleValue != null)
-    {
+  public String toString() {
+    if (_singleValue != null) {
       return _singleValue;
-    }
-    else if (_listValue != null)
-    {
+    } else if (_listValue != null) {
       return _listValue.toString();
-    }
-    else if (_mapValue != null)
-    {
+    } else if (_mapValue != null) {
       return _mapValue.toString();
-    }
-    else if (_znodeValue != null)
-    {
+    } else if (_znodeValue != null) {
       return _znodeValue.toString();
     }
-    
+
     return "null";
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java b/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
index a5ac5bc..82d7b6c 100644
--- a/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
+++ b/helix-core/src/main/java/org/apache/helix/util/HelixUtil.java
@@ -26,53 +26,43 @@ import org.apache.helix.PropertyPathConfig;
 import org.apache.helix.PropertyType;
 import org.apache.log4j.Logger;
 
-public final class HelixUtil
-{
+public final class HelixUtil {
   static private Logger LOG = Logger.getLogger(HelixUtil.class);
 
-  private HelixUtil()
-  {
+  private HelixUtil() {
   }
 
-  public static String getPropertyPath(String clusterName, PropertyType type)
-  {
+  public static String getPropertyPath(String clusterName, PropertyType type) {
     return "/" + clusterName + "/" + type.toString();
   }
 
   public static String getInstancePropertyPath(String clusterName, String instanceName,
-      PropertyType type)
-  {
+      PropertyType type) {
     return getPropertyPath(clusterName, PropertyType.INSTANCES) + "/" + instanceName + "/"
         + type.toString();
   }
 
-  public static String getInstancePath(String clusterName, String instanceName)
-  {
+  public static String getInstancePath(String clusterName, String instanceName) {
     return getPropertyPath(clusterName, PropertyType.INSTANCES) + "/" + instanceName;
   }
 
-  public static String getIdealStatePath(String clusterName, String resourceName)
-  {
+  public static String getIdealStatePath(String clusterName, String resourceName) {
     return getPropertyPath(clusterName, PropertyType.IDEALSTATES) + "/" + resourceName;
   }
 
-  public static String getIdealStatePath(String clusterName)
-  {
+  public static String getIdealStatePath(String clusterName) {
     return getPropertyPath(clusterName, PropertyType.IDEALSTATES);
   }
 
-  public static String getLiveInstancesPath(String clusterName)
-  {
+  public static String getLiveInstancesPath(String clusterName) {
     return getPropertyPath(clusterName, PropertyType.LIVEINSTANCES);
   }
 
-  public static String getMessagePath(String clusterName, String instanceName)
-  {
+  public static String getMessagePath(String clusterName, String instanceName) {
     return getInstancePropertyPath(clusterName, instanceName, PropertyType.MESSAGES);
   }
 
-  public static String getCurrentStateBasePath(String clusterName, String instanceName)
-  {
+  public static String getCurrentStateBasePath(String clusterName, String instanceName) {
     return getInstancePropertyPath(clusterName, instanceName, PropertyType.CURRENTSTATES);
   }
 
@@ -83,85 +73,67 @@ public final class HelixUtil
    * cluster manager neeeds to maintain watch on each of these nodes for every
    * node. So over all cluster manager will have P*K*D watches which can be
    * quite large given that we over partition.
-   * 
    * The other extreme is having one znode per storage per database. This will
    * result in N*D watches which is good. But data in every node might become
    * really big since it has to save partition
-   * 
    * Ideally we want to balance between the two models
-   * 
    */
   public static String getCurrentStatePath(String clusterName, String instanceName,
-      String sessionId, String stateUnitKey)
-  {
+      String sessionId, String stateUnitKey) {
     return getInstancePropertyPath(clusterName, instanceName, PropertyType.CURRENTSTATES) + "/"
         + sessionId + "/" + stateUnitKey;
   }
 
-  public static String getExternalViewPath(String clusterName)
-  {
+  public static String getExternalViewPath(String clusterName) {
     return getPropertyPath(clusterName, PropertyType.EXTERNALVIEW);
   }
 
-  public static String getStateModelDefinitionPath(String clusterName)
-  {
+  public static String getStateModelDefinitionPath(String clusterName) {
     return getPropertyPath(clusterName, PropertyType.STATEMODELDEFS);
   }
 
-  public static String getExternalViewPath(String clusterName, String resourceName)
-  {
+  public static String getExternalViewPath(String clusterName, String resourceName) {
     return getPropertyPath(clusterName, PropertyType.EXTERNALVIEW) + "/" + resourceName;
   }
 
-  public static String getLiveInstancePath(String clusterName, String instanceName)
-  {
+  public static String getLiveInstancePath(String clusterName, String instanceName) {
     return getPropertyPath(clusterName, PropertyType.LIVEINSTANCES) + "/" + instanceName;
   }
 
-  public static String getMemberInstancesPath(String clusterName)
-  {
+  public static String getMemberInstancesPath(String clusterName) {
     return getPropertyPath(clusterName, PropertyType.INSTANCES);
   }
 
-  public static String getErrorsPath(String clusterName, String instanceName)
-  {
+  public static String getErrorsPath(String clusterName, String instanceName) {
     return getInstancePropertyPath(clusterName, instanceName, PropertyType.ERRORS);
   }
 
-  public static String getStatusUpdatesPath(String clusterName, String instanceName)
-  {
+  public static String getStatusUpdatesPath(String clusterName, String instanceName) {
     return getInstancePropertyPath(clusterName, instanceName, PropertyType.STATUSUPDATES);
   }
 
-  public static String getHealthPath(String clusterName, String instanceName)
-  {
+  public static String getHealthPath(String clusterName, String instanceName) {
     return PropertyPathConfig.getPath(PropertyType.HEALTHREPORT, clusterName, instanceName);
   }
 
-  public static String getPersistentStatsPath(String clusterName)
-  {
+  public static String getPersistentStatsPath(String clusterName) {
     return PropertyPathConfig.getPath(PropertyType.PERSISTENTSTATS, clusterName);
   }
 
-  public static String getAlertsPath(String clusterName)
-  {
+  public static String getAlertsPath(String clusterName) {
     return PropertyPathConfig.getPath(PropertyType.ALERTS, clusterName);
   }
 
-  public static String getAlertStatusPath(String clusterName)
-  {
+  public static String getAlertStatusPath(String clusterName) {
     return PropertyPathConfig.getPath(PropertyType.ALERT_STATUS, clusterName);
   }
 
-  public static String getInstanceNameFromPath(String path)
-  {
+  public static String getInstanceNameFromPath(String path) {
     // path structure
     // /<cluster_name>/instances/<instance_name>/[currentStates/messages]
-    if (path.contains("/" + PropertyType.INSTANCES + "/"))
-    {
+    if (path.contains("/" + PropertyType.INSTANCES + "/")) {
       String[] split = path.split("\\/");
-      if (split.length > 3)
-      {
+      if (split.length > 3) {
         return split[3];
       }
     }
@@ -169,56 +141,49 @@ public final class HelixUtil
   }
 
   // distributed cluster controller
-  public static String getControllerPath(String clusterName)
-  {
+  public static String getControllerPath(String clusterName) {
     return getPropertyPath(clusterName, PropertyType.CONTROLLER);
   }
 
-  public static String getControllerPropertyPath(String clusterName, PropertyType type)
-  {
+  public static String getControllerPropertyPath(String clusterName, PropertyType type) {
     return PropertyPathConfig.getPath(type, clusterName);
   }
-  
+
   /**
    * get the parent-path of given path
    * return "/" string if path = "/xxx", null if path = "/"
-   * 
    * @param path
    * @return
    */
   public static String getZkParentPath(String path) {
-      if (path.equals("/")) {
-          return null;
-      }
-      
-      int idx = path.lastIndexOf('/');
-      return idx == 0? "/" : path.substring(0, idx);
+    if (path.equals("/")) {
+      return null;
+    }
+
+    int idx = path.lastIndexOf('/');
+    return idx == 0 ? "/" : path.substring(0, idx);
   }
-  
+
   /**
    * get the last part of the zk-path
-   * 
    * @param path
    * @return
    */
   public static String getZkName(String path) {
-      return path.substring(path.lastIndexOf('/') + 1);
+    return path.substring(path.lastIndexOf('/') + 1);
   }
-  
+
   /**
    * parse a csv-formated key-value pairs
-   * 
    * @param keyValuePairs : csv-formatted key-value pairs. e.g. k1=v1,k2=v2,...
-   * @return 
+   * @return
    */
   public static Map<String, String> parseCsvFormatedKeyValuePairs(String keyValuePairs) {
     String[] pairs = keyValuePairs.split("[\\s,]");
     Map<String, String> keyValueMap = new TreeMap<String, String>();
-    for (String pair : pairs)
-    {
+    for (String pair : pairs) {
       int idx = pair.indexOf('=');
-      if (idx == -1)
-      {
+      if (idx == -1) {
         LOG.error("Invalid key-value pair: " + pair + ". Igonore it.");
         continue;
       }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/util/PathUtils.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/util/PathUtils.java b/helix-core/src/main/java/org/apache/helix/util/PathUtils.java
index 85d2947..178ddcd 100644
--- a/helix-core/src/main/java/org/apache/helix/util/PathUtils.java
+++ b/helix-core/src/main/java/org/apache/helix/util/PathUtils.java
@@ -1,4 +1,4 @@
- /**
+/**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -18,86 +18,77 @@
 
 package org.apache.helix.util;
 
-
 /**
  * Path related utilities
- */    
+ */
 public class PathUtils {
-	
-	/** validate the provided znode path string
-	 * @param path znode path string
-	 * @param isSequential if the path is being created
-	 * with a sequential flag
-	 * @throws IllegalArgumentException if the path is invalid
-	 */
-	public static void validatePath(String path, boolean isSequential) 
-		throws IllegalArgumentException {
-		validatePath(isSequential? path + "1": path);
-	}
-	
-    /**
-     * Validate the provided znode path string
-     * @param path znode path string
-     * @throws IllegalArgumentException if the path is invalid
-     */
-    public static void validatePath(String path) throws IllegalArgumentException {
-        if (path == null) {
-            throw new IllegalArgumentException("Path cannot be null");
-        }
-        if (path.length() == 0) {
-            throw new IllegalArgumentException("Path length must be > 0");
-        }
-        if (path.charAt(0) != '/') {
-            throw new IllegalArgumentException(
-                         "Path must start with / character");
-        }
-        if (path.length() == 1) { // done checking - it's the root
-            return;
-        }
-        if (path.charAt(path.length() - 1) == '/') {
-            throw new IllegalArgumentException(
-                         "Path must not end with / character");
-        }
 
-        String reason = null;
-        char lastc = '/';
-        char chars[] = path.toCharArray();
-        char c;
-        for (int i = 1; i < chars.length; lastc = chars[i], i++) {
-            c = chars[i];
+  /**
+   * validate the provided znode path string
+   * @param path znode path string
+   * @param isSequential if the path is being created
+   *          with a sequential flag
+   * @throws IllegalArgumentException if the path is invalid
+   */
+  public static void validatePath(String path, boolean isSequential)
+      throws IllegalArgumentException {
+    validatePath(isSequential ? path + "1" : path);
+  }
 
-            if (c == 0) {
-                reason = "null character not allowed @" + i;
-                break;
-            } else if (c == '/' && lastc == '/') {
-                reason = "empty node name specified @" + i;
-                break;
-            } else if (c == '.' && lastc == '.') {
-                if (chars[i-2] == '/' &&
-                        ((i + 1 == chars.length)
-                                || chars[i+1] == '/')) {
-                    reason = "relative paths not allowed @" + i;
-                    break;
-                }
-            } else if (c == '.') {
-                if (chars[i-1] == '/' &&
-                        ((i + 1 == chars.length)
-                                || chars[i+1] == '/')) {
-                    reason = "relative paths not allowed @" + i;
-                    break;
-                }
-            } else if (c > '\u0000' && c <= '\u001f'
-                    || c >= '\u007f' && c <= '\u009F'
-                    || c >= '\ud800' && c <= '\uf8ff'
-                    || c >= '\ufff0' && c <= '\uffff') {
-                reason = "invalid charater @" + i;
-                break;
-            }
-        }
+  /**
+   * Validate the provided znode path string
+   * @param path znode path string
+   * @throws IllegalArgumentException if the path is invalid
+   */
+  public static void validatePath(String path) throws IllegalArgumentException {
+    if (path == null) {
+      throw new IllegalArgumentException("Path cannot be null");
+    }
+    if (path.length() == 0) {
+      throw new IllegalArgumentException("Path length must be > 0");
+    }
+    if (path.charAt(0) != '/') {
+      throw new IllegalArgumentException("Path must start with / character");
+    }
+    if (path.length() == 1) { // done checking - it's the root
+      return;
+    }
+    if (path.charAt(path.length() - 1) == '/') {
+      throw new IllegalArgumentException("Path must not end with / character");
+    }
 
-        if (reason != null) {
-            throw new IllegalArgumentException(
-                    "Invalid path string \"" + path + "\" caused by " + reason);
+    String reason = null;
+    char lastc = '/';
+    char chars[] = path.toCharArray();
+    char c;
+    for (int i = 1; i < chars.length; lastc = chars[i], i++) {
+      c = chars[i];
+
+      if (c == 0) {
+        reason = "null character not allowed @" + i;
+        break;
+      } else if (c == '/' && lastc == '/') {
+        reason = "empty node name specified @" + i;
+        break;
+      } else if (c == '.' && lastc == '.') {
+        if (chars[i - 2] == '/' && ((i + 1 == chars.length) || chars[i + 1] == '/')) {
+          reason = "relative paths not allowed @" + i;
+          break;
+        }
+      } else if (c == '.') {
+        if (chars[i - 1] == '/' && ((i + 1 == chars.length) || chars[i + 1] == '/')) {
+          reason = "relative paths not allowed @" + i;
+          break;
         }
+      } else if (c > '\u0000' && c <= '\u001f' || c >= '\u007f' && c <= '\u009F' || c >= '\ud800'
+          && c <= '\uf8ff' || c >= '\ufff0' && c <= '\uffff') {
+        reason = "invalid charater @" + i;
+        break;
+      }
+    }
+
+    if (reason != null) {
+      throw new IllegalArgumentException("Invalid path string \"" + path + "\" caused by " + reason);
     }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/util/RebalanceUtil.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/util/RebalanceUtil.java b/helix-core/src/main/java/org/apache/helix/util/RebalanceUtil.java
index 03c45c4..3f8c406 100644
--- a/helix-core/src/main/java/org/apache/helix/util/RebalanceUtil.java
+++ b/helix-core/src/main/java/org/apache/helix/util/RebalanceUtil.java
@@ -30,32 +30,25 @@ import org.apache.helix.HelixException;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.model.StateModelDefinition;
 
-public class RebalanceUtil
-{
-  public static Map<String, Object> buildInternalIdealState(IdealState state)
-  {
+public class RebalanceUtil {
+  public static Map<String, Object> buildInternalIdealState(IdealState state) {
     // Try parse the partition number from name DB_n. If not, sort the partitions and
     // assign id
     Map<String, Integer> partitionIndex = new HashMap<String, Integer>();
     Map<String, String> reversePartitionIndex = new HashMap<String, String>();
     boolean indexInPartitionName = true;
-    for (String partitionId : state.getPartitionSet())
-    {
+    for (String partitionId : state.getPartitionSet()) {
       int lastPos = partitionId.lastIndexOf("_");
-      if (lastPos < 0)
-      {
+      if (lastPos < 0) {
         indexInPartitionName = false;
         break;
       }
-      try
-      {
+      try {
         String idStr = partitionId.substring(lastPos + 1);
         int partition = Integer.parseInt(idStr);
         partitionIndex.put(partitionId, partition);
         reversePartitionIndex.put(state.getResourceName() + "_" + partition, partitionId);
-      }
-      catch (Exception e)
-      {
+      } catch (Exception e) {
         indexInPartitionName = false;
         partitionIndex.clear();
         reversePartitionIndex.clear();
@@ -63,41 +56,33 @@ public class RebalanceUtil
       }
     }
 
-    if (indexInPartitionName == false)
-    {
+    if (indexInPartitionName == false) {
       List<String> partitions = new ArrayList<String>();
       partitions.addAll(state.getPartitionSet());
       Collections.sort(partitions);
-      for (int i = 0; i < partitions.size(); i++)
-      {
+      for (int i = 0; i < partitions.size(); i++) {
         partitionIndex.put(partitions.get(i), i);
         reversePartitionIndex.put(state.getResourceName() + "_" + i, partitions.get(i));
       }
     }
 
-    Map<String, List<Integer>> nodeMasterAssignmentMap =
-        new TreeMap<String, List<Integer>>();
+    Map<String, List<Integer>> nodeMasterAssignmentMap = new TreeMap<String, List<Integer>>();
     Map<String, Map<String, List<Integer>>> combinedNodeSlaveAssignmentMap =
         new TreeMap<String, Map<String, List<Integer>>>();
-    for (String partition : state.getPartitionSet())
-    {
+    for (String partition : state.getPartitionSet()) {
       List<String> instances = state.getRecord().getListField(partition);
       String master = instances.get(0);
-      if (!nodeMasterAssignmentMap.containsKey(master))
-      {
+      if (!nodeMasterAssignmentMap.containsKey(master)) {
         nodeMasterAssignmentMap.put(master, new ArrayList<Integer>());
       }
-      if (!combinedNodeSlaveAssignmentMap.containsKey(master))
-      {
+      if (!combinedNodeSlaveAssignmentMap.containsKey(master)) {
         combinedNodeSlaveAssignmentMap.put(master, new TreeMap<String, List<Integer>>());
       }
       nodeMasterAssignmentMap.get(master).add(partitionIndex.get(partition));
-      for (int i = 1; i < instances.size(); i++)
-      {
+      for (int i = 1; i < instances.size(); i++) {
         String instance = instances.get(i);
         Map<String, List<Integer>> slaveMap = combinedNodeSlaveAssignmentMap.get(master);
-        if (!slaveMap.containsKey(instance))
-        {
+        if (!slaveMap.containsKey(instance)) {
           slaveMap.put(instance, new ArrayList<Integer>());
         }
         slaveMap.get(instance).add(partitionIndex.get(partition));
@@ -112,8 +97,8 @@ public class RebalanceUtil
     result.put("reversePartitionIndex", reversePartitionIndex);
     return result;
   }
-  public static String[] parseStates(String clusterName, StateModelDefinition stateModDef)
-  {
+
+  public static String[] parseStates(String clusterName, StateModelDefinition stateModDef) {
     String[] result = new String[2];
     String masterStateValue = null, slaveStateValue = null;
 
@@ -121,41 +106,30 @@ public class RebalanceUtil
 
     List<String> statePriorityList = stateModDef.getStatesPriorityList();
 
-    for (String state : statePriorityList)
-    {
+    for (String state : statePriorityList) {
       String count = stateModDef.getNumInstancesPerState(state);
-      if (count.equals("1"))
-      {
-        if (masterStateValue != null)
-        {
+      if (count.equals("1")) {
+        if (masterStateValue != null) {
           throw new HelixException("Invalid or unsupported state model definition");
         }
         masterStateValue = state;
-      }
-      else if (count.equalsIgnoreCase("R"))
-      {
-        if (slaveStateValue != null)
-        {
+      } else if (count.equalsIgnoreCase("R")) {
+        if (slaveStateValue != null) {
           throw new HelixException("Invalid or unsupported state model definition");
         }
         slaveStateValue = state;
-      }
-      else if (count.equalsIgnoreCase("N"))
-      {
-        if (!(masterStateValue == null && slaveStateValue == null))
-        {
+      } else if (count.equalsIgnoreCase("N")) {
+        if (!(masterStateValue == null && slaveStateValue == null)) {
           throw new HelixException("Invalid or unsupported state model definition");
         }
         masterStateValue = slaveStateValue = state;
       }
     }
-    if (masterStateValue == null && slaveStateValue == null)
-    {
+    if (masterStateValue == null && slaveStateValue == null) {
       throw new HelixException("Invalid or unsupported state model definition");
     }
 
-    if (masterStateValue == null)
-    {
+    if (masterStateValue == null) {
       masterStateValue = slaveStateValue;
     }
     result[0] = masterStateValue;


Mime
View raw message