You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2016/12/23 01:47:02 UTC
[33/50] [abbrv] incubator-atlas git commit: ATLAS-1162: shutdown
hooks to register with ShutdownHookManager, instead of System.Runtime
ATLAS-1162: shutdown hooks to register with ShutdownHookManager, instead of System.Runtime
(cherry picked from commit 8044ca48d041f59a66ccd597a1cf7e9832a60146)
Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/d0d0f82b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/d0d0f82b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/d0d0f82b
Branch: refs/heads/0.7-incubating
Commit: d0d0f82b1f9bf723db4308bc85a89f97a0f8ea0f
Parents: 5eaf6b4
Author: Madhan Neethiraj <ma...@apache.org>
Authored: Mon Sep 12 15:46:17 2016 -0700
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Thu Dec 22 15:29:06 2016 -0800
----------------------------------------------------------------------
.../java/org/apache/atlas/falcon/hook/FalconHook.java | 10 ++++++++--
.../main/java/org/apache/atlas/hive/hook/HiveHook.java | 9 +++++++--
.../src/main/java/org/apache/atlas/AtlasConstants.java | 1 +
.../src/main/java/org/apache/atlas/hook/AtlasHook.java | 4 ++--
release-log.txt | 1 +
webapp/src/main/java/org/apache/atlas/Atlas.java | 11 ++++++++---
6 files changed, 27 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d0d0f82b/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java
----------------------------------------------------------------------
diff --git a/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java b/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java
index d724f57..b6312d7 100644
--- a/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java
+++ b/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java
@@ -21,6 +21,7 @@ package org.apache.atlas.falcon.hook;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.inject.Guice;
import com.google.inject.Injector;
+import org.apache.atlas.AtlasConstants;
import org.apache.atlas.falcon.bridge.FalconBridge;
import org.apache.atlas.falcon.event.FalconEvent;
import org.apache.atlas.falcon.publisher.FalconEventPublisher;
@@ -32,6 +33,7 @@ import org.apache.atlas.typesystem.Referenceable;
import org.apache.falcon.entity.store.ConfigurationStore;
import org.apache.falcon.entity.v0.feed.Feed;
import org.apache.falcon.entity.v0.process.Process;
+import org.apache.hadoop.util.ShutdownHookManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -90,19 +92,23 @@ public class FalconHook extends AtlasHook implements FalconEventPublisher {
new LinkedBlockingQueue<Runnable>(queueSize),
new ThreadFactoryBuilder().setNameFormat("Atlas Logger %d").build());
- Runtime.getRuntime().addShutdownHook(new Thread() {
+ ShutdownHookManager.get().addShutdownHook(new Thread() {
@Override
public void run() {
try {
+ LOG.info("==> Shutdown of Atlas Falcon Hook");
+
executor.shutdown();
executor.awaitTermination(WAIT_TIME, TimeUnit.SECONDS);
executor = null;
} catch (InterruptedException ie) {
LOG.info("Interrupt received in shutdown.");
+ } finally {
+ LOG.info("<== Shutdown of Atlas Falcon Hook");
}
// shutdown client
}
- });
+ }, AtlasConstants.ATLAS_SHUTDOWN_HOOK_PRIORITY);
STORE = ConfigurationStore.get();
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d0d0f82b/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 fdd0199..a3464a0 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
@@ -50,6 +50,7 @@ import org.apache.hadoop.hive.ql.metadata.Partition;
import org.apache.hadoop.hive.ql.metadata.Table;
import org.apache.hadoop.hive.ql.plan.HiveOperation;
import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.util.ShutdownHookManager;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -122,19 +123,23 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
new LinkedBlockingQueue<Runnable>(queueSize),
new ThreadFactoryBuilder().setNameFormat("Atlas Logger %d").build());
- Runtime.getRuntime().addShutdownHook(new Thread() {
+ ShutdownHookManager.get().addShutdownHook(new Thread() {
@Override
public void run() {
try {
+ LOG.info("==> Shutdown of Atlas Hive Hook");
+
executor.shutdown();
executor.awaitTermination(WAIT_TIME, TimeUnit.SECONDS);
executor = null;
} catch (InterruptedException ie) {
LOG.info("Interrupt received in shutdown.");
+ } finally {
+ LOG.info("<== Shutdown of Atlas Hive Hook");
}
// shutdown client
}
- });
+ }, AtlasConstants.ATLAS_SHUTDOWN_HOOK_PRIORITY);
}
setupOperationMap();
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d0d0f82b/common/src/main/java/org/apache/atlas/AtlasConstants.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/atlas/AtlasConstants.java b/common/src/main/java/org/apache/atlas/AtlasConstants.java
index cee85b4..17ffbd7 100644
--- a/common/src/main/java/org/apache/atlas/AtlasConstants.java
+++ b/common/src/main/java/org/apache/atlas/AtlasConstants.java
@@ -32,5 +32,6 @@ public final class AtlasConstants {
public static final String DEFAULT_APP_PORT_STR = "21000";
public static final String ATLAS_REST_ADDRESS_KEY = "atlas.rest.address";
public static final String DEFAULT_ATLAS_REST_ADDRESS = "http://localhost:21000";
+ public static final int ATLAS_SHUTDOWN_HOOK_PRIORITY = 30;
}
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d0d0f82b/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java b/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
index 93a10b4..04ee9c0 100644
--- a/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
+++ b/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
@@ -131,9 +131,9 @@ public abstract class AtlasHook {
} catch (Exception e) {
numRetries++;
if (numRetries < maxRetries) {
- LOG.error("Notification send retry failed");
+ LOG.error("Failed to send notification - attempt #" + numRetries + "; error=" + e.getMessage());
try {
- LOG.info("Sleeping for {} ms before retry", notificationRetryInterval);
+ LOG.debug("Sleeping for {} ms before retry", notificationRetryInterval);
Thread.sleep(notificationRetryInterval);
} catch (InterruptedException ie){
LOG.error("Notification hook thread sleep interrupted");
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d0d0f82b/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index d94eb2b..4a888c7 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -31,6 +31,7 @@ ATLAS-409 Atlas will not import avro tables with schema read from a file (dosset
ATLAS-379 Create sqoop and falcon metadata addons (venkatnrangan,bvellanki,sowmyaramesh via shwethags)
ALL CHANGES:
+ATLAS-1162 Register shutdown hooks with Hadoop's ShutdownHookManager, instead of directly with Java Runtime (mneethiraj via sumasai)
ATLAS-1098 Atlas allows creation of tag with name "isa" which causes exceptions during search (apoorvnaik via kevalbhatt)
ATLAS-1160 Update Atlas hive hook to read configuration from atlas-application.properties instead of hive-site.xml (mneethiraj via kevalbhatt)
ATLAS-1154 Errors in Eclipse with web.xml (davidrad via dkantor)
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d0d0f82b/webapp/src/main/java/org/apache/atlas/Atlas.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/Atlas.java b/webapp/src/main/java/org/apache/atlas/Atlas.java
index dd43c6d..14c43cc 100755
--- a/webapp/src/main/java/org/apache/atlas/Atlas.java
+++ b/webapp/src/main/java/org/apache/atlas/Atlas.java
@@ -30,6 +30,7 @@ import org.apache.commons.cli.ParseException;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.lang.StringUtils;
+import org.apache.hadoop.util.ShutdownHookManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,16 +53,20 @@ public final class Atlas {
private static EmbeddedServer server;
static {
- Runtime.getRuntime().addShutdownHook(new Thread() {
+ ShutdownHookManager.get().addShutdownHook(new Thread() {
@Override
public void run() {
try {
+ LOG.info("==> Shutdown of Atlas");
+
shutdown();
} catch (Exception e) {
- LOG.debug("Failed to shutdown", e);
+ LOG.error("Failed to shutdown", e);
+ } finally {
+ LOG.info("<== Shutdown of Atlas");
}
}
- });
+ }, AtlasConstants.ATLAS_SHUTDOWN_HOOK_PRIORITY);
}
private static void shutdown() {