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 ec5d1c4..c08431a 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 @@ -46,6 +46,7 @@ import org.apache.hadoop.hive.metastore.api.SQLPrimaryKey; import org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint; import org.apache.hadoop.hive.metastore.api.Table; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; import org.apache.hadoop.hive.metastore.events.AddForeignKeyEvent; import org.apache.hadoop.hive.metastore.events.AddIndexEvent; import org.apache.hadoop.hive.metastore.events.AddNotNullConstraintEvent; @@ -94,14 +95,14 @@ // This is the same object as super.conf, but it's convenient to keep a copy of it as a // HiveConf rather than a Configuration. - private HiveConf hiveConf; + private Configuration conf; private MessageFactory msgFactory; - private synchronized void init(HiveConf conf) throws MetaException { + private synchronized void init(Configuration conf) throws MetaException { if (cleaner == null) { cleaner = new CleanerThread(conf, RawStoreProxy.getProxy(conf, conf, - conf.getVar(HiveConf.ConfVars.METASTORE_RAW_STORE_IMPL), 999999)); + MetastoreConf.getVar(conf, MetastoreConf.ConfVars.RAW_STORE_IMPL), 999999)); cleaner.start(); } } @@ -111,8 +112,8 @@ public DbNotificationListener(Configuration config) throws MetaException { // The code in MetastoreUtils.getMetaStoreListeners() that calls this looks for a constructor // with a Configuration parameter, so we have to declare config as Configuration. But it // actually passes a HiveConf, which we need. So we'll do this ugly down cast. - hiveConf = (HiveConf)config; - init(hiveConf); + this.conf = config; + init(conf); msgFactory = MessageFactory.getInstance(); } @@ -127,9 +128,9 @@ public void onConfigChange(ConfigChangeEvent tableEvent) throws MetaException { // This weirdness of setting it in our hiveConf 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. - hiveConf.set(HiveConf.ConfVars.METASTORE_EVENT_DB_LISTENER_TTL.name(), + conf.set(HiveConf.ConfVars.METASTORE_EVENT_DB_LISTENER_TTL.name(), tableEvent.getNewValue()); - cleaner.setTimeToLive(hiveConf.getTimeVar(HiveConf.ConfVars.METASTORE_EVENT_DB_LISTENER_TTL, + cleaner.setTimeToLive(MetastoreConf.getTimeVar(conf, MetastoreConf.ConfVars.EVENT_DB_LISTENER_TTL, TimeUnit.SECONDS)); } } @@ -205,7 +206,7 @@ public boolean accept(Path p) { try { if (locString != null) { Path loc = new Path(locString); - fs = loc.getFileSystem(hiveConf); + fs = loc.getFileSystem(conf); files = fs.listStatus(loc, VALID_FILES_FILTER); } } catch (IOException e) { @@ -573,7 +574,7 @@ private void process(NotificationEvent event, ListenerEvent listenerEvent) throw event.setMessageFormat(msgFactory.getMessageFormat()); LOG.debug("DbNotificationListener: Processing : {}:{}", event.getEventId(), event.getMessage()); - HMSHandler.getMSForConf(hiveConf).addNotificationEvent(event); + HMSHandler.getMSForConf(conf).addNotificationEvent(event); // Set the DB_NOTIFICATION_EVENT_ID for future reference by other listeners. if (event.isSetEventId()) { @@ -588,10 +589,10 @@ private void process(NotificationEvent event, ListenerEvent listenerEvent) throw private int ttl; static private long sleepTime = 60000; - CleanerThread(HiveConf conf, RawStore rs) { + CleanerThread(Configuration conf, RawStore rs) { super("CleanerThread"); this.rs = rs; - setTimeToLive(conf.getTimeVar(HiveConf.ConfVars.METASTORE_EVENT_DB_LISTENER_TTL, + setTimeToLive(MetastoreConf.getTimeVar(conf, MetastoreConf.ConfVars.EVENT_DB_LISTENER_TTL, TimeUnit.SECONDS)); setDaemon(true); } diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java index d18ddc8..781f19b 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java @@ -463,6 +463,9 @@ public static ConfVars getMetaConf(String name) { "hive.metastore.event.message.factory", "org.apache.hadoop.hive.metastore.messaging.json.JSONMessageFactory", "Factory class for making encoding and decoding messages in the events generated."), + 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_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" +