You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sh...@apache.org on 2015/09/28 08:32:39 UTC

incubator-atlas git commit: ATLAS-194 Thread pool in hive hook should be static (shwethags)

Repository: incubator-atlas
Updated Branches:
  refs/heads/master 9ebfd1b1b -> 57a7d1bc6


ATLAS-194 Thread pool in hive hook should be static (shwethags)


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/57a7d1bc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/57a7d1bc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/57a7d1bc

Branch: refs/heads/master
Commit: 57a7d1bc6185a01a689908d7929bd767f82c209e
Parents: 9ebfd1b
Author: Shwetha GS <ss...@hortonworks.com>
Authored: Mon Sep 28 12:02:33 2015 +0530
Committer: Shwetha GS <ss...@hortonworks.com>
Committed: Mon Sep 28 12:02:33 2015 +0530

----------------------------------------------------------------------
 .../org/apache/atlas/hive/hook/HiveHook.java    | 64 ++++++++++----------
 release-log.txt                                 |  1 +
 2 files changed, 32 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/57a7d1bc/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java
----------------------------------------------------------------------
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

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/57a7d1bc/release-log.txt
----------------------------------------------------------------------
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)