diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java index 7ab1b35..20aa748 100755 --- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java +++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java @@ -24,7 +24,6 @@ import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; import org.apache.atlas.ApplicationProperties; -import org.apache.atlas.AtlasException; import org.apache.atlas.hive.bridge.HiveMetaStoreBridge; import org.apache.atlas.hive.model.HiveDataTypes; import org.apache.atlas.notification.NotificationInterface; @@ -89,7 +88,7 @@ public class HiveHook implements ExecuteWithHookContext { private static final long keepAliveTimeDefault = 10; private static boolean typesRegistered = false; - private final Configuration atlasProperties; + private static Configuration atlasProperties; class HiveEvent { public HiveConf conf; @@ -106,44 +105,43 @@ public class HiveHook implements ExecuteWithHookContext { } @Inject - private NotificationInterface notifInterface; - - public HiveHook() throws AtlasException { - atlasProperties = ApplicationProperties.get(ApplicationProperties.CLIENT_PROPERTIES); - - // initialize the async facility to process hook calls. We don't - // want to do this inline since it adds plenty of overhead for the query. - HiveConf hiveConf = new HiveConf(); - int minThreads = hiveConf.getInt(MIN_THREADS, minThreadsDefault); - int maxThreads = hiveConf.getInt(MAX_THREADS, maxThreadsDefault); - long keepAliveTime = hiveConf.getLong(KEEP_ALIVE_TIME, keepAliveTimeDefault); - - executor = new ThreadPoolExecutor(minThreads, maxThreads, keepAliveTime, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue<Runnable>(), - new ThreadFactoryBuilder().setNameFormat("Atlas Logger %d").build()); + private static NotificationInterface notifInterface; + static { try { - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - try { - executor.shutdown(); - executor.awaitTermination(WAIT_TIME, TimeUnit.SECONDS); - executor = null; - } catch (InterruptedException ie) { - LOG.info("Interrupt received in shutdown."); + atlasProperties = ApplicationProperties.get(ApplicationProperties.CLIENT_PROPERTIES); + + // initialize the async facility to process hook calls. We don't + // want to do this inline since it adds plenty of overhead for the query. + int minThreads = atlasProperties.getInt(MIN_THREADS, minThreadsDefault); + int maxThreads = atlasProperties.getInt(MAX_THREADS, maxThreadsDefault); + long keepAliveTime = atlasProperties.getLong(KEEP_ALIVE_TIME, keepAliveTimeDefault); + + executor = new ThreadPoolExecutor(minThreads, maxThreads, keepAliveTime, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<Runnable>(), + new ThreadFactoryBuilder().setNameFormat("Atlas Logger %d").build()); + + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + try { + executor.shutdown(); + executor.awaitTermination(WAIT_TIME, TimeUnit.SECONDS); + executor = null; + } catch (InterruptedException ie) { + LOG.info("Interrupt received in shutdown."); + } + // shutdown client } - // shutdown client - } - }); - } catch (IllegalStateException is) { - LOG.info("Attempting to send msg while shutdown in progress."); + }); + } catch (Exception e) { + LOG.info("Attempting to send msg while shutdown in progress.", e); } - LOG.info("Created Atlas Hook"); - Injector injector = Guice.createInjector(new NotificationModule()); notifInterface = injector.getInstance(NotificationInterface.class); + + LOG.info("Created Atlas Hook"); } @Override diff --git a/release-log.txt b/release-log.txt index 64b786c..a867ac3 100644 --- a/release-log.txt +++ b/release-log.txt @@ -9,6 +9,7 @@ ATLAS-54 Rename configs in hive hook (shwethags) ATLAS-3 Mixed Index creation fails with Date types (suma.shivaprasad via shwethags) ALL CHANGES: +ATLAS-194 Thread pool in hive hook should be static (shwethags) ATLAS-180 Cleanup atlas doc packaging (shwethags) ATLAS-147 Fix a code issue when defineTypes (ltfxyz via shwethags) ATLAS-110 UI: Lineage should be clickable (Vishal Kadam via Venkatesh Seetharam)