hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khorg...@apache.org
Subject hive git commit: HIVE-12937 : DbNotificationListener unable to clean up old notification events (Sushanth Sowmyan, reviewed by Sergey Shelukhin)
Date Tue, 29 Mar 2016 18:26:15 GMT
Repository: hive
Updated Branches:
  refs/heads/branch-2.0 fdbed3e50 -> c341cbec7


HIVE-12937 : DbNotificationListener unable to clean up old notification events (Sushanth Sowmyan,
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/c341cbec
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/c341cbec
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/c341cbec

Branch: refs/heads/branch-2.0
Commit: c341cbec78ebadf3548ca929565a23f26e508c86
Parents: fdbed3e
Author: Sushanth Sowmyan <khorgath@gmail.com>
Authored: Tue Mar 29 11:21:23 2016 -0700
Committer: Sushanth Sowmyan <khorgath@gmail.com>
Committed: Tue Mar 29 11:26:05 2016 -0700

----------------------------------------------------------------------
 .../listener/TestDbNotificationListener.java      | 18 ++++++++++++++++++
 .../apache/hadoop/hive/metastore/ObjectStore.java |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/c341cbec/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
----------------------------------------------------------------------
diff --git a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
index 56f5c8b..d54ab66 100644
--- a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
+++ b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
@@ -57,6 +57,7 @@ import java.util.Map;
 public class TestDbNotificationListener {
 
   private static final Logger LOG = LoggerFactory.getLogger(TestDbNotificationListener.class.getName());
+  private static final int EVENTS_TTL = 30;
   private static Map<String, String> emptyParameters = new HashMap<String, String>();
   private static IMetaStoreClient msClient;
   private static Driver driver;
@@ -68,6 +69,7 @@ public class TestDbNotificationListener {
     HiveConf conf = new HiveConf();
     conf.setVar(HiveConf.ConfVars.METASTORE_EVENT_LISTENERS,
         DbNotificationListener.class.getName());
+    conf.setVar(HiveConf.ConfVars.METASTORE_EVENT_DB_LISTENER_TTL, String.valueOf(EVENTS_TTL)+"s");
     conf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
     conf.setBoolVar(HiveConf.ConfVars.FIRE_EVENTS_FOR_DML, true);
     conf.setVar(HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
@@ -565,4 +567,20 @@ public class TestDbNotificationListener {
     assertEquals(firstEventId + 25, event.getEventId());
     assertEquals(HCatConstants.HCAT_DROP_PARTITION_EVENT, event.getEventType());
   }
+
+  @Test
+  public void cleanupNotifs() throws Exception {
+    Database db = new Database("cleanup1","no description","file:/tmp", emptyParameters);
+    msClient.createDatabase(db);
+    msClient.dropDatabase("cleanup1");
+
+    NotificationEventResponse rsp = msClient.getNextNotification(firstEventId, 0, null);
+    assertEquals(2, rsp.getEventsSize());
+
+    // sleep for expiry time, and then fetch again
+    Thread.sleep(EVENTS_TTL * 2 * 1000); // sleep twice the TTL interval - things should
have been cleaned by then.
+
+    NotificationEventResponse rsp2 = msClient.getNextNotification(firstEventId, 0, null);
+    assertEquals(0, rsp2.getEventsSize());
+  }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/c341cbec/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
----------------------------------------------------------------------
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java b/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
index c100bb4..05685ff 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
@@ -7684,7 +7684,7 @@ public class ObjectStore implements RawStore, Configurable {
       query.declareParameters("java.lang.Integer tooOld");
       Collection<MNotificationLog> toBeRemoved = (Collection) query.execute(tooOld);
       if (toBeRemoved != null && toBeRemoved.size() > 0) {
-        pm.deletePersistent(toBeRemoved);
+        pm.deletePersistentAll(toBeRemoved);
       }
       commited = commitTransaction();
     } finally {


Mime
View raw message