diff --git a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java index b287d43..4313e12 100644 --- a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java +++ b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java @@ -148,6 +148,19 @@ public void onConfigChange(ConfigChangeEvent tableEvent) throws MetaException { cleaner.setTimeToLive(MetastoreConf.getTimeVar(getConf(), MetastoreConf.ConfVars.EVENT_DB_LISTENER_TTL, TimeUnit.SECONDS)); } + + if (key.equals(ConfVars.EVENT_DB_LISTENER_CLEAN_INTERVAL.toString()) || + key.equals(ConfVars.EVENT_DB_LISTENER_CLEAN_INTERVAL.getHiveName())) { + // This weirdness of setting it in our conf and then reading back does two things. + // One, it handles the conversion of the TimeUnit. Two, it keeps the value around for + // later in case we need it again. + long time = MetastoreConf.convertTimeStr(tableEvent.getNewValue(), TimeUnit.SECONDS, + TimeUnit.SECONDS); + MetastoreConf.setTimeVar(getConf(), MetastoreConf.ConfVars.EVENT_DB_LISTENER_CLEAN_INTERVAL, time, + TimeUnit.SECONDS); + cleaner.setCleanupInterval(MetastoreConf.getTimeVar(getConf(), + MetastoreConf.ConfVars.EVENT_DB_LISTENER_CLEAN_INTERVAL, TimeUnit.MILLISECONDS)); + } } /** @@ -913,13 +926,15 @@ private void process(NotificationEvent event, ListenerEvent listenerEvent) throw private static class CleanerThread extends Thread { private RawStore rs; private int ttl; - static private long sleepTime = 60000; + private long sleepTime; CleanerThread(Configuration conf, RawStore rs) { super("DB-Notification-Cleaner"); this.rs = rs; setTimeToLive(MetastoreConf.getTimeVar(conf, ConfVars.EVENT_DB_LISTENER_TTL, TimeUnit.SECONDS)); + setCleanupInterval(MetastoreConf.getTimeVar(conf, ConfVars.EVENT_DB_LISTENER_CLEAN_INTERVAL, + TimeUnit.MILLISECONDS)); setDaemon(true); } @@ -955,5 +970,9 @@ public void setTimeToLive(long configTtl) { } } + public void setCleanupInterval(long configInterval) { + sleepTime = configInterval; + } + } } diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java index 7b01678..79b2f95 100644 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java +++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java @@ -525,6 +525,9 @@ public static ConfVars getMetaConf(String name) { EVENT_DB_LISTENER_TTL("metastore.event.db.listener.timetolive", "hive.metastore.event.db.listener.timetolive", 86400, TimeUnit.SECONDS, "time after which events will be removed from the database listener queue"), + EVENT_DB_LISTENER_CLEAN_INTERVAL("metastore.event.db.listener.clean.interval", + "hive.metastore.event.db.listener.clean.interval", 7200, TimeUnit.SECONDS, + "sleep interval between each run for cleanup of events from the database listener queue"), EVENT_DB_NOTIFICATION_API_AUTH("metastore.metastore.event.db.notification.api.auth", "hive.metastore.event.db.notification.api.auth", true, "Should metastore do authorization against database notification related APIs such as get_next_notification.\n" +