You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metron.apache.org by ni...@apache.org on 2016/11/16 21:54:35 UTC

incubator-metron git commit: METRON-556 Profiler - Refactor 'Group By' Calculation (nickwallen) closes apache/incubator-metron#348

Repository: incubator-metron
Updated Branches:
  refs/heads/master daa9a5ea7 -> d03a363f8


METRON-556 Profiler - Refactor 'Group By' Calculation (nickwallen) closes apache/incubator-metron#348


Project: http://git-wip-us.apache.org/repos/asf/incubator-metron/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-metron/commit/d03a363f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-metron/tree/d03a363f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-metron/diff/d03a363f

Branch: refs/heads/master
Commit: d03a363f8b9aaca962bf4b3052e37909889563be
Parents: daa9a5e
Author: nickwallen <ni...@nickallen.org>
Authored: Wed Nov 16 16:53:58 2016 -0500
Committer: Nick Allen <ni...@nickallen.org>
Committed: Wed Nov 16 16:53:58 2016 -0500

----------------------------------------------------------------------
 .../metron/profiler/client/ProfileWriter.java   |   8 +-
 .../metron/profiler/ProfileMeasurement.java     |  27 +--
 .../metron/profiler/hbase/RowKeyBuilder.java    |   3 +-
 .../profiler/hbase/SaltyRowKeyBuilder.java      |   5 +-
 .../profiler/hbase/SaltyRowKeyBuilderTest.java  |  24 +--
 .../src/main/flux/profiler/remote.yaml          |   2 -
 .../profiler/bolt/ProfileBuilderBolt.java       |  71 ++++++--
 .../profiler/bolt/ProfileHBaseMapper.java       |  44 +----
 .../profiler/bolt/ProfileBuilderBoltTest.java   | 176 ++++++++++++-------
 .../profiler/bolt/ProfileHBaseMapperTest.java   |  50 ------
 10 files changed, 206 insertions(+), 204 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/d03a363f/metron-analytics/metron-profiler-client/src/test/java/org/apache/metron/profiler/client/ProfileWriter.java
----------------------------------------------------------------------
diff --git a/metron-analytics/metron-profiler-client/src/test/java/org/apache/metron/profiler/client/ProfileWriter.java b/metron-analytics/metron-profiler-client/src/test/java/org/apache/metron/profiler/client/ProfileWriter.java
index 503e118..a4ea8af 100644
--- a/metron-analytics/metron-profiler-client/src/test/java/org/apache/metron/profiler/client/ProfileWriter.java
+++ b/metron-analytics/metron-profiler-client/src/test/java/org/apache/metron/profiler/client/ProfileWriter.java
@@ -82,20 +82,20 @@ public class ProfileWriter {
       // generate the next value that should be written
       Object nextValue = valueGenerator.apply(m.getValue());
       m.setValue(nextValue);
+      m.setGroups(group);
 
       // write the measurement
-      write(m, group);
+      write(m);
     }
   }
 
   /**
    * Write a ProfileMeasurement.
    * @param m The ProfileMeasurement to write.
-   * @param groups The groups to use when writing the ProfileMeasurement.
    */
-  private void write(ProfileMeasurement m, List<Object> groups) {
+  private void write(ProfileMeasurement m) {
 
-    byte[] rowKey = rowKeyBuilder.rowKey(m, groups);
+    byte[] rowKey = rowKeyBuilder.rowKey(m);
     ColumnList cols = columnBuilder.columns(m);
 
     hbaseClient.addMutation(rowKey, cols, Durability.SKIP_WAL);

http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/d03a363f/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/ProfileMeasurement.java
----------------------------------------------------------------------
diff --git a/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/ProfileMeasurement.java b/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/ProfileMeasurement.java
index 210b92f..b20dccf 100644
--- a/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/ProfileMeasurement.java
+++ b/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/ProfileMeasurement.java
@@ -20,6 +20,7 @@
 
 package org.apache.metron.profiler;
 
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
@@ -47,9 +48,10 @@ public class ProfileMeasurement {
   private Object value;
 
   /**
-   * A set of expressions used to group the profile measurements when persisted.
+   * The 'groups' used to sort the Profile data. The groups are the result of
+   * executing the Profile's 'groupBy' expression.
    */
-  private List<String> groupBy;
+  private List<Object> groups;
 
   /**
    * The period in which the ProfileMeasurement was taken.
@@ -67,6 +69,7 @@ public class ProfileMeasurement {
     this.profileName = profileName;
     this.entity = entity;
     this.period = new ProfilePeriod(whenMillis, periodDuration, periodUnits);
+    this.groups = Collections.emptyList();
   }
 
   public String getProfileName() {
@@ -85,16 +88,16 @@ public class ProfileMeasurement {
     return period;
   }
 
-  public List<String> getGroupBy() {
-    return groupBy;
-  }
-
   public void setValue(Object value) {
     this.value = value;
   }
 
-  public void setGroupBy(List<String> groupBy) {
-    this.groupBy = groupBy;
+  public List<Object> getGroups() {
+    return groups;
+  }
+
+  public void setGroups(List<Object> groups) {
+    this.groups = groups;
   }
 
   @Override
@@ -103,12 +106,12 @@ public class ProfileMeasurement {
     if (o == null || getClass() != o.getClass()) return false;
 
     ProfileMeasurement that = (ProfileMeasurement) o;
+
     if (profileName != null ? !profileName.equals(that.profileName) : that.profileName != null) return false;
     if (entity != null ? !entity.equals(that.entity) : that.entity != null) return false;
     if (value != null ? !value.equals(that.value) : that.value != null) return false;
-    if (groupBy != null ? !groupBy.equals(that.groupBy) : that.groupBy != null) return false;
+    if (groups != null ? !groups.equals(that.groups) : that.groups != null) return false;
     return period != null ? period.equals(that.period) : that.period == null;
-
   }
 
   @Override
@@ -116,7 +119,7 @@ public class ProfileMeasurement {
     int result = profileName != null ? profileName.hashCode() : 0;
     result = 31 * result + (entity != null ? entity.hashCode() : 0);
     result = 31 * result + (value != null ? value.hashCode() : 0);
-    result = 31 * result + (groupBy != null ? groupBy.hashCode() : 0);
+    result = 31 * result + (groups != null ? groups.hashCode() : 0);
     result = 31 * result + (period != null ? period.hashCode() : 0);
     return result;
   }
@@ -127,7 +130,7 @@ public class ProfileMeasurement {
             "profileName='" + profileName + '\'' +
             ", entity='" + entity + '\'' +
             ", value=" + value +
-            ", groupBy=" + groupBy +
+            ", groups=" + groups +
             ", period=" + period +
             '}';
   }

http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/d03a363f/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/RowKeyBuilder.java
----------------------------------------------------------------------
diff --git a/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/RowKeyBuilder.java b/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/RowKeyBuilder.java
index 1ce4906..b53a1ac 100644
--- a/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/RowKeyBuilder.java
+++ b/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/RowKeyBuilder.java
@@ -38,10 +38,9 @@ public interface RowKeyBuilder extends Serializable {
    * This method is useful when writing ProfileMeasurements to HBase.
    *
    * @param measurement The profile measurement.
-   * @param groups      The groups used to sort the profile data.
    * @return The HBase row key.
    */
-  byte[] rowKey(ProfileMeasurement measurement, List<Object> groups);
+  byte[] rowKey(ProfileMeasurement measurement);
 
   /**
    * Builds a list of row keys necessary to retrieve a profile's measurements over

http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/d03a363f/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/SaltyRowKeyBuilder.java
----------------------------------------------------------------------
diff --git a/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/SaltyRowKeyBuilder.java b/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/SaltyRowKeyBuilder.java
index fe683ae..4e2b44f 100644
--- a/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/SaltyRowKeyBuilder.java
+++ b/metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/hbase/SaltyRowKeyBuilder.java
@@ -104,12 +104,11 @@ public class SaltyRowKeyBuilder implements RowKeyBuilder {
   /**
    * Builds the row key for a given profile measurement.
    * @param m The profile measurement.
-   * @param groups The groups used to sort the profile data.
    * @return The HBase row key.
    */
   @Override
-  public byte[] rowKey(ProfileMeasurement m, List<Object> groups) {
-    return rowKey(m.getProfileName(), m.getEntity(), m.getPeriod(), groups);
+  public byte[] rowKey(ProfileMeasurement m) {
+    return rowKey(m.getProfileName(), m.getEntity(), m.getPeriod(), m.getGroups());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/d03a363f/metron-analytics/metron-profiler-common/src/test/java/org/apache/metron/profiler/hbase/SaltyRowKeyBuilderTest.java
----------------------------------------------------------------------
diff --git a/metron-analytics/metron-profiler-common/src/test/java/org/apache/metron/profiler/hbase/SaltyRowKeyBuilderTest.java b/metron-analytics/metron-profiler-common/src/test/java/org/apache/metron/profiler/hbase/SaltyRowKeyBuilderTest.java
index ccbb09c..c83f998 100644
--- a/metron-analytics/metron-profiler-common/src/test/java/org/apache/metron/profiler/hbase/SaltyRowKeyBuilderTest.java
+++ b/metron-analytics/metron-profiler-common/src/test/java/org/apache/metron/profiler/hbase/SaltyRowKeyBuilderTest.java
@@ -70,6 +70,8 @@ public class SaltyRowKeyBuilderTest {
     // the tuple will contain the original message
     tuple = mock(Tuple.class);
     when(tuple.getValueByField(eq("measurement"))).thenReturn(measurement);
+
+    rowKeyBuilder = new SaltyRowKeyBuilder(saltDivisor, periodDuration, periodUnits);
   }
 
   /**
@@ -78,8 +80,8 @@ public class SaltyRowKeyBuilderTest {
   @Test
   public void testRowKeyWithOneGroup() throws Exception {
     // setup
-    rowKeyBuilder = new SaltyRowKeyBuilder(saltDivisor, periodDuration, periodUnits);
     List<Object> groups = Arrays.asList("group1");
+    measurement.setGroups(groups);
 
     // the expected row key
     ByteBuffer buffer = ByteBuffer
@@ -95,7 +97,7 @@ public class SaltyRowKeyBuilderTest {
     buffer.get(expected, 0, buffer.limit());
 
     // validate
-    byte[] actual = rowKeyBuilder.rowKey(measurement, groups);
+    byte[] actual = rowKeyBuilder.rowKey(measurement);
     Assert.assertTrue(Arrays.equals(expected, actual));
   }
 
@@ -105,8 +107,8 @@ public class SaltyRowKeyBuilderTest {
   @Test
   public void testRowKeyWithTwoGroups() throws Exception {
     // setup
-    rowKeyBuilder = new SaltyRowKeyBuilder(saltDivisor, periodDuration, periodUnits);
     List<Object> groups = Arrays.asList("group1","group2");
+    measurement.setGroups(groups);
 
     // the expected row key
     ByteBuffer buffer = ByteBuffer
@@ -123,7 +125,7 @@ public class SaltyRowKeyBuilderTest {
     buffer.get(expected, 0, buffer.limit());
 
     // validate
-    byte[] actual = rowKeyBuilder.rowKey(measurement, groups);
+    byte[] actual = rowKeyBuilder.rowKey(measurement);
     Assert.assertTrue(Arrays.equals(expected, actual));
   }
 
@@ -133,8 +135,8 @@ public class SaltyRowKeyBuilderTest {
   @Test
   public void testRowKeyWithOneIntegerGroup() throws Exception {
     // setup
-    rowKeyBuilder = new SaltyRowKeyBuilder(saltDivisor, periodDuration, periodUnits);
     List<Object> groups = Arrays.asList(200);
+    measurement.setGroups(groups);
 
     // the expected row key
     ByteBuffer buffer = ByteBuffer
@@ -150,7 +152,7 @@ public class SaltyRowKeyBuilderTest {
     buffer.get(expected, 0, buffer.limit());
 
     // validate
-    byte[] actual = rowKeyBuilder.rowKey(measurement, groups);
+    byte[] actual = rowKeyBuilder.rowKey(measurement);
     Assert.assertTrue(Arrays.equals(expected, actual));
   }
 
@@ -160,8 +162,8 @@ public class SaltyRowKeyBuilderTest {
   @Test
   public void testRowKeyWithMixedGroups() throws Exception {
     // setup
-    rowKeyBuilder = new SaltyRowKeyBuilder(saltDivisor, periodDuration, periodUnits);
     List<Object> groups = Arrays.asList(200, "group1");
+    measurement.setGroups(groups);
 
     // the expected row key
     ByteBuffer buffer = ByteBuffer
@@ -178,7 +180,7 @@ public class SaltyRowKeyBuilderTest {
     buffer.get(expected, 0, buffer.limit());
 
     // validate
-    byte[] actual = rowKeyBuilder.rowKey(measurement, groups);
+    byte[] actual = rowKeyBuilder.rowKey(measurement);
     Assert.assertTrue(Arrays.equals(expected, actual));
   }
 
@@ -188,8 +190,8 @@ public class SaltyRowKeyBuilderTest {
   @Test
   public void testRowKeyWithNoGroup() throws Exception {
     // setup
-    rowKeyBuilder = new SaltyRowKeyBuilder(saltDivisor, periodDuration, periodUnits);
     List<Object> groups = Collections.emptyList();
+    measurement.setGroups(groups);
 
     // the expected row key
     ByteBuffer buffer = ByteBuffer
@@ -204,7 +206,7 @@ public class SaltyRowKeyBuilderTest {
     buffer.get(expected, 0, buffer.limit());
 
     // validate
-    byte[] actual = rowKeyBuilder.rowKey(measurement, groups);
+    byte[] actual = rowKeyBuilder.rowKey(measurement);
     Assert.assertTrue(Arrays.equals(expected, actual));
   }
 
@@ -230,7 +232,7 @@ public class SaltyRowKeyBuilderTest {
     for  (int i=0; i<(hoursAgo * 4)+1; i++) {
 
       // generate the expected key
-      byte[] rk = rowKeyBuilder.rowKey(m, groups);
+      byte[] rk = rowKeyBuilder.rowKey(m);
       expectedKeys.add(rk);
 
       // advance to the next period

http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/d03a363f/metron-analytics/metron-profiler/src/main/flux/profiler/remote.yaml
----------------------------------------------------------------------
diff --git a/metron-analytics/metron-profiler/src/main/flux/profiler/remote.yaml b/metron-analytics/metron-profiler/src/main/flux/profiler/remote.yaml
index b1de565..c818a70 100644
--- a/metron-analytics/metron-profiler/src/main/flux/profiler/remote.yaml
+++ b/metron-analytics/metron-profiler/src/main/flux/profiler/remote.yaml
@@ -46,8 +46,6 @@ components:
               ref: "rowKeyBuilder"
             - name: "columnBuilder"
               ref: "columnBuilder"
-            - name: "executor"
-              ref: "defaultExecutor"
 
     -   id: "zkHosts"
         className: "org.apache.storm.kafka.ZkHosts"

http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/d03a363f/metron-analytics/metron-profiler/src/main/java/org/apache/metron/profiler/bolt/ProfileBuilderBolt.java
----------------------------------------------------------------------
diff --git a/metron-analytics/metron-profiler/src/main/java/org/apache/metron/profiler/bolt/ProfileBuilderBolt.java b/metron-analytics/metron-profiler/src/main/java/org/apache/metron/profiler/bolt/ProfileBuilderBolt.java
index fa732e2..962b4f9 100644
--- a/metron-analytics/metron-profiler/src/main/java/org/apache/metron/profiler/bolt/ProfileBuilderBolt.java
+++ b/metron-analytics/metron-profiler/src/main/java/org/apache/metron/profiler/bolt/ProfileBuilderBolt.java
@@ -20,6 +20,7 @@
 
 package org.apache.metron.profiler.bolt;
 
+import org.apache.commons.beanutils.BeanMap;
 import org.apache.storm.Config;
 import org.apache.storm.Constants;
 import org.apache.storm.task.OutputCollector;
@@ -40,10 +41,13 @@ import org.json.simple.parser.JSONParser;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 import static java.lang.String.format;
+import static org.apache.commons.collections.CollectionUtils.isEmpty;
 
 /**
  * A bolt that is responsible for building a Profile.
@@ -229,18 +233,15 @@ public class ProfileBuilderBolt extends ConfiguredProfilerBolt {
     LOG.info(String.format("Flushing profile: profile=%s, entity=%s",
             measurement.getProfileName(), measurement.getEntity()));
 
-    // execute the 'result' expression
-    Object result;
-    try {
-      String resultExpr = profileConfig.getResult();
-      result = executor.execute(resultExpr, new JSONObject(), Object.class);
+    // calculate the result
+    Object result = executeResult(profileConfig.getResult());
+    measurement.setValue(result);
 
-    } catch(ParseException e) {
-      throw new ParseException("Bad 'result' expression", e);
-    }
+    // calculate the groups
+    List<Object> groups = executeGroupBy(profileConfig.getGroupBy());
+    measurement.setGroups(groups);
 
     // emit the completed profile measurement
-    measurement.setValue(result);
     emit(measurement, tickTuple);
 
     // clear the execution state to prepare for the next window
@@ -251,12 +252,60 @@ public class ProfileBuilderBolt extends ConfiguredProfilerBolt {
   }
 
   /**
-   * Emits a message containing a ProfileMeasurement.
+   * Executes the 'result' expression of a Profile.
+   * @return The result of evaluating the 'result' expression.
+   */
+  private Object executeResult(String expression) {
+    Object result;
+    try {
+      result = executor.execute(expression, new JSONObject(), Object.class);
+
+    } catch(ParseException e) {
+      String msg = format("Bad 'result' expression: %s, profile=%s, entity=%s",
+              e.getMessage(), measurement.getProfileName(), measurement.getEntity());
+      throw new ParseException(msg, e);
+    }
+    return result;
+  }
+
+
+  /**
+   * Executes each of the 'groupBy' expressions.  The result of each
+   * expression are the groups used to sort the data as part of the
+   * row key.
+   * @param expressions The 'groupBy' expressions to execute.
+   * @return The result of executing the 'groupBy' expressions.
+   */
+  private List<Object> executeGroupBy(List<String> expressions) {
+    List<Object> groups = new ArrayList<>();
+
+    if(!isEmpty(expressions)) {
+      try {
+        // allows each 'groupBy' expression to refer to the fields of the ProfileMeasurement
+        BeanMap measureAsMap = new BeanMap(measurement);
+
+        for (String expr : expressions) {
+          Object result = executor.execute(expr, measureAsMap, Object.class);
+          groups.add(result);
+        }
+
+      } catch(Throwable e) {
+        String msg = format("Bad 'groupBy' expression: %s, profile=%s, entity=%s",
+                e.getMessage(), measurement.getProfileName(), measurement.getEntity());
+        throw new ParseException(msg, e);
+      }
+    }
+
+    return groups;
+  }
+
+  /**
+   * Emits a message containing a ProfileMeasurement and the Profile configuration.
    * @param measurement The completed ProfileMeasurement.
+   * @param anchor The original tuple to be used as the anchor.
    */
   private void emit(ProfileMeasurement measurement, Tuple anchor) {
     collector.emit(anchor, new Values(measurement, profileConfig));
-    collector.ack(anchor);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/d03a363f/metron-analytics/metron-profiler/src/main/java/org/apache/metron/profiler/bolt/ProfileHBaseMapper.java
----------------------------------------------------------------------
diff --git a/metron-analytics/metron-profiler/src/main/java/org/apache/metron/profiler/bolt/ProfileHBaseMapper.java b/metron-analytics/metron-profiler/src/main/java/org/apache/metron/profiler/bolt/ProfileHBaseMapper.java
index 28d0530..fdea3e9 100644
--- a/metron-analytics/metron-profiler/src/main/java/org/apache/metron/profiler/bolt/ProfileHBaseMapper.java
+++ b/metron-analytics/metron-profiler/src/main/java/org/apache/metron/profiler/bolt/ProfileHBaseMapper.java
@@ -46,11 +46,6 @@ import static org.apache.commons.collections.CollectionUtils.isEmpty;
 public class ProfileHBaseMapper implements HBaseMapper {
 
   /**
-   * Executes Stellar code and maintains state across multiple invocations.
-   */
-  private StellarExecutor executor;
-
-  /**
    * Generates the row keys necessary to store profile data in HBase.
    */
   private RowKeyBuilder rowKeyBuilder;
@@ -78,9 +73,8 @@ public class ProfileHBaseMapper implements HBaseMapper {
    */
   @Override
   public byte[] rowKey(Tuple tuple) {
-    ProfileMeasurement m = (ProfileMeasurement) tuple.getValueByField("measurement");
-    List<Object> groups = executeGroupBy(m);
-    return rowKeyBuilder.rowKey(m, groups);
+    ProfileMeasurement measurement = (ProfileMeasurement) tuple.getValueByField("measurement");
+    return rowKeyBuilder.rowKey(measurement);
   }
 
   /**
@@ -115,40 +109,6 @@ public class ProfileHBaseMapper implements HBaseMapper {
     return result;
   }
 
-  /**
-   * Executes each of the 'groupBy' expressions.  The result of each
-   * expression are the groups used to sort the data as part of the
-   * row key.
-   * @param m The profile measurement.
-   * @return The result of executing the 'groupBy' expressions.
-   */
-  private List<Object> executeGroupBy(ProfileMeasurement m) {
-    List<Object> groups = new ArrayList<>();
-
-    if(!isEmpty(m.getGroupBy())) {
-      try {
-        // allows each 'groupBy' expression to refer to the fields of the ProfileMeasurement
-        BeanMap measureAsMap = new BeanMap(m);
-
-        for (String expr : m.getGroupBy()) {
-          Object result = executor.execute(expr, measureAsMap, Object.class);
-          groups.add(result);
-        }
-
-      } catch(Throwable e) {
-        String msg = format("Bad 'groupBy' expression: %s, profile=%s, entity=%s",
-                e.getMessage(), m.getProfileName(), m.getEntity());
-        throw new ParseException(msg, e);
-      }
-    }
-
-    return groups;
-  }
-
-  public void setExecutor(StellarExecutor executor) {
-    this.executor = executor;
-  }
-
   public void setRowKeyBuilder(RowKeyBuilder rowKeyBuilder) {
     this.rowKeyBuilder = rowKeyBuilder;
   }

http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/d03a363f/metron-analytics/metron-profiler/src/test/java/org/apache/metron/profiler/bolt/ProfileBuilderBoltTest.java
----------------------------------------------------------------------
diff --git a/metron-analytics/metron-profiler/src/test/java/org/apache/metron/profiler/bolt/ProfileBuilderBoltTest.java b/metron-analytics/metron-profiler/src/test/java/org/apache/metron/profiler/bolt/ProfileBuilderBoltTest.java
index 8faab90..42a5cdf 100644
--- a/metron-analytics/metron-profiler/src/test/java/org/apache/metron/profiler/bolt/ProfileBuilderBoltTest.java
+++ b/metron-analytics/metron-profiler/src/test/java/org/apache/metron/profiler/bolt/ProfileBuilderBoltTest.java
@@ -60,73 +60,6 @@ public class ProfileBuilderBoltTest extends BaseBoltTest {
   @Multiline
   private String input;
 
-  /**
-   * {
-   *   "profile": "test",
-   *   "foreach": "ip_src_addr",
-   *   "onlyif": "true",
-   *   "init": {
-   *     "x": "10",
-   *     "y": "20"
-   *   },
-   *   "update": {
-   *     "x": "x + 10",
-   *     "y": "y + 20"
-   *   },
-   *   "result": "x + y"
-   * }
-   */
-  @Multiline
-  private String basicProfile;
-
-  /**
-   * {
-   *   "profile": "test",
-   *   "foreach": "ip_src_addr",
-   *   "onlyif": "true",
-   *   "init":   { "x": 10 },
-   *   "update": { "x": "x + 'string'" },
-   *   "result": "x"
-   * }
-   */
-  @Multiline
-  private String profileWithBadUpdate;
-
-  /**
-   * {
-   *   "profile": "test",
-   *   "foreach": "ip_src_addr",
-   *   "onlyif": "true",
-   *   "init":   { "x": "10 + 'string'" },
-   *   "update": { "x": "x + 2" },
-   *   "result": "x"
-   * }
-   */
-  @Multiline
-  private String profileWithBadInit;
-
-  /**
-   * {
-   *   "profile": "test",
-   *   "foreach": "ip_src_addr",
-   *   "update": { "x": "2" },
-   *   "result": "x"
-   * }
-   */
-  @Multiline
-  private String profileWithNoInit;
-
-  /**
-   * {
-   *   "profile": "test",
-   *   "foreach": "ip_src_addr",
-   *   "init": { "x": "2" },
-   *   "result": "x"
-   * }
-   */
-  @Multiline
-  private String profileWithNoUpdate;
-
   private JSONObject message;
 
   public static Tuple mockTickTuple() {
@@ -173,6 +106,25 @@ public class ProfileBuilderBoltTest extends BaseBoltTest {
   }
 
   /**
+   * {
+   *   "profile": "test",
+   *   "foreach": "ip_src_addr",
+   *   "onlyif": "true",
+   *   "init": {
+   *     "x": "10",
+   *     "y": "20"
+   *   },
+   *   "update": {
+   *     "x": "x + 10",
+   *     "y": "y + 20"
+   *   },
+   *   "result": "x + y"
+   * }
+   */
+  @Multiline
+  private String basicProfile;
+
+  /**
    * Ensure that the bolt can update a profile based on new messages that it receives.
    */
   @Test
@@ -189,6 +141,17 @@ public class ProfileBuilderBoltTest extends BaseBoltTest {
   }
 
   /**
+   * {
+   *   "profile": "test",
+   *   "foreach": "ip_src_addr",
+   *   "update": { "x": "2" },
+   *   "result": "x"
+   * }
+   */
+  @Multiline
+  private String profileWithNoInit;
+
+  /**
    * If the 'init' field is not defined, then the profile should
    * behave as normal, but with no variable initialization.
    */
@@ -205,6 +168,17 @@ public class ProfileBuilderBoltTest extends BaseBoltTest {
   }
 
   /**
+   * {
+   *   "profile": "test",
+   *   "foreach": "ip_src_addr",
+   *   "init": { "x": "2" },
+   *   "result": "x"
+   * }
+   */
+  @Multiline
+  private String profileWithNoUpdate;
+
+  /**
    * If the 'update' field is not defined, then no updates should occur as messages
    * are received.
    */
@@ -291,6 +265,19 @@ public class ProfileBuilderBoltTest extends BaseBoltTest {
   }
 
   /**
+   * {
+   *   "profile": "test",
+   *   "foreach": "ip_src_addr",
+   *   "onlyif": "true",
+   *   "init":   { "x": 10 },
+   *   "update": { "x": "x + 'string'" },
+   *   "result": "x"
+   * }
+   */
+  @Multiline
+  private String profileWithBadUpdate;
+
+  /**
    * What happens when the profile contains a bad Stellar expression?
    */
   @Test
@@ -310,6 +297,19 @@ public class ProfileBuilderBoltTest extends BaseBoltTest {
   }
 
   /**
+   * {
+   *   "profile": "test",
+   *   "foreach": "ip_src_addr",
+   *   "onlyif": "true",
+   *   "init":   { "x": "10 + 'string'" },
+   *   "update": { "x": "x + 2" },
+   *   "result": "x"
+   * }
+   */
+  @Multiline
+  private String profileWithBadInit;
+
+  /**
    * What happens when the profile contains a bad Stellar expression?
    */
   @Test
@@ -327,4 +327,46 @@ public class ProfileBuilderBoltTest extends BaseBoltTest {
     verify(outputCollector, times(1)).ack(eq(tuple));
     verify(outputCollector, times(1)).reportError(any());
   }
+
+  /**
+   * {
+   *   "profile": "test",
+   *   "foreach": "ip_src_addr",
+   *   "onlyif": "true",
+   *   "groupBy": ["2 + 2", "4 + 4"],
+   *   "init":   { "x": "0" },
+   *   "update": { "x": "x + 1" },
+   *   "result": "x"
+   * }
+   */
+  @Multiline
+  private String profileWithGroupBy;
+
+  /**
+   * Ensure that the Profile's 'groupBy' are handled correctly.
+   */
+  @Test
+  public void testProfileWithGroupBy() throws Exception {
+
+    // setup
+    setup(profileWithGroupBy);
+    ProfileBuilderBolt bolt = createBolt();
+    bolt.execute(tuple);
+    bolt.execute(tuple);
+
+    // execute - the tick tuple triggers a flush of the profile
+    bolt.execute(mockTickTuple());
+
+    // capture the ProfileMeasurement that should be emitted
+    ArgumentCaptor<Values> arg = ArgumentCaptor.forClass(Values.class);
+    verify(outputCollector, times(1)).emit(refEq(tuple), arg.capture());
+
+    Values actual = arg.getValue();
+    ProfileMeasurement measurement = (ProfileMeasurement) actual.get(0);
+
+    // verify the groups
+    assertThat(measurement.getGroups().size(), equalTo(2));
+    assertThat(measurement.getGroups().get(0), equalTo(4.0));
+    assertThat(measurement.getGroups().get(1), equalTo(8.0));
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/d03a363f/metron-analytics/metron-profiler/src/test/java/org/apache/metron/profiler/bolt/ProfileHBaseMapperTest.java
----------------------------------------------------------------------
diff --git a/metron-analytics/metron-profiler/src/test/java/org/apache/metron/profiler/bolt/ProfileHBaseMapperTest.java b/metron-analytics/metron-profiler/src/test/java/org/apache/metron/profiler/bolt/ProfileHBaseMapperTest.java
index f2fa2f6..f468bbf 100644
--- a/metron-analytics/metron-profiler/src/test/java/org/apache/metron/profiler/bolt/ProfileHBaseMapperTest.java
+++ b/metron-analytics/metron-profiler/src/test/java/org/apache/metron/profiler/bolt/ProfileHBaseMapperTest.java
@@ -49,18 +49,14 @@ public class ProfileHBaseMapperTest {
   private Tuple tuple;
   private ProfileHBaseMapper mapper;
   private ProfileMeasurement measurement;
-  private DefaultStellarExecutor executor;
   private RowKeyBuilder rowKeyBuilder;
   private ProfileConfig profile;
 
   @Before
   public void setup() {
-    executor = new DefaultStellarExecutor();
-
     rowKeyBuilder = mock(RowKeyBuilder.class);
 
     mapper = new ProfileHBaseMapper();
-    mapper.setExecutor(executor);
     mapper.setRowKeyBuilder(rowKeyBuilder);
 
     measurement = new ProfileMeasurement("profile", "entity", 20000, 15, TimeUnit.MINUTES);
@@ -68,7 +64,6 @@ public class ProfileHBaseMapperTest {
 
     profile = new ProfileConfig();
 
-
     // the tuple will contain the original message
     tuple = mock(Tuple.class);
     when(tuple.getValueByField(eq("measurement"))).thenReturn(measurement);
@@ -76,51 +71,6 @@ public class ProfileHBaseMapperTest {
   }
 
   /**
-   * The mapper should execute the 'groupBy' Stellar expressions and use that to generate
-   * a row key.
-   */
-  @Test
-  public void testExecuteGroupBy() throws Exception {
-
-    // setup - expression that refers to the ProfileMeasurement.end
-    measurement.setGroupBy(Arrays.asList("2 + 2"));
-
-    // execute
-    mapper.rowKey(tuple);
-
-    // capture the ProfileMeasurement that should be emitted
-    ArgumentCaptor<List> arg = ArgumentCaptor.forClass(List.class);
-    verify(rowKeyBuilder).rowKey(any(), arg.capture());
-
-    // validate
-    List<Object> actual = arg.getValue();
-    Assert.assertEquals(4.0, actual.get(0));
-  }
-
-  /**
-   * The mapper should execute each 'groupBy' Stellar expression and use that to generate
-   * a row key.  There can be multiple groups.
-   */
-  @Test
-  public void testExecuteMultipleGroupBys() throws Exception {
-
-    // setup - expression that refers to the ProfileMeasurement.end
-    measurement.setGroupBy(Arrays.asList("2 + 2", "4 + 4"));
-
-    // execute
-    mapper.rowKey(tuple);
-
-    // capture the ProfileMeasurement that should be emitted
-    ArgumentCaptor<List> arg = ArgumentCaptor.forClass(List.class);
-    verify(rowKeyBuilder).rowKey(any(), arg.capture());
-
-    // validate
-    List<Object> actual = arg.getValue();
-    Assert.assertEquals(4.0, actual.get(0));
-    Assert.assertEquals(8.0, actual.get(1));
-  }
-
-  /**
    * The mapper should return the expiration for a tuple based on the Profile definition.
    */
   @Test