hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vinayakum...@apache.org
Subject [1/3] hadoop git commit: HADOOP-12423. Handle failure of registering shutdownhook by ShutdownHookManager in static block (Contributed by Abhishek Agarwal)
Date Thu, 21 Jan 2016 14:45:54 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 845acfd96 -> c13929b38
  refs/heads/branch-2.8 444967704 -> a02fab85e
  refs/heads/trunk b7372b716 -> 446987e20


HADOOP-12423. Handle failure of registering shutdownhook by ShutdownHookManager in static
block (Contributed by Abhishek Agarwal)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/446987e2
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/446987e2
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/446987e2

Branch: refs/heads/trunk
Commit: 446987e20aacd870e1bc3f950b2bd4bbda1f9571
Parents: b7372b7
Author: Vinayakumar B <vinayakumarb@apache.org>
Authored: Thu Jan 21 20:08:24 2016 +0530
Committer: Vinayakumar B <vinayakumarb@apache.org>
Committed: Thu Jan 21 20:08:24 2016 +0530

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt |  3 ++
 .../apache/hadoop/util/ShutdownHookManager.java | 31 ++++++++++++--------
 2 files changed, 21 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/446987e2/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 85f304a..e775f1b 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -1630,6 +1630,9 @@ Release 2.8.0 - UNRELEASED
     HADOOP-12356. Fix computing CPU usage statistics on Windows.
     (Inigo Goiri via wangda)
 
+    HADOOP-12423. Handle failure of registering shutdownhook by
+    ShutdownHookManager in static block (Abhishek Agarwal via vinayakumarb)
+
 Release 2.7.3 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/446987e2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ShutdownHookManager.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ShutdownHookManager.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ShutdownHookManager.java
index 85533db..843454b 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ShutdownHookManager.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ShutdownHookManager.java
@@ -44,22 +44,27 @@ public class ShutdownHookManager {
   private static final Log LOG = LogFactory.getLog(ShutdownHookManager.class);
 
   static {
-    Runtime.getRuntime().addShutdownHook(
-      new Thread() {
-        @Override
-        public void run() {
-          MGR.shutdownInProgress.set(true);
-          for (Runnable hook: MGR.getShutdownHooksInOrder()) {
-            try {
-              hook.run();
-            } catch (Throwable ex) {
-              LOG.warn("ShutdownHook '" + hook.getClass().getSimpleName() +
-                       "' failed, " + ex.toString(), ex);
+    try {
+      Runtime.getRuntime().addShutdownHook(
+        new Thread() {
+          @Override
+          public void run() {
+            MGR.shutdownInProgress.set(true);
+            for (Runnable hook: MGR.getShutdownHooksInOrder()) {
+              try {
+                hook.run();
+              } catch (Throwable ex) {
+                LOG.warn("ShutdownHook '" + hook.getClass().getSimpleName() +
+                         "' failed, " + ex.toString(), ex);
+              }
             }
           }
         }
-      }
-    );
+      );
+    } catch (IllegalStateException ex) {
+      // JVM is being shut down. Ignore
+      LOG.warn("Failed to add the ShutdownHook", ex);
+    }
   }
 
   /**


Mime
View raw message