Repository: hive
Updated Branches:
  refs/heads/master 408ea39b7 -> 6155f307c


HIVE-18637: WorkloadManagent Event Summary leaving subscribedCounters and 
currentCounters fields empty (Prasanth Jayachandran reviewed by Sergey 
Shelukhin)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/6155f307
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/6155f307
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/6155f307

Branch: refs/heads/master
Commit: 6155f307c8b1b5581c5f6a3af394e5b866a39bb7
Parents: 408ea39
Author: Prasanth Jayachandran <prasan...@apache.org>
Authored: Fri Feb 9 06:13:03 2018 -0800
Committer: Prasanth Jayachandran <prasan...@apache.org>
Committed: Fri Feb 9 06:13:03 2018 -0800

----------------------------------------------------------------------
 .../apache/hive/jdbc/TestTriggersMoveWorkloadManager.java |  9 +++++++--
 ql/src/java/org/apache/hadoop/hive/ql/wm/WmContext.java   | 10 ++++++++--
 ql/src/test/org/apache/hadoop/hive/ql/wm/TestTrigger.java |  7 +++++++
 3 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/6155f307/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestTriggersMoveWorkloadManager.java
----------------------------------------------------------------------
diff --git 
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestTriggersMoveWorkloadManager.java
 
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestTriggersMoveWorkloadManager.java
index 8aca2a6..ba5ff8e 100644
--- 
a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestTriggersMoveWorkloadManager.java
+++ 
b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestTriggersMoveWorkloadManager.java
@@ -82,8 +82,8 @@ public class TestTriggersMoveWorkloadManager extends 
AbstractJdbcTriggersTest {
 
   @Test(timeout = 60000)
   public void testTriggerMoveAndKill() throws Exception {
-    Expression moveExpression = ExpressionFactory.fromString("EXECUTION_TIME > 
1000");
-    Expression killExpression = ExpressionFactory.fromString("EXECUTION_TIME > 
5000");
+    Expression moveExpression = ExpressionFactory.fromString("EXECUTION_TIME > 
1sec");
+    Expression killExpression = ExpressionFactory.fromString("EXECUTION_TIME > 
5000ms");
     Trigger moveTrigger = new ExecutionTrigger("slow_query_move", 
moveExpression,
       new Action(Action.Type.MOVE_TO_POOL, "ETL"));
     Trigger killTrigger = new ExecutionTrigger("slow_query_kill", 
killExpression,
@@ -111,6 +111,7 @@ public class TestTriggersMoveWorkloadManager extends 
AbstractJdbcTriggersTest {
     errCaptureExpect.add("\"violationMsg\" : \"Trigger " + moveTrigger + " 
violated");
     // violation in ETL queue
     errCaptureExpect.add("\"violationMsg\" : \"Trigger " + killTrigger + " 
violated");
+    errCaptureExpect.add("\"subscribedCounters\" : [ \"EXECUTION_TIME\" ]");
     runQueryWithTrigger(query, setCmds, killTrigger + " violated", 
errCaptureExpect);
   }
 
@@ -141,6 +142,7 @@ public class TestTriggersMoveWorkloadManager extends 
AbstractJdbcTriggersTest {
     errCaptureExpect.add("\"name\" : \"slow_query_kill\"");
     // violation in BI queue
     errCaptureExpect.add("\"violationMsg\" : \"Trigger " + moveTrigger + " 
violated");
+    errCaptureExpect.add("\"subscribedCounters\" : [ \"HDFS_BYTES_READ\", 
\"EXECUTION_TIME\" ]");
     runQueryWithTrigger(query, setCmds, null, errCaptureExpect);
   }
 
@@ -183,6 +185,7 @@ public class TestTriggersMoveWorkloadManager extends 
AbstractJdbcTriggersTest {
     errCaptureExpect.add("\"violationMsg\" : \"Trigger " + moveTrigger2 + " 
violated");
     // violation in BI queue
     errCaptureExpect.add("\"violationMsg\" : \"Trigger " + killTrigger + " 
violated");
+    errCaptureExpect.add("\"subscribedCounters\" : [ \"HDFS_BYTES_READ\", 
\"EXECUTION_TIME\", \"SHUFFLE_BYTES\" ]");
     runQueryWithTrigger(query, setCmds, killTrigger + " violated", 
errCaptureExpect);
   }
 
@@ -219,6 +222,7 @@ public class TestTriggersMoveWorkloadManager extends 
AbstractJdbcTriggersTest {
 //    errCaptureExpect.add("\"violationMsg\" : \"Trigger " + moveTrigger1 + " 
violated");
 //    // violation in ETL queue
 //    errCaptureExpect.add("\"violationMsg\" : \"Trigger " + killTrigger + " 
violated");
+//    errCaptureExpect.add("\"subscribedCounters\" : [ \"HDFS_BYTES_READ\", 
\"HDFS_BYTES_WRITTEN\" ]");
 //    runQueryWithTrigger(query, setCmds, killTrigger + " violated", 
errCaptureExpect);
 //  }
 
@@ -249,6 +253,7 @@ public class TestTriggersMoveWorkloadManager extends 
AbstractJdbcTriggersTest {
     errCaptureExpect.add("\"name\" : \"kill_big_read\"");
     // violation in BI queue
     errCaptureExpect.add("\"violationMsg\" : \"Trigger " + killTrigger + " 
violated");
+    errCaptureExpect.add("\"subscribedCounters\" : [ \"HDFS_BYTES_READ\" ]");
     runQueryWithTrigger(query, setCmds, killTrigger + " violated", 
errCaptureExpect);
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/6155f307/ql/src/java/org/apache/hadoop/hive/ql/wm/WmContext.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/wm/WmContext.java 
b/ql/src/java/org/apache/hadoop/hive/ql/wm/WmContext.java
index 7a7ef50..d09bf89 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/wm/WmContext.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/wm/WmContext.java
@@ -85,8 +85,7 @@ public class WmContext implements PrintSummary {
       for (Trigger trigger : triggers) {
         counters.add(trigger.getExpression().getCounterLimit().getName());
       }
-      setSubscribedCounters(counters);
-      setCurrentCounters(new HashMap<>());
+      addSubscribedCounters(counters);
     }
   }
 
@@ -106,6 +105,13 @@ public class WmContext implements PrintSummary {
     this.subscribedCounters = subscribedCounters;
   }
 
+  public void addSubscribedCounters(final Set<String> moreCounters) {
+    if (subscribedCounters == null) {
+      subscribedCounters = new HashSet<>();
+    }
+    subscribedCounters.addAll(moreCounters);
+  }
+
   public Map<String, Long> getCurrentCounters() {
     return currentCounters;
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/6155f307/ql/src/test/org/apache/hadoop/hive/ql/wm/TestTrigger.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/wm/TestTrigger.java 
b/ql/src/test/org/apache/hadoop/hive/ql/wm/TestTrigger.java
index 55b4ced..3953d4c 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/wm/TestTrigger.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/wm/TestTrigger.java
@@ -276,6 +276,13 @@ public class TestTrigger {
     assertEquals(expected, expression);
     assertEquals(expected.hashCode(), expression.hashCode());
 
+    expression = ExpressionFactory.fromString(" elapsed_TIME > 300000ms");
+    expected = ExpressionFactory.createExpression(new 
TimeCounterLimit(TimeCounterLimit.TimeCounter
+      .ELAPSED_TIME, 300000));
+    assertEquals(expected, expression);
+    assertEquals(expected.hashCode(), expression.hashCode());
+
+
     expression = ExpressionFactory.fromString(" elapsed_TIME > 
300000000microseconds");
     expected = ExpressionFactory.createExpression(new 
TimeCounterLimit(TimeCounterLimit.TimeCounter
       .ELAPSED_TIME, 300000));

Reply via email to