helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject [44/51] [partial] [HELIX-198] Unify helix code style, rb=13710
Date Wed, 21 Aug 2013 20:43:57 GMT
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/alerts/ExpressionParser.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/ExpressionParser.java b/helix-core/src/main/java/org/apache/helix/alerts/ExpressionParser.java
index 14f0a09..ca64be5 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/ExpressionParser.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/ExpressionParser.java
@@ -31,9 +31,7 @@ import java.util.regex.Pattern;
 import org.apache.helix.HelixException;
 import org.apache.log4j.Logger;
 
-
-public class ExpressionParser
-{
+public class ExpressionParser {
   private static Logger logger = Logger.getLogger(ExpressionParser.class);
 
   final static String opDelim = "|";
@@ -48,8 +46,7 @@ public class ExpressionParser
   static Map<String, Operator> operatorMap = new HashMap<String, Operator>();
   static Map<String, Aggregator> aggregatorMap = new HashMap<String, Aggregator>();
 
-  static
-  {
+  static {
 
     addOperatorEntry("EXPAND", new ExpandOperator());
     addOperatorEntry("DIVIDE", new DivideOperator());
@@ -69,19 +66,15 @@ public class ExpressionParser
 
   // static Pattern pattern = Pattern.compile("(\\{.+?\\})");
 
-  private static void addOperatorEntry(String label, Operator op)
-  {
-    if (!operatorMap.containsKey(label))
-    {
+  private static void addOperatorEntry(String label, Operator op) {
+    if (!operatorMap.containsKey(label)) {
       operatorMap.put(label, op);
     }
     logger.info("Adding operator: " + op);
   }
 
-  private static void addAggregatorEntry(String label, Aggregator agg)
-  {
-    if (!aggregatorMap.containsKey(label.toUpperCase()))
-    {
+  private static void addAggregatorEntry(String label, Aggregator agg) {
+    if (!aggregatorMap.containsKey(label.toUpperCase())) {
       aggregatorMap.put(label.toUpperCase(), agg);
     }
     logger.info("Adding aggregator: " + agg);
@@ -93,8 +86,7 @@ public class ExpressionParser
    * logger.info("Adding operator type: "+type); }
    */
 
-  public static boolean isExpressionNested(String expression)
-  {
+  public static boolean isExpressionNested(String expression) {
     return expression.contains("(");
   }
 
@@ -105,10 +97,8 @@ public class ExpressionParser
    * Exception(op+" is not a valid op type"); } return operatorMap.get(op); }
    */
 
-  public static String getInnerExpression(String expression)
-  {
-    return expression.substring(expression.indexOf("(") + 1,
-        expression.lastIndexOf(")"));
+  public static String getInnerExpression(String expression) {
+    return expression.substring(expression.indexOf("(") + 1, expression.lastIndexOf(")"));
   }
 
   /*
@@ -118,12 +108,10 @@ public class ExpressionParser
    * getOperatorType(expression); String innerExp =
    * getInnerExpression(expression); items = getBaseStats(nextType, innerExp); }
    * else { //base class, no nesting items = expression.split(","); }
-   * 
    * if (type != null && type.isBaseOp()) { //surround items with type. for (int
    * i=0; i<items.length; i++) { items[i] = type + "(" + items[i] + ")"; //!!!!
    * NEED type to behave like string here
    * logger.debug("Forming item "+items[i]); } } return items; }
-   * 
    * public static String[] getBaseStats(String expression) throws Exception {
    * expression = expression.replaceAll("\\s+", ""); return getBaseStats(null,
    * expression); }
@@ -131,12 +119,9 @@ public class ExpressionParser
 
   /*
    * Validate 2 sets of parenthesis exist, all before first opDelim
-   * 
    * extract agg type and validate it exists. validate number of args passed in
    */
-  public static void validateAggregatorFormat(String expression)
-      throws HelixException
-  {
+  public static void validateAggregatorFormat(String expression) throws HelixException {
     logger.debug("validating aggregator for expression: " + expression);
     // have 0 or more args, 1 or more stats...e.g. ()(x) or (2)(x,y)
     Pattern pattern = Pattern.compile("\\(.*?\\)");
@@ -144,47 +129,34 @@ public class ExpressionParser
     String aggComponent = null;
     String statComponent = null;
     int lastMatchEnd = -1;
-    if (matcher.find())
-    {
+    if (matcher.find()) {
       aggComponent = matcher.group();
       aggComponent = aggComponent.substring(1, aggComponent.length() - 1);
-      if (aggComponent.contains(")") || aggComponent.contains("("))
-      {
-        throw new HelixException(expression
-            + " has invalid aggregate component");
+      if (aggComponent.contains(")") || aggComponent.contains("(")) {
+        throw new HelixException(expression + " has invalid aggregate component");
       }
-    }
-    else
-    {
+    } else {
       throw new HelixException(expression + " has invalid aggregate component");
     }
-    if (matcher.find())
-    {
+    if (matcher.find()) {
       statComponent = matcher.group();
       statComponent = statComponent.substring(1, statComponent.length() - 1);
       // statComponent must have at least 1 arg between paren
-      if (statComponent.contains(")") || statComponent.contains("(")
-          || statComponent.length() == 0)
-      {
+      if (statComponent.contains(")") || statComponent.contains("(") || statComponent.length() == 0) {
         throw new HelixException(expression + " has invalid stat component");
       }
       lastMatchEnd = matcher.end();
-    }
-    else
-    {
+    } else {
       throw new HelixException(expression + " has invalid stat component");
     }
-    if (matcher.find())
-    {
-      throw new HelixException(expression
-          + " has too many parenthesis components");
+    if (matcher.find()) {
+      throw new HelixException(expression + " has too many parenthesis components");
     }
 
-    if (expression.length() >= lastMatchEnd + 1)
-    { // lastMatchEnd is pos 1 past the pattern. check if there are paren there
+    if (expression.length() >= lastMatchEnd + 1) { // lastMatchEnd is pos 1 past the pattern. check
+                                                   // if there are paren there
       if (expression.substring(lastMatchEnd).contains("(")
-          || expression.substring(lastMatchEnd).contains(")"))
-      {
+          || expression.substring(lastMatchEnd).contains(")")) {
         throw new HelixException(expression + " has extra parenthesis");
       }
     }
@@ -192,16 +164,12 @@ public class ExpressionParser
     // check wildcard locations. each part can have at most 1 wildcard, and must
     // be at end
     // String expStatNamePart = expression.substring(expression.)
-    StringTokenizer fieldTok = new StringTokenizer(statComponent,
-        statFieldDelim);
-    while (fieldTok.hasMoreTokens())
-    {
+    StringTokenizer fieldTok = new StringTokenizer(statComponent, statFieldDelim);
+    while (fieldTok.hasMoreTokens()) {
       String currTok = fieldTok.nextToken();
-      if (currTok.contains(wildcardChar))
-      {
+      if (currTok.contains(wildcardChar)) {
         if (currTok.indexOf(wildcardChar) != currTok.length() - 1
-            || currTok.lastIndexOf(wildcardChar) != currTok.length() - 1)
-        {
+            || currTok.lastIndexOf(wildcardChar) != currTok.length() - 1) {
           throw new HelixException(currTok
               + " is illegal stat name.  Single wildcard must appear at end.");
         }
@@ -209,15 +177,13 @@ public class ExpressionParser
     }
   }
 
-  public static boolean statContainsWildcards(String stat)
-  {
+  public static boolean statContainsWildcards(String stat) {
     return stat.contains(wildcardChar);
   }
 
   /*
    * Return true if stat name matches exactly...incomingStat has no agg type
    * currentStat can have any
-   * 
    * Function can match for 2 cases extractStatFromAgg=false. Match
    * accumulate()(dbFoo.partition10.latency) with
    * accumulate()(dbFoo.partition10.latency)...trival extractStatFromAgg=true.
@@ -225,11 +191,9 @@ public class ExpressionParser
    * dbFoo.partition10.latency
    */
   public static boolean isExactMatch(String currentStat, String incomingStat,
-      boolean extractStatFromAgg)
-  {
+      boolean extractStatFromAgg) {
     String currentStatName = currentStat;
-    if (extractStatFromAgg)
-    {
+    if (extractStatFromAgg) {
       currentStatName = getSingleAggregatorStat(currentStat);
     }
     return (incomingStat.equals(currentStatName));
@@ -238,21 +202,17 @@ public class ExpressionParser
   /*
    * Return true if incomingStat matches wildcardStat except currentStat has 1+
    * fields with "*" a*.c* matches a5.c7 a*.c* does not match a5.b6.c7
-   * 
    * Function can match for 2 cases extractStatFromAgg=false. Match
    * accumulate()(dbFoo.partition*.latency) with
    * accumulate()(dbFoo.partition10.latency) extractStatFromAgg=true. Match
    * accumulate()(dbFoo.partition*.latency) with dbFoo.partition10.latency
    */
-  public static boolean isWildcardMatch(String currentStat,
-      String incomingStat, boolean statCompareOnly, ArrayList<String> bindings)
-  {
-    if (!statCompareOnly)
-    { // need to check for match on agg type and stat
+  public static boolean isWildcardMatch(String currentStat, String incomingStat,
+      boolean statCompareOnly, ArrayList<String> bindings) {
+    if (!statCompareOnly) { // need to check for match on agg type and stat
       String currentStatAggType = (currentStat.split("\\)"))[0];
       String incomingStatAggType = (incomingStat.split("\\)"))[0];
-      if (!currentStatAggType.equals(incomingStatAggType))
-      {
+      if (!currentStatAggType.equals(incomingStatAggType)) {
         return false;
       }
     }
@@ -260,90 +220,86 @@ public class ExpressionParser
     String currentStatName = getSingleAggregatorStat(currentStat);
     String incomingStatName = getSingleAggregatorStat(incomingStat);
 
-    if (!currentStatName.contains(wildcardChar))
-    { // no wildcards in stat name
+    if (!currentStatName.contains(wildcardChar)) { // no wildcards in stat name
       return false;
     }
-    
+
     String currentStatNamePattern = currentStatName.replace(".", "\\.");
     currentStatNamePattern = currentStatNamePattern.replace("*", ".*");
-    boolean result =  Pattern.matches(currentStatNamePattern, incomingStatName);
-    if(result && bindings != null)
-    {
+    boolean result = Pattern.matches(currentStatNamePattern, incomingStatName);
+    if (result && bindings != null) {
       bindings.add(incomingStatName);
     }
     return result;
     /*
-    StringTokenizer currentStatTok = new StringTokenizer(currentStatName,
-        statFieldDelim);
-    StringTokenizer incomingStatTok = new StringTokenizer(incomingStatName,
-        statFieldDelim);
-    if (currentStatTok.countTokens() != incomingStatTok.countTokens())
-    { // stat names different numbers of fields
-      return false;
-    }
-    // for each token, if not wildcarded, must be an exact match
-    while (currentStatTok.hasMoreTokens())
-    {
-      String currTok = currentStatTok.nextToken();
-      String incomingTok = incomingStatTok.nextToken();
-      logger.debug("curTok: " + currTok);
-      logger.debug("incomingTok: " + incomingTok);
-      if (!currTok.contains(wildcardChar))
-      { // no wildcard, but have exact match
-        if (!currTok.equals(incomingTok))
-        { // not exact match
-          return false;
-        }
-      }
-      else
-      { // currTok has a wildcard
-        if (currTok.indexOf(wildcardChar) != currTok.length() - 1
-            || currTok.lastIndexOf(wildcardChar) != currTok.length() - 1)
-        {
-          throw new HelixException(currTok
-              + " is illegal stat name.  Single wildcard must appear at end.");
-        }
-        // for wildcard matching, need to escape parentheses on currTok, so
-        // regex works
-        // currTok = currTok.replace("(", "\\(");
-        // currTok = currTok.replace(")", "\\)");
-        // incomingTok = incomingTok.replace("(", "\\(");
-        // incomingTok = incomingTok.replace(")", "\\)");
-        String currTokPreWildcard = currTok.substring(0, currTok.length() - 1);
-        // TODO: if current token has a "(" in it, pattern compiling throws
-        // error
-        // Pattern pattern = Pattern.compile(currTokPreWildcard+".+"); //form
-        // pattern...wildcard part can be anything
-        // Matcher matcher = pattern.matcher(incomingTok); //see if incomingTok
-        // matches
-        if (incomingTok.indexOf(currTokPreWildcard) != 0)
-        {
-          // if (!matcher.find()) { //no match on one tok, return false
-          return false;
-        }
-        // get the binding
-
-        if (bindings != null)
-        {
-          // TODO: debug me!
-          String wildcardBinding = incomingTok.substring(incomingTok
-              .indexOf(currTokPreWildcard) + currTokPreWildcard.length());
-          bindings.add(wildcardBinding);
-        }
-      }
-    }
-    // all fields match or wildcard match...return true!
-    return true;*/
+     * StringTokenizer currentStatTok = new StringTokenizer(currentStatName,
+     * statFieldDelim);
+     * StringTokenizer incomingStatTok = new StringTokenizer(incomingStatName,
+     * statFieldDelim);
+     * if (currentStatTok.countTokens() != incomingStatTok.countTokens())
+     * { // stat names different numbers of fields
+     * return false;
+     * }
+     * // for each token, if not wildcarded, must be an exact match
+     * while (currentStatTok.hasMoreTokens())
+     * {
+     * String currTok = currentStatTok.nextToken();
+     * String incomingTok = incomingStatTok.nextToken();
+     * logger.debug("curTok: " + currTok);
+     * logger.debug("incomingTok: " + incomingTok);
+     * if (!currTok.contains(wildcardChar))
+     * { // no wildcard, but have exact match
+     * if (!currTok.equals(incomingTok))
+     * { // not exact match
+     * return false;
+     * }
+     * }
+     * else
+     * { // currTok has a wildcard
+     * if (currTok.indexOf(wildcardChar) != currTok.length() - 1
+     * || currTok.lastIndexOf(wildcardChar) != currTok.length() - 1)
+     * {
+     * throw new HelixException(currTok
+     * + " is illegal stat name.  Single wildcard must appear at end.");
+     * }
+     * // for wildcard matching, need to escape parentheses on currTok, so
+     * // regex works
+     * // currTok = currTok.replace("(", "\\(");
+     * // currTok = currTok.replace(")", "\\)");
+     * // incomingTok = incomingTok.replace("(", "\\(");
+     * // incomingTok = incomingTok.replace(")", "\\)");
+     * String currTokPreWildcard = currTok.substring(0, currTok.length() - 1);
+     * // TODO: if current token has a "(" in it, pattern compiling throws
+     * // error
+     * // Pattern pattern = Pattern.compile(currTokPreWildcard+".+"); //form
+     * // pattern...wildcard part can be anything
+     * // Matcher matcher = pattern.matcher(incomingTok); //see if incomingTok
+     * // matches
+     * if (incomingTok.indexOf(currTokPreWildcard) != 0)
+     * {
+     * // if (!matcher.find()) { //no match on one tok, return false
+     * return false;
+     * }
+     * // get the binding
+     * if (bindings != null)
+     * {
+     * // TODO: debug me!
+     * String wildcardBinding = incomingTok.substring(incomingTok
+     * .indexOf(currTokPreWildcard) + currTokPreWildcard.length());
+     * bindings.add(wildcardBinding);
+     * }
+     * }
+     * }
+     * // all fields match or wildcard match...return true!
+     * return true;
+     */
   }
 
   /*
    * For checking if an incoming stat (no agg type defined) matches a persisted
    * stat (with agg type defined)
    */
-  public static boolean isIncomingStatExactMatch(String currentStat,
-      String incomingStat)
-  {
+  public static boolean isIncomingStatExactMatch(String currentStat, String incomingStat) {
     return isExactMatch(currentStat, incomingStat, true);
   }
 
@@ -352,18 +308,14 @@ public class ExpressionParser
    * persisted stat (with agg type defined) The persisted stat may have
    * wildcards
    */
-  public static boolean isIncomingStatWildcardMatch(String currentStat,
-      String incomingStat)
-  {
+  public static boolean isIncomingStatWildcardMatch(String currentStat, String incomingStat) {
     return isWildcardMatch(currentStat, incomingStat, true, null);
   }
 
   /*
    * For checking if a persisted stat matches a stat defined in an alert
    */
-  public static boolean isAlertStatExactMatch(String alertStat,
-      String currentStat)
-  {
+  public static boolean isAlertStatExactMatch(String alertStat, String currentStat) {
     return isExactMatch(alertStat, currentStat, false);
   }
 
@@ -371,42 +323,33 @@ public class ExpressionParser
    * For checking if a maintained stat wildcard matches a stat defined in an
    * alert. The alert may have wildcards
    */
-  public static boolean isAlertStatWildcardMatch(String alertStat,
-      String currentStat, ArrayList<String> wildcardBindings)
-  {
+  public static boolean isAlertStatWildcardMatch(String alertStat, String currentStat,
+      ArrayList<String> wildcardBindings) {
     return isWildcardMatch(alertStat, currentStat, false, wildcardBindings);
   }
 
-  public static Aggregator getAggregator(String aggStr) throws HelixException
-  {
+  public static Aggregator getAggregator(String aggStr) throws HelixException {
     aggStr = aggStr.toUpperCase();
     Aggregator agg = aggregatorMap.get(aggStr);
-    if (agg == null)
-    {
+    if (agg == null) {
       throw new HelixException("Unknown aggregator type " + aggStr);
     }
     return agg;
   }
 
-  public static String getAggregatorStr(String expression)
-      throws HelixException
-  {
-    if (!expression.contains("("))
-    {
+  public static String getAggregatorStr(String expression) throws HelixException {
+    if (!expression.contains("(")) {
       throw new HelixException(expression
           + " does not contain a valid aggregator.  No parentheses found");
     }
     String aggName = expression.substring(0, expression.indexOf("("));
-    if (!aggregatorMap.containsKey(aggName.toUpperCase()))
-    {
+    if (!aggregatorMap.containsKey(aggName.toUpperCase())) {
       throw new HelixException("aggregator <" + aggName + "> is unknown type");
     }
     return aggName;
   }
 
-  public static String[] getAggregatorArgs(String expression)
-      throws HelixException
-  {
+  public static String[] getAggregatorArgs(String expression) throws HelixException {
     String aggregator = getAggregatorStr(expression);
     String argsStr = getAggregatorArgsStr(expression);
     String[] args = argsStr.split(argDelim);
@@ -415,10 +358,8 @@ public class ExpressionParser
     // String[] argList = (expression.substring(expression.indexOf("(")+1,
     // expression.indexOf(")"))).split(argDelim);
     // verify correct number of args
-    int requiredNumArgs = aggregatorMap.get(aggregator.toUpperCase())
-        .getRequiredNumArgs();
-    if (numArgs != requiredNumArgs)
-    {
+    int requiredNumArgs = aggregatorMap.get(aggregator.toUpperCase()).getRequiredNumArgs();
+    if (numArgs != requiredNumArgs) {
       throw new HelixException(expression + " contains " + args.length
           + " arguments, but requires " + requiredNumArgs);
     }
@@ -431,44 +372,32 @@ public class ExpressionParser
    * argsStr.split(argDelim); return args; }
    */
 
-  public static String getAggregatorArgsStr(String expression)
-  {
-    return expression.substring(expression.indexOf("(") + 1,
-        expression.indexOf(")"));
+  public static String getAggregatorArgsStr(String expression) {
+    return expression.substring(expression.indexOf("(") + 1, expression.indexOf(")"));
   }
 
-  public static String[] getAggregatorStats(String expression)
-      throws HelixException
-  {
+  public static String[] getAggregatorStats(String expression) throws HelixException {
     String justStats = expression;
-    if (expression.contains("(") && expression.contains(")"))
-    {
-      justStats = (expression.substring(expression.lastIndexOf("(") + 1,
-          expression.lastIndexOf(")")));
+    if (expression.contains("(") && expression.contains(")")) {
+      justStats =
+          (expression.substring(expression.lastIndexOf("(") + 1, expression.lastIndexOf(")")));
     }
     String[] statList = justStats.split(argDelim);
-    if (statList.length < 1)
-    {
-      throw new HelixException(expression
-          + " does not contain any aggregator stats");
+    if (statList.length < 1) {
+      throw new HelixException(expression + " does not contain any aggregator stats");
     }
     return statList;
   }
 
-  public static String getSingleAggregatorStat(String expression)
-      throws HelixException
-  {
+  public static String getSingleAggregatorStat(String expression) throws HelixException {
     String[] stats = getAggregatorStats(expression);
-    if (stats.length > 1)
-    {
+    if (stats.length > 1) {
       throw new HelixException(expression + " contains more than 1 stat");
     }
     return stats[0];
   }
 
-  public static String getWildcardStatSubstitution(String wildcardStat,
-      String fixedStat)
-  {
+  public static String getWildcardStatSubstitution(String wildcardStat, String fixedStat) {
     int lastOpenParenLoc = wildcardStat.lastIndexOf("(");
     int lastCloseParenLoc = wildcardStat.lastIndexOf(")");
     StringBuilder builder = new StringBuilder();
@@ -484,8 +413,7 @@ public class ExpressionParser
   // XXX: each op type should have number of inputs, number of outputs. do
   // validation.
   // (dbFoo.partition*.latency, dbFoo.partition*.count)|EACH|ACCUMULATE|DIVIDE
-  public static String[] getBaseStats(String expression) throws HelixException
-  {
+  public static String[] getBaseStats(String expression) throws HelixException {
     expression = expression.replaceAll("\\s+", "");
     validateAggregatorFormat(expression);
 
@@ -497,8 +425,7 @@ public class ExpressionParser
     String aggArgList = getAggregatorArgsStr(expression);
 
     String[] baseStats = new String[aggStats.length];
-    for (int i = 0; i < aggStats.length; i++)
-    {
+    for (int i = 0; i < aggStats.length; i++) {
       StringBuilder stat = new StringBuilder();
       stat.append(aggName);
       stat.append("(");
@@ -512,13 +439,11 @@ public class ExpressionParser
     return baseStats;
   }
 
-  public static String[] getOperators(String expression) throws HelixException
-  {
+  public static String[] getOperators(String expression) throws HelixException {
     String[] ops = null;
     int numAggStats = (getAggregatorStats(expression)).length;
     int opDelimLoc = expression.indexOf(opDelim);
-    if (opDelimLoc < 0)
-    {
+    if (opDelimLoc < 0) {
       return null;
     }
     logger.debug("ops str: " + expression.substring(opDelimLoc + 1));
@@ -529,51 +454,39 @@ public class ExpressionParser
     // take num input tuples sets and verify ops will output exactly 1 tuple
     // sets
     int currNumTuples = numAggStats;
-    for (String op : ops)
-    {
+    for (String op : ops) {
       logger.debug("op: " + op);
-      if (!operatorMap.containsKey(op.toUpperCase()))
-      {
+      if (!operatorMap.containsKey(op.toUpperCase())) {
         throw new HelixException("<" + op + "> is not a valid operator type");
       }
       Operator currOpType = operatorMap.get(op.toUpperCase());
       if (currNumTuples < currOpType.minInputTupleLists
-          || currNumTuples > currOpType.maxInputTupleLists)
-      {
-        throw new HelixException("<" + op + "> cannot process " + currNumTuples
-            + " input tuples");
+          || currNumTuples > currOpType.maxInputTupleLists) {
+        throw new HelixException("<" + op + "> cannot process " + currNumTuples + " input tuples");
       }
       // reset num tuples to this op's output size
-      if (!currOpType.inputOutputTupleListsCountsEqual)
-      { // if equal, this number does not change
+      if (!currOpType.inputOutputTupleListsCountsEqual) { // if equal, this number does not change
         currNumTuples = currOpType.numOutputTupleLists;
       }
     }
-    if (currNumTuples != 1)
-    {
-      throw new HelixException(expression
-          + " does not terminate in a single tuple set");
+    if (currNumTuples != 1) {
+      throw new HelixException(expression + " does not terminate in a single tuple set");
     }
     return ops;
   }
 
-  public static void validateOperators(String expression) throws HelixException
-  {
+  public static void validateOperators(String expression) throws HelixException {
     getOperators(expression);
   }
 
-  public static Operator getOperator(String opName) throws HelixException
-  {
-    if (!operatorMap.containsKey(opName))
-    {
+  public static Operator getOperator(String opName) throws HelixException {
+    if (!operatorMap.containsKey(opName)) {
       throw new HelixException(opName + " is unknown op type");
     }
     return operatorMap.get(opName);
   }
 
-  public static void validateExpression(String expression)
-      throws HelixException
-  {
+  public static void validateExpression(String expression) throws HelixException {
     // 1. extract stats part and validate
     validateAggregatorFormat(expression);
     // 2. extract ops part and validate the ops exist and the inputs/outputs are

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/alerts/GreaterAlertComparator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/GreaterAlertComparator.java b/helix-core/src/main/java/org/apache/helix/alerts/GreaterAlertComparator.java
index 1e234c1..0e9c8f1 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/GreaterAlertComparator.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/GreaterAlertComparator.java
@@ -23,23 +23,23 @@ import java.util.Iterator;
 
 public class GreaterAlertComparator extends AlertComparator {
 
-	@Override
-	/*
-	 * Returns true if any element left tuple exceeds any element in right tuple
-	 */
-	public boolean evaluate(Tuple<String> leftTup, Tuple<String> rightTup) {
-		Iterator<String> leftIter = leftTup.iterator();
-		while (leftIter.hasNext()) {
-			double leftVal = Double.parseDouble(leftIter.next());
-			Iterator<String> rightIter = rightTup.iterator();
-			while (rightIter.hasNext()) {
-				double rightVal = Double.parseDouble(rightIter.next());
-				if (leftVal > rightVal) {
-					return true;
-				}
-			}
-		}
-		return false;
-	}
+  @Override
+  /*
+   * Returns true if any element left tuple exceeds any element in right tuple
+   */
+  public boolean evaluate(Tuple<String> leftTup, Tuple<String> rightTup) {
+    Iterator<String> leftIter = leftTup.iterator();
+    while (leftIter.hasNext()) {
+      double leftVal = Double.parseDouble(leftIter.next());
+      Iterator<String> rightIter = rightTup.iterator();
+      while (rightIter.hasNext()) {
+        double rightVal = Double.parseDouble(rightIter.next());
+        if (leftVal > rightVal) {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/alerts/MultiplyOperator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/MultiplyOperator.java b/helix-core/src/main/java/org/apache/helix/alerts/MultiplyOperator.java
index de02c61..74a4688 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/MultiplyOperator.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/MultiplyOperator.java
@@ -25,39 +25,36 @@ import java.util.List;
 
 public class MultiplyOperator extends Operator {
 
-	public MultiplyOperator() {
-		minInputTupleLists = 1;
-		maxInputTupleLists = Integer.MAX_VALUE;
-		inputOutputTupleListsCountsEqual = false;
-		numOutputTupleLists = 1;
-	}
+  public MultiplyOperator() {
+    minInputTupleLists = 1;
+    maxInputTupleLists = Integer.MAX_VALUE;
+    inputOutputTupleListsCountsEqual = false;
+    numOutputTupleLists = 1;
+  }
 
-	
-	public List<Iterator<Tuple<String>>> singleSetToIter(ArrayList<Tuple<String>> input) 
-	{
-		List out = new ArrayList();
-		out.add(input.iterator());
-		return out;
-	}
-	
-	
-	
-	@Override
-	public List<Iterator<Tuple<String>>> execute(List<Iterator<Tuple<String>>> input) {
-		ArrayList<Tuple<String>> output = new ArrayList<Tuple<String>>();
-		if (input == null || input.size() == 0) {
-			return singleSetToIter(output);
-		}
-		while (true) { //loop through set of iters, return when 1 runs out (not completing the row in progress)
-			Tuple<String> rowProduct = null;
-			for (Iterator<Tuple<String>> it : input) {
-				if (!it.hasNext()) { //when any iterator runs out, we are done
-					return singleSetToIter(output);
-				}
-				rowProduct = multiplyTuples(rowProduct, it.next());
-			}
-			output.add(rowProduct);
-		}
-	}
+  public List<Iterator<Tuple<String>>> singleSetToIter(ArrayList<Tuple<String>> input) {
+    List out = new ArrayList();
+    out.add(input.iterator());
+    return out;
+  }
+
+  @Override
+  public List<Iterator<Tuple<String>>> execute(List<Iterator<Tuple<String>>> input) {
+    ArrayList<Tuple<String>> output = new ArrayList<Tuple<String>>();
+    if (input == null || input.size() == 0) {
+      return singleSetToIter(output);
+    }
+    while (true) { // loop through set of iters, return when 1 runs out (not completing the row in
+                   // progress)
+      Tuple<String> rowProduct = null;
+      for (Iterator<Tuple<String>> it : input) {
+        if (!it.hasNext()) { // when any iterator runs out, we are done
+          return singleSetToIter(output);
+        }
+        rowProduct = multiplyTuples(rowProduct, it.next());
+      }
+      output.add(rowProduct);
+    }
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/alerts/Operator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/Operator.java b/helix-core/src/main/java/org/apache/helix/alerts/Operator.java
index 9f3e852..0612cf3 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/Operator.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/Operator.java
@@ -23,97 +23,89 @@ import java.util.Iterator;
 import java.util.List;
 
 public abstract class Operator {
-	
-	public int minInputTupleLists;
-	public int maxInputTupleLists;
-	public int numOutputTupleLists = -1;
-	public boolean inputOutputTupleListsCountsEqual = false;
-	
-	public Operator()
-	{
-		
-	}
-	
-	public Tuple<String> multiplyTuples(Tuple<String> tup1, Tuple<String> tup2)
-	{
-		if (tup1 == null) {
-			return tup2;
-		}
-		if (tup2 == null) {
-			return tup1;
-		}
-		Tuple<String>outputTup = new Tuple<String>();
-		
 
-		//sum staggers if the tuples are same length
-		//e.g. 1,2,3 + 4,5 = 1,6,8
-		//so this is a bit tricky
-		Tuple<String>largerTup;
-		Tuple<String>smallerTup;
-		if (tup1.size() >= tup2.size()) {
-			largerTup = tup1;
-			smallerTup = tup2;
-		}
-		else {
-			largerTup = tup2;
-			smallerTup = tup1;
-		}		
-		int gap = largerTup.size() - smallerTup.size();
-		
-		for (int i=0; i< largerTup.size();i++) {
-			if (i < gap) {
-				outputTup.add(largerTup.getElement(i));
-			}
-			else {
-				double elementProduct = 0;
-				elementProduct = Double.parseDouble(largerTup.getElement(i)) *
-						Double.parseDouble(smallerTup.getElement(i-gap));
-				outputTup.add(String.valueOf(elementProduct));
-			}
-		}
-		return outputTup;
-	}
-	
-	public Tuple<String> sumTuples(Tuple<String> tup1, Tuple<String> tup2)
-	{
-		if (tup1 == null) {
-			return tup2;
-		}
-		if (tup2 == null) {
-			return tup1;
-		}
-		Tuple<String>outputTup = new Tuple<String>();
-		
+  public int minInputTupleLists;
+  public int maxInputTupleLists;
+  public int numOutputTupleLists = -1;
+  public boolean inputOutputTupleListsCountsEqual = false;
 
-		//sum staggers if the tuples are same length
-		//e.g. 1,2,3 + 4,5 = 1,6,8
-		//so this is a bit tricky
-		Tuple<String>largerTup;
-		Tuple<String>smallerTup;
-		if (tup1.size() >= tup2.size()) {
-			largerTup = tup1;
-			smallerTup = tup2;
-		}
-		else {
-			largerTup = tup2;
-			smallerTup = tup1;
-		}		
-		int gap = largerTup.size() - smallerTup.size();
-		
-		for (int i=0; i< largerTup.size();i++) {
-			if (i < gap) {
-				outputTup.add(largerTup.getElement(i));
-			}
-			else {
-				double elementSum = 0;
-				elementSum = Double.parseDouble(largerTup.getElement(i)) +
-						Double.parseDouble(smallerTup.getElement(i-gap));
-				outputTup.add(String.valueOf(elementSum));
-			}
-		}
-		return outputTup;
-	}
-	
-	public abstract List<Iterator<Tuple<String>>> execute(List<Iterator<Tuple<String>>> input);
-}
+  public Operator() {
+
+  }
+
+  public Tuple<String> multiplyTuples(Tuple<String> tup1, Tuple<String> tup2) {
+    if (tup1 == null) {
+      return tup2;
+    }
+    if (tup2 == null) {
+      return tup1;
+    }
+    Tuple<String> outputTup = new Tuple<String>();
+
+    // sum staggers if the tuples are same length
+    // e.g. 1,2,3 + 4,5 = 1,6,8
+    // so this is a bit tricky
+    Tuple<String> largerTup;
+    Tuple<String> smallerTup;
+    if (tup1.size() >= tup2.size()) {
+      largerTup = tup1;
+      smallerTup = tup2;
+    } else {
+      largerTup = tup2;
+      smallerTup = tup1;
+    }
+    int gap = largerTup.size() - smallerTup.size();
+
+    for (int i = 0; i < largerTup.size(); i++) {
+      if (i < gap) {
+        outputTup.add(largerTup.getElement(i));
+      } else {
+        double elementProduct = 0;
+        elementProduct =
+            Double.parseDouble(largerTup.getElement(i))
+                * Double.parseDouble(smallerTup.getElement(i - gap));
+        outputTup.add(String.valueOf(elementProduct));
+      }
+    }
+    return outputTup;
+  }
 
+  public Tuple<String> sumTuples(Tuple<String> tup1, Tuple<String> tup2) {
+    if (tup1 == null) {
+      return tup2;
+    }
+    if (tup2 == null) {
+      return tup1;
+    }
+    Tuple<String> outputTup = new Tuple<String>();
+
+    // sum staggers if the tuples are same length
+    // e.g. 1,2,3 + 4,5 = 1,6,8
+    // so this is a bit tricky
+    Tuple<String> largerTup;
+    Tuple<String> smallerTup;
+    if (tup1.size() >= tup2.size()) {
+      largerTup = tup1;
+      smallerTup = tup2;
+    } else {
+      largerTup = tup2;
+      smallerTup = tup1;
+    }
+    int gap = largerTup.size() - smallerTup.size();
+
+    for (int i = 0; i < largerTup.size(); i++) {
+      if (i < gap) {
+        outputTup.add(largerTup.getElement(i));
+      } else {
+        double elementSum = 0;
+        elementSum =
+            Double.parseDouble(largerTup.getElement(i))
+                + Double.parseDouble(smallerTup.getElement(i - gap));
+        outputTup.add(String.valueOf(elementSum));
+      }
+    }
+    return outputTup;
+  }
+
+  public abstract List<Iterator<Tuple<String>>> execute(List<Iterator<Tuple<String>>> input);
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/alerts/Stat.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/Stat.java b/helix-core/src/main/java/org/apache/helix/alerts/Stat.java
index 3b8cbe3..6895128 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/Stat.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/Stat.java
@@ -20,29 +20,25 @@ package org.apache.helix.alerts;
  */
 
 public class Stat {
-	String _name;
-	Tuple<String> _value;
-	Tuple<String> _timestamp;
-	
-	public Stat(String name, Tuple<String> value, Tuple<String> timestamp)
-	{
-		_name = name;
-		_value = value;
-		_timestamp = timestamp;
-	}
-	
-	public String getName()
-	{
-		return _name;
-	}
-	
-	public Tuple<String> getValue()
-	{
-		return _value;
-	}
-	
-	public Tuple<String> getTimestamp()
-	{
-		return _timestamp;
-	}
+  String _name;
+  Tuple<String> _value;
+  Tuple<String> _timestamp;
+
+  public Stat(String name, Tuple<String> value, Tuple<String> timestamp) {
+    _name = name;
+    _value = value;
+    _timestamp = timestamp;
+  }
+
+  public String getName() {
+    return _name;
+  }
+
+  public Tuple<String> getValue() {
+    return _value;
+  }
+
+  public Tuple<String> getTimestamp() {
+    return _timestamp;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/alerts/StatsHolder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/StatsHolder.java b/helix-core/src/main/java/org/apache/helix/alerts/StatsHolder.java
index 51efaf6..97ae463 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/StatsHolder.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/StatsHolder.java
@@ -38,13 +38,14 @@ import org.apache.helix.controller.stages.HealthDataCache;
 import org.apache.helix.model.PersistentStats;
 import org.apache.log4j.Logger;
 
+public class StatsHolder {
+  enum MatchResult {
+    WILDCARDMATCH,
+    EXACTMATCH,
+    NOMATCH
+  };
 
-public class StatsHolder
-{
-  enum MatchResult {WILDCARDMATCH, EXACTMATCH, NOMATCH};
-  
-  private static final Logger logger = Logger.getLogger(StatsHolder.class
-      .getName());
+  private static final Logger logger = Logger.getLogger(StatsHolder.class.getName());
 
   public static final String VALUE_NAME = "value";
   public static final String TIMESTAMP_NAME = "TimeStamp";
@@ -56,43 +57,38 @@ public class StatsHolder
   Map<String, Map<String, MatchResult>> _statAlertMatchResult;
 
   private Builder _keyBuilder;
+
   // PersistentStats _persistentStats;
 
-  public StatsHolder(HelixManager manager, HealthDataCache cache)
-  {
+  public StatsHolder(HelixManager manager, HealthDataCache cache) {
     _accessor = manager.getHelixDataAccessor();
     _cache = cache;
     _keyBuilder = new PropertyKey.Builder(manager.getClusterName());
     updateCache(_cache);
     _statAlertMatchResult = new HashMap<String, Map<String, MatchResult>>();
-    
+
   }
 
-  public void refreshStats()
-  {
+  public void refreshStats() {
     logger.info("Refreshing cached stats");
     _cache.refresh(_accessor);
     updateCache(_cache);
   }
 
-  public void persistStats()
-  {
+  public void persistStats() {
     // XXX: Am I using _accessor too directly here?
     // took around 35 ms from desktop to ESV4 machine
     PersistentStats stats = _accessor.getProperty(_keyBuilder.persistantStat());
-    if (stats == null)
-    {
+    if (stats == null) {
       stats = new PersistentStats(PersistentStats.nodeName); // TODO: fix naming of
-                                                         // this record, if it
-                                                         // matters
+      // this record, if it
+      // matters
     }
     stats.getRecord().setMapFields(_statMap);
-    boolean retVal = _accessor.setProperty(_keyBuilder.persistantStat(),
-        stats);
+    boolean retVal = _accessor.setProperty(_keyBuilder.persistantStat(), stats);
   }
 
-  public void getStatsFromCache(boolean refresh)
-  {
+  public void getStatsFromCache(boolean refresh) {
     long refreshStartTime = System.currentTimeMillis();
     if (refresh) {
       _cache.refresh(_accessor);
@@ -100,27 +96,24 @@ public class StatsHolder
     PersistentStats persistentStatRecord = _cache.getPersistentStats();
     if (persistentStatRecord != null) {
       _statMap = persistentStatRecord.getMapFields();
-    }
-    else {
-      _statMap = new HashMap<String,Map<String,String>>();
+    } else {
+      _statMap = new HashMap<String, Map<String, String>>();
     }
     /*
-		if (_cache.getPersistentStats() != null) {
-
-			_statMap = _cache.getPersistentStats();
-		}
+     * if (_cache.getPersistentStats() != null) {
+     * _statMap = _cache.getPersistentStats();
+     * }
      */
-    //TODO: confirm this a good place to init the _statMap when null
+    // TODO: confirm this a good place to init the _statMap when null
     /*
-		if (_statMap == null) {
-			_statMap = new HashMap<String, Map<String, String>>();
-		}
+     * if (_statMap == null) {
+     * _statMap = new HashMap<String, Map<String, String>>();
+     * }
      */
-    System.out.println("Refresh stats done: "+(System.currentTimeMillis() - refreshStartTime));
+    System.out.println("Refresh stats done: " + (System.currentTimeMillis() - refreshStartTime));
   }
 
-  public Iterator<String> getAllStats()
-  {
+  public Iterator<String> getAllStats() {
     return null;
   }
 
@@ -128,16 +121,12 @@ public class StatsHolder
    * TODO: figure out pre-conditions here. I think not allowing anything to be
    * null on input
    */
-  public Map<String, String> mergeStats(String statName,
-      Map<String, String> existingStat, Map<String, String> incomingStat)
-      throws HelixException
-  {
-    if (existingStat == null)
-    {
+  public Map<String, String> mergeStats(String statName, Map<String, String> existingStat,
+      Map<String, String> incomingStat) throws HelixException {
+    if (existingStat == null) {
       throw new HelixException("existing stat for merge is null");
     }
-    if (incomingStat == null)
-    {
+    if (incomingStat == null) {
       throw new HelixException("incoming stat for merge is null");
     }
     // get agg type and arguments, then get agg object
@@ -152,26 +141,21 @@ public class StatsHolder
     String incomingTime = incomingStat.get(TIMESTAMP_NAME);
     String incomingVal = incomingStat.get(VALUE_NAME);
     // parse values into tuples, if the values exist. else, tuples are null
-    Tuple<String> existingTimeTuple = (existingTime != null) ? Tuple
-        .fromString(existingTime) : null;
-    Tuple<String> existingValueTuple = (existingVal != null) ? Tuple
-        .fromString(existingVal) : null;
-    Tuple<String> incomingTimeTuple = (incomingTime != null) ? Tuple
-        .fromString(incomingTime) : null;
-    Tuple<String> incomingValueTuple = (incomingVal != null) ? Tuple
-        .fromString(incomingVal) : null;
+    Tuple<String> existingTimeTuple =
+        (existingTime != null) ? Tuple.fromString(existingTime) : null;
+    Tuple<String> existingValueTuple = (existingVal != null) ? Tuple.fromString(existingVal) : null;
+    Tuple<String> incomingTimeTuple =
+        (incomingTime != null) ? Tuple.fromString(incomingTime) : null;
+    Tuple<String> incomingValueTuple = (incomingVal != null) ? Tuple.fromString(incomingVal) : null;
 
     // dp merge
-    agg.merge(existingValueTuple, incomingValueTuple, existingTimeTuple,
-        incomingTimeTuple, aggArgs);
+    agg.merge(existingValueTuple, incomingValueTuple, existingTimeTuple, incomingTimeTuple, aggArgs);
     // put merged tuples back in map
     Map<String, String> mergedMap = new HashMap<String, String>();
-    if (existingTimeTuple.size() == 0)
-    {
+    if (existingTimeTuple.size() == 0) {
       throw new HelixException("merged time tuple has size zero");
     }
-    if (existingValueTuple.size() == 0)
-    {
+    if (existingValueTuple.size() == 0) {
       throw new HelixException("merged value tuple has size zero");
     }
 
@@ -188,84 +172,65 @@ public class StatsHolder
 
   // need to do a time check here!
 
-  public void applyStat(String incomingStatName, Map<String, String> statFields)
-  {
+  public void applyStat(String incomingStatName, Map<String, String> statFields) {
     // TODO: consider locking stats here
-    //refreshStats(); //will have refreshed by now during stage
+    // refreshStats(); //will have refreshed by now during stage
 
     Map<String, Map<String, String>> pendingAdds = new HashMap<String, Map<String, String>>();
-    
-    if(!_statAlertMatchResult.containsKey(incomingStatName))
-    {
+
+    if (!_statAlertMatchResult.containsKey(incomingStatName)) {
       _statAlertMatchResult.put(incomingStatName, new HashMap<String, MatchResult>());
     }
     Map<String, MatchResult> resultMap = _statAlertMatchResult.get(incomingStatName);
     // traverse through all persistent stats
-    for (String key : _statMap.keySet())
-    {
-      if(resultMap.containsKey(key))
-      {
+    for (String key : _statMap.keySet()) {
+      if (resultMap.containsKey(key)) {
         MatchResult cachedMatchResult = resultMap.get(key);
-        if(cachedMatchResult == MatchResult.EXACTMATCH)
-        {
+        if (cachedMatchResult == MatchResult.EXACTMATCH) {
           processExactMatch(key, statFields);
-        }
-        else if(cachedMatchResult == MatchResult.WILDCARDMATCH)
-        {
-          processWildcardMatch(incomingStatName, key,statFields, pendingAdds);
+        } else if (cachedMatchResult == MatchResult.WILDCARDMATCH) {
+          processWildcardMatch(incomingStatName, key, statFields, pendingAdds);
         }
         // don't care about NOMATCH
         continue;
       }
       // exact match on stat and stat portion of persisted stat, just update
-      if (ExpressionParser.isIncomingStatExactMatch(key, incomingStatName))
-      {
+      if (ExpressionParser.isIncomingStatExactMatch(key, incomingStatName)) {
         processExactMatch(key, statFields);
         resultMap.put(key, MatchResult.EXACTMATCH);
       }
       // wildcard match
-      else if (ExpressionParser.isIncomingStatWildcardMatch(key,
-          incomingStatName))
-      {
-        processWildcardMatch(incomingStatName, key,statFields, pendingAdds);
+      else if (ExpressionParser.isIncomingStatWildcardMatch(key, incomingStatName)) {
+        processWildcardMatch(incomingStatName, key, statFields, pendingAdds);
         resultMap.put(key, MatchResult.WILDCARDMATCH);
-      }
-      else
-      {
+      } else {
         resultMap.put(key, MatchResult.NOMATCH);
       }
     }
     _statMap.putAll(pendingAdds);
-  } 
-  
-  void processExactMatch(String key, Map<String, String> statFields)
-  {
-    Map<String, String> mergedStat = mergeStats(key, _statMap.get(key),
-        statFields);
+  }
+
+  void processExactMatch(String key, Map<String, String> statFields) {
+    Map<String, String> mergedStat = mergeStats(key, _statMap.get(key), statFields);
     // update in place, no problem with hash map
     _statMap.put(key, mergedStat);
   }
-  
-  void processWildcardMatch(String incomingStatName, String key, 
-      Map<String, String> statFields,  Map<String, Map<String, String>> pendingAdds)
-  {
+
+  void processWildcardMatch(String incomingStatName, String key, Map<String, String> statFields,
+      Map<String, Map<String, String>> pendingAdds) {
 
     // make sure incoming stat doesn't already exist, either in previous
     // round or this round
     // form new key (incomingStatName with agg type from the wildcarded
     // stat)
-    String statToAdd = ExpressionParser.getWildcardStatSubstitution(key,
-        incomingStatName);
+    String statToAdd = ExpressionParser.getWildcardStatSubstitution(key, incomingStatName);
     // if the stat already existed in _statMap, we have/will apply it as an
     // exact match
     // if the stat was added this round to pendingAdds, no need to recreate
     // (it would have same value)
-    if (!_statMap.containsKey(statToAdd)
-        && !pendingAdds.containsKey(statToAdd))
-    {
+    if (!_statMap.containsKey(statToAdd) && !pendingAdds.containsKey(statToAdd)) {
       // add this stat to persisted stats
-      Map<String, String> mergedStat = mergeStats(statToAdd,
-          getEmptyStat(), statFields);
+      Map<String, String> mergedStat = mergeStats(statToAdd, getEmptyStat(), statFields);
       // add to pendingAdds so we don't mess up ongoing traversal of
       // _statMap
       pendingAdds.put(statToAdd, mergedStat);
@@ -274,16 +239,13 @@ public class StatsHolder
 
   // add parsing of stat (or is that in expression holder?) at least add
   // validate
-  public void addStat(String exp) throws HelixException
-  {
+  public void addStat(String exp) throws HelixException {
     refreshStats(); // get current stats
 
     String[] parsedStats = ExpressionParser.getBaseStats(exp);
 
-    for (String stat : parsedStats)
-    {
-      if (_statMap.containsKey(stat))
-      {
+    for (String stat : parsedStats) {
+      if (_statMap.containsKey(stat)) {
         logger.debug("Stat " + stat + " already exists; not adding");
         continue;
       }
@@ -291,16 +253,12 @@ public class StatsHolder
     }
   }
 
-  public static Map<String, Map<String, String>> parseStat(String exp)
-      throws HelixException
-  {
+  public static Map<String, Map<String, String>> parseStat(String exp) throws HelixException {
     String[] parsedStats = ExpressionParser.getBaseStats(exp);
     Map<String, Map<String, String>> statMap = new HashMap<String, Map<String, String>>();
 
-    for (String stat : parsedStats)
-    {
-      if (statMap.containsKey(stat))
-      {
+    for (String stat : parsedStats) {
+      if (statMap.containsKey(stat)) {
         logger.debug("Stat " + stat + " already exists; not adding");
         continue;
       }
@@ -309,20 +267,16 @@ public class StatsHolder
     return statMap;
   }
 
-
-  public static Map<String, String> getEmptyStat()
-  {
+  public static Map<String, String> getEmptyStat() {
     Map<String, String> statFields = new HashMap<String, String>();
     statFields.put(TIMESTAMP_NAME, "");
     statFields.put(VALUE_NAME, "");
     return statFields;
   }
 
-  public List<Stat> getStatsList()
-  {
+  public List<Stat> getStatsList() {
     List<Stat> stats = new LinkedList<Stat>();
-    for (String stat : _statMap.keySet())
-    {
+    for (String stat : _statMap.keySet()) {
       Map<String, String> statFields = _statMap.get(stat);
       Tuple<String> valTup = Tuple.fromString(statFields.get(VALUE_NAME));
       Tuple<String> timeTup = Tuple.fromString(statFields.get(TIMESTAMP_NAME));
@@ -332,12 +286,10 @@ public class StatsHolder
     return stats;
   }
 
-  public Map<String, Tuple<String>> getStatsMap()
-  {
-    //refreshStats(); //don't refresh, stage will have refreshed by this time
+  public Map<String, Tuple<String>> getStatsMap() {
+    // refreshStats(); //don't refresh, stage will have refreshed by this time
     HashMap<String, Tuple<String>> stats = new HashMap<String, Tuple<String>>();
-    for (String stat : _statMap.keySet())
-    {
+    for (String stat : _statMap.keySet()) {
       Map<String, String> statFields = _statMap.get(stat);
       Tuple<String> valTup = Tuple.fromString(statFields.get(VALUE_NAME));
       Tuple<String> timeTup = Tuple.fromString(statFields.get(TIMESTAMP_NAME));
@@ -346,16 +298,12 @@ public class StatsHolder
     return stats;
   }
 
-  public void updateCache(HealthDataCache cache)
-  {
+  public void updateCache(HealthDataCache cache) {
     _cache = cache;
     PersistentStats persistentStatRecord = _cache.getPersistentStats();
-    if (persistentStatRecord != null)
-    {
+    if (persistentStatRecord != null) {
       _statMap = persistentStatRecord.getMapFields();
-    }
-    else
-    {
+    } else {
       _statMap = new HashMap<String, Map<String, String>>();
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/alerts/SumEachOperator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/SumEachOperator.java b/helix-core/src/main/java/org/apache/helix/alerts/SumEachOperator.java
index 18ece89..2cc733f 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/SumEachOperator.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/SumEachOperator.java
@@ -25,27 +25,27 @@ import java.util.List;
 
 public class SumEachOperator extends Operator {
 
-	public SumEachOperator() {
-		minInputTupleLists = 1;
-		maxInputTupleLists = Integer.MAX_VALUE;
-		inputOutputTupleListsCountsEqual = true;
-		numOutputTupleLists = -1;
-	}
+  public SumEachOperator() {
+    minInputTupleLists = 1;
+    maxInputTupleLists = Integer.MAX_VALUE;
+    inputOutputTupleListsCountsEqual = true;
+    numOutputTupleLists = -1;
+  }
 
-	//for each column, generate sum
-	@Override
-	public List<Iterator<Tuple<String>>> execute(List<Iterator<Tuple<String>>> input) {
-		List<Iterator<Tuple<String>>> out = new ArrayList<Iterator<Tuple<String>>>();
-		for (Iterator<Tuple<String>> currIt : input) {
-			Tuple<String> currSum = null;
-			while (currIt.hasNext()) {
-				currSum = sumTuples(currSum, currIt.next());
-			}
-			ArrayList<Tuple<String>> currOutList = new ArrayList<Tuple<String>>();
-			currOutList.add(currSum);
-			out.add(currOutList.iterator());
-		}
-		return out;
-	}
+  // for each column, generate sum
+  @Override
+  public List<Iterator<Tuple<String>>> execute(List<Iterator<Tuple<String>>> input) {
+    List<Iterator<Tuple<String>>> out = new ArrayList<Iterator<Tuple<String>>>();
+    for (Iterator<Tuple<String>> currIt : input) {
+      Tuple<String> currSum = null;
+      while (currIt.hasNext()) {
+        currSum = sumTuples(currSum, currIt.next());
+      }
+      ArrayList<Tuple<String>> currOutList = new ArrayList<Tuple<String>>();
+      currOutList.add(currSum);
+      out.add(currOutList.iterator());
+    }
+    return out;
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/alerts/SumOperator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/SumOperator.java b/helix-core/src/main/java/org/apache/helix/alerts/SumOperator.java
index 0a495de..90c9ab0 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/SumOperator.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/SumOperator.java
@@ -25,36 +25,35 @@ import java.util.List;
 
 public class SumOperator extends Operator {
 
-	public SumOperator() {
-		minInputTupleLists = 1;
-		maxInputTupleLists = Integer.MAX_VALUE;
-		inputOutputTupleListsCountsEqual = false;
-		numOutputTupleLists = 1;
-	}
+  public SumOperator() {
+    minInputTupleLists = 1;
+    maxInputTupleLists = Integer.MAX_VALUE;
+    inputOutputTupleListsCountsEqual = false;
+    numOutputTupleLists = 1;
+  }
 
-	
-	public List<Iterator<Tuple<String>>> singleSetToIter(ArrayList<Tuple<String>> input) 
-	{
-		List out = new ArrayList();
-		out.add(input.iterator());
-		return out;
-	}
-	
-	@Override
-	public List<Iterator<Tuple<String>>> execute(List<Iterator<Tuple<String>>> input) {
-		ArrayList<Tuple<String>> output = new ArrayList<Tuple<String>>();
-		if (input == null || input.size() == 0) {
-			return singleSetToIter(output);
-		}
-		while (true) { //loop through set of iters, return when 1 runs out (not completing the row in progress)
-			Tuple<String> rowSum = null;
-			for (Iterator<Tuple<String>> it : input) {
-				if (!it.hasNext()) { //when any iterator runs out, we are done
-					return singleSetToIter(output);
-				}
-				rowSum = sumTuples(rowSum, it.next());
-			}
-			output.add(rowSum);
-		}
-	}
+  public List<Iterator<Tuple<String>>> singleSetToIter(ArrayList<Tuple<String>> input) {
+    List out = new ArrayList();
+    out.add(input.iterator());
+    return out;
+  }
+
+  @Override
+  public List<Iterator<Tuple<String>>> execute(List<Iterator<Tuple<String>>> input) {
+    ArrayList<Tuple<String>> output = new ArrayList<Tuple<String>>();
+    if (input == null || input.size() == 0) {
+      return singleSetToIter(output);
+    }
+    while (true) { // loop through set of iters, return when 1 runs out (not completing the row in
+                   // progress)
+      Tuple<String> rowSum = null;
+      for (Iterator<Tuple<String>> it : input) {
+        if (!it.hasNext()) { // when any iterator runs out, we are done
+          return singleSetToIter(output);
+        }
+        rowSum = sumTuples(rowSum, it.next());
+      }
+      output.add(rowSum);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/alerts/Tuple.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/Tuple.java b/helix-core/src/main/java/org/apache/helix/alerts/Tuple.java
index f9c484b..9a876a4 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/Tuple.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/Tuple.java
@@ -27,72 +27,62 @@ import java.util.StringTokenizer;
 import java.util.Vector;
 
 public class Tuple<T> {
-	List<T> elements;
-	
-	public Tuple() 
-	{
-		elements = new ArrayList<T>();
-	}
-	
-	public int size()
-	{
-		return elements.size();
-	}
+  List<T> elements;
 
-	public void add(T entry)
-	{
-		elements.add(entry);
-	}
-	
-	public void addAll(Tuple<T> incoming)
-	{
-		elements.addAll(incoming.getElements());
-	}
-	
-	public Iterator<T> iterator()
-	{
-		return elements.listIterator();
-	}
-	
-	public T getElement(int ind)
-	{
-		return elements.get(ind);
-	}
-	
-	public List<T> getElements()
-	{
-		return elements;
-	}
-	
-	public void clear() 
-	{
-		elements.clear();
-	}
-	
-	public static Tuple<String> fromString(String in) 
-	{
-		Tuple<String> tup = new Tuple<String>();
-		if (in.length() > 0) {
-			String[] elements = in.split(",");
-			for (String element : elements) {
-				tup.add(element);
-			}
-		}
-		return tup;
-	}
-	
-	public String toString() 
-	{
-		StringBuilder out = new StringBuilder();
-		Iterator<T> it = iterator();
-		boolean outEmpty=true;
-		while (it.hasNext()) {
-			if (!outEmpty) {
-				out.append(",");
-			}
-			out.append(it.next());
-			outEmpty = false;
-		}
-		return out.toString();
-	}
+  public Tuple() {
+    elements = new ArrayList<T>();
+  }
+
+  public int size() {
+    return elements.size();
+  }
+
+  public void add(T entry) {
+    elements.add(entry);
+  }
+
+  public void addAll(Tuple<T> incoming) {
+    elements.addAll(incoming.getElements());
+  }
+
+  public Iterator<T> iterator() {
+    return elements.listIterator();
+  }
+
+  public T getElement(int ind) {
+    return elements.get(ind);
+  }
+
+  public List<T> getElements() {
+    return elements;
+  }
+
+  public void clear() {
+    elements.clear();
+  }
+
+  public static Tuple<String> fromString(String in) {
+    Tuple<String> tup = new Tuple<String>();
+    if (in.length() > 0) {
+      String[] elements = in.split(",");
+      for (String element : elements) {
+        tup.add(element);
+      }
+    }
+    return tup;
+  }
+
+  public String toString() {
+    StringBuilder out = new StringBuilder();
+    Iterator<T> it = iterator();
+    boolean outEmpty = true;
+    while (it.hasNext()) {
+      if (!outEmpty) {
+        out.append(",");
+      }
+      out.append(it.next());
+      outEmpty = false;
+    }
+    return out.toString();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/alerts/WindowAggregator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/WindowAggregator.java b/helix-core/src/main/java/org/apache/helix/alerts/WindowAggregator.java
index 55f1050..ff4340c 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/WindowAggregator.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/WindowAggregator.java
@@ -23,73 +23,71 @@ import java.util.Iterator;
 
 import org.apache.helix.HelixException;
 
-
 public class WindowAggregator extends Aggregator {
 
-	
-	int _windowSize;
-	
-	public WindowAggregator(String windowSize) 
-	{
-		_windowSize = Integer.parseInt(windowSize);
-		_numArgs = 1;
-	}
-	
-	public WindowAggregator()
-	{
-		this("1");
-	}
+  int _windowSize;
+
+  public WindowAggregator(String windowSize) {
+    _windowSize = Integer.parseInt(windowSize);
+    _numArgs = 1;
+  }
+
+  public WindowAggregator() {
+    this("1");
+  }
+
+  @Override
+  public void merge(Tuple<String> currValTup, Tuple<String> newValTup, Tuple<String> currTimeTup,
+      Tuple<String> newTimeTup, String... args) {
+
+    _windowSize = Integer.parseInt(args[0]);
+
+    // figure out how many curr tuple values we displace
+    Tuple<String> mergedTimeTuple = new Tuple<String>();
+    Tuple<String> mergedValTuple = new Tuple<String>();
 
-	@Override
-	public void merge(Tuple<String> currValTup, Tuple<String> newValTup,
-			Tuple<String> currTimeTup, Tuple<String> newTimeTup, String... args) {
-		
-		_windowSize = Integer.parseInt(args[0]);
-		
-		//figure out how many curr tuple values we displace
-		Tuple<String> mergedTimeTuple = new Tuple<String>();
-		Tuple<String> mergedValTuple = new Tuple<String>();
-		
-		Iterator<String> currTimeIter = currTimeTup.iterator();
-		Iterator<String> currValIter = currValTup.iterator();
-		Iterator<String> newTimeIter = newTimeTup.iterator();
-		Iterator<String> newValIter = newValTup.iterator();
-		int currCtr = 0;
-		//traverse current vals
-		double currTime = -1;
-		double currVal;
-		while (currTimeIter.hasNext()) {
-			currTime = Double.parseDouble(currTimeIter.next());
-			currVal = Double.parseDouble(currValIter.next());
-			currCtr++;
-			//number of evicted currVals equal to total size of both minus _windowSize
-			if (currCtr > (newTimeTup.size()+currTimeTup.size()-_windowSize)) { //non-evicted element, just bump down
-				mergedTimeTuple.add(String.valueOf(currTime));
-				mergedValTuple.add(String.valueOf(currVal));
-			}
-		}
+    Iterator<String> currTimeIter = currTimeTup.iterator();
+    Iterator<String> currValIter = currValTup.iterator();
+    Iterator<String> newTimeIter = newTimeTup.iterator();
+    Iterator<String> newValIter = newValTup.iterator();
+    int currCtr = 0;
+    // traverse current vals
+    double currTime = -1;
+    double currVal;
+    while (currTimeIter.hasNext()) {
+      currTime = Double.parseDouble(currTimeIter.next());
+      currVal = Double.parseDouble(currValIter.next());
+      currCtr++;
+      // number of evicted currVals equal to total size of both minus _windowSize
+      if (currCtr > (newTimeTup.size() + currTimeTup.size() - _windowSize)) { // non-evicted
+                                                                              // element, just bump
+                                                                              // down
+        mergedTimeTuple.add(String.valueOf(currTime));
+        mergedValTuple.add(String.valueOf(currVal));
+      }
+    }
 
-		double newVal;
-		double newTime;
-		while (newTimeIter.hasNext()) {
-			newVal = Double.parseDouble(newValIter.next());
-			newTime = Double.parseDouble(newTimeIter.next());
-			if (newTime <= currTime) { //oldest new time older than newest curr time.  we will not apply new tuple!
-				return; //curr tuples remain the same
-			}
-			currCtr++;
-			if (currCtr > (newTimeTup.size()+currTimeTup.size()-_windowSize)) { //non-evicted element
-				mergedTimeTuple.add(String.valueOf(newTime));
-				mergedValTuple.add(String.valueOf(newVal));
-			}
-		}
-		 //set curr tuples to merged tuples
-		currTimeTup.clear();
-		currTimeTup.addAll(mergedTimeTuple);
-		currValTup.clear();
-		currValTup.addAll(mergedValTuple);
-		//TODO: see if we can do merger in place on curr
-	}
+    double newVal;
+    double newTime;
+    while (newTimeIter.hasNext()) {
+      newVal = Double.parseDouble(newValIter.next());
+      newTime = Double.parseDouble(newTimeIter.next());
+      if (newTime <= currTime) { // oldest new time older than newest curr time. we will not apply
+                                 // new tuple!
+        return; // curr tuples remain the same
+      }
+      currCtr++;
+      if (currCtr > (newTimeTup.size() + currTimeTup.size() - _windowSize)) { // non-evicted element
+        mergedTimeTuple.add(String.valueOf(newTime));
+        mergedValTuple.add(String.valueOf(newVal));
+      }
+    }
+    // set curr tuples to merged tuples
+    currTimeTup.clear();
+    currTimeTup.addAll(mergedTimeTuple);
+    currValTup.clear();
+    currValTup.addAll(mergedValTuple);
+    // TODO: see if we can do merger in place on curr
+  }
 
-	
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f414aad4/helix-core/src/main/java/org/apache/helix/controller/ExternalViewGenerator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/ExternalViewGenerator.java b/helix-core/src/main/java/org/apache/helix/controller/ExternalViewGenerator.java
index c155384..3d811bc 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/ExternalViewGenerator.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/ExternalViewGenerator.java
@@ -32,7 +32,6 @@ import org.apache.helix.model.Message;
 import org.apache.helix.model.CurrentState.CurrentStateProperty;
 import org.apache.log4j.Logger;
 
-
 /*
  * ZKRoutingInfoProvider keeps a copy of the routing table. Given a partition id,
  * it will return
@@ -46,44 +45,33 @@ import org.apache.log4j.Logger;
  * TODO: move the code as part of router process
  * TODO: add listeners to node current state changes
  * */
-public class ExternalViewGenerator
-{
+public class ExternalViewGenerator {
   static Logger _logger = Logger.getLogger(ExternalViewGenerator.class);
 
   /*
    * Given a list of external view ZNRecord nodes(one for each cluster),
    * calculate the routing map.
-   *
    * The format of the routing map is like this:
-   *
    * Map<String, Map<String, Set<String>>> maps from a partitionName to its
    * states Map<String, List<String>> The second Map maps from a state
    * ("MASTER", "SLAVE"...) to a list of nodeNames
-   *
    * So that the we can query the map for the list of nodes by providing the
    * partition name and the expected state.
    */
   public Map<String, Map<String, Set<String>>> getRouterMapFromExternalView(
-      List<ZNRecord> externalViewList)
-  {
+      List<ZNRecord> externalViewList) {
     Map<String, Map<String, Set<String>>> result = new TreeMap<String, Map<String, Set<String>>>();
 
-    for (ZNRecord nodeView : externalViewList)
-    {
-      Map<String, Map<String, String>> partitionNodeStateMap = nodeView
-          .getMapFields();
-      for (String partitionId : partitionNodeStateMap.keySet())
-      {
-        if (!result.containsKey(partitionId))
-        {
+    for (ZNRecord nodeView : externalViewList) {
+      Map<String, Map<String, String>> partitionNodeStateMap = nodeView.getMapFields();
+      for (String partitionId : partitionNodeStateMap.keySet()) {
+        if (!result.containsKey(partitionId)) {
           result.put(partitionId, new TreeMap<String, Set<String>>());
         }
         Map<String, String> nodeStateMap = partitionNodeStateMap.get(partitionId);
-        for (String nodeName : nodeStateMap.keySet())
-        {
+        for (String nodeName : nodeStateMap.keySet()) {
           String state = nodeStateMap.get(nodeName);
-          if (!result.get(partitionId).containsKey(state))
-          {
+          if (!result.get(partitionId).containsKey(state)) {
             result.get(partitionId).put(state, new TreeSet<String>());
           }
           result.get(partitionId).get(state).add(nodeName);
@@ -96,9 +84,8 @@ public class ExternalViewGenerator
   /*
    * The parameter is a map that maps the nodeName to a list of ZNRecords.
    */
-  public List<ZNRecord> computeExternalView(
-      Map<String, List<ZNRecord>> currentStates, List<ZNRecord> idealStates)
-  {
+  public List<ZNRecord> computeExternalView(Map<String, List<ZNRecord>> currentStates,
+      List<ZNRecord> idealStates) {
     List<ZNRecord> resultList = new ArrayList<ZNRecord>();
     Map<String, ZNRecord> resultRoutingTable = new HashMap<String, ZNRecord>();
     // maps from resourceName to another map : partition -> map <nodename,
@@ -106,51 +93,39 @@ public class ExternalViewGenerator
     // Fill the routing table with "empty" default state according to ideals
     // states
     // in the cluster
-    if (idealStates != null)
-    {
-      for (ZNRecord idealState : idealStates)
-      {
+    if (idealStates != null) {
+      for (ZNRecord idealState : idealStates) {
         ZNRecord defaultExternalView = new ZNRecord(idealState.getId());
         resultRoutingTable.put(idealState.getId(), defaultExternalView);
       }
-    } else
-    {
+    } else {
       assert (!currentStates.isEmpty());
       return resultList;
     }
-    for (String nodeName : currentStates.keySet())
-    {
+    for (String nodeName : currentStates.keySet()) {
       List<ZNRecord> znStates = currentStates.get(nodeName);
-      for (ZNRecord nodeStateRecord : znStates)
-      {
-        Map<String, Map<String, String>> resourceStates = nodeStateRecord
-            .getMapFields();
-        for (String stateUnitKey : resourceStates.keySet())
-        {
+      for (ZNRecord nodeStateRecord : znStates) {
+        Map<String, Map<String, String>> resourceStates = nodeStateRecord.getMapFields();
+        for (String stateUnitKey : resourceStates.keySet()) {
           Map<String, String> partitionStates = resourceStates.get(stateUnitKey);
-          String resourceName = partitionStates
-              .get(Message.Attributes.RESOURCE_NAME.toString());
+          String resourceName = partitionStates.get(Message.Attributes.RESOURCE_NAME.toString());
           ZNRecord partitionStatus = resultRoutingTable.get(resourceName);
-          if (partitionStatus == null)
-          {
+          if (partitionStatus == null) {
             partitionStatus = new ZNRecord(resourceName);
             resultRoutingTable.put(resourceName, partitionStatus);
           }
           String currentStateKey = CurrentStateProperty.CURRENT_STATE.toString();
 
-          if (!partitionStatus.getMapFields().containsKey(stateUnitKey))
-          {
-            partitionStatus.setMapField(stateUnitKey,
-                new TreeMap<String, String>());
+          if (!partitionStatus.getMapFields().containsKey(stateUnitKey)) {
+            partitionStatus.setMapField(stateUnitKey, new TreeMap<String, String>());
           }
           partitionStatus.getMapField(stateUnitKey).put(nodeName,
-                  partitionStates.get(currentStateKey));
+              partitionStates.get(currentStateKey));
 
         }
       }
     }
-    for (ZNRecord record : resultRoutingTable.values())
-    {
+    for (ZNRecord record : resultRoutingTable.values()) {
       resultList.add(record);
     }
     return resultList;


Mime
View raw message