asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Blow (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: [ASTERIXDB-2055][HYR][CLUS] Avoid double shutdown
Date Tue, 22 Aug 2017 00:51:43 GMT
Michael Blow has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1957

Change subject: [ASTERIXDB-2055][HYR][CLUS] Avoid double shutdown
......................................................................

[ASTERIXDB-2055][HYR][CLUS] Avoid double shutdown

Change-Id: If50651a4c46178f191966e09d365d2015df295bc
---
M hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NCShutdownHook.java
M hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NodeControllerService.java
M hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/task/ShutdownTask.java
3 files changed, 10 insertions(+), 14 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/57/1957/1

diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NCShutdownHook.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NCShutdownHook.java
index 162d912..1cd45b2 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NCShutdownHook.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NCShutdownHook.java
@@ -68,7 +68,7 @@
             shutdownHookThread = Thread.currentThread();
             watchDog.start();
             nodeControllerService.stop();
-        } catch (Throwable th) { // NOSONAR... This is fine since this is shutdwon hook
+        } catch (Throwable th) { // NOSONAR... This is fine since this is shutdown hook
             LOGGER.log(Level.WARNING, "Exception in executing shutdown hook", th);
         }
     }
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NodeControllerService.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NodeControllerService.java
index 6b97b31..3deca03 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NodeControllerService.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NodeControllerService.java
@@ -29,6 +29,7 @@
 import java.lang.management.ThreadMXBean;
 import java.lang.reflect.Field;
 import java.net.InetSocketAddress;
+import java.util.Arrays;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
@@ -153,7 +154,7 @@
 
     private final MemoryManager memoryManager;
 
-    private boolean shuttedDown = false;
+    private StackTraceElement[] shuttedDown = null;
 
     private IIOCounter ioCounter;
 
@@ -369,7 +370,8 @@
 
     @Override
     public synchronized void stop() throws Exception {
-        if (!shuttedDown) {
+        if (shuttedDown == null) {
+            shuttedDown = new Throwable().getStackTrace();
             LOGGER.log(Level.INFO, "Stopping NodeControllerService");
             application.preStop();
             executor.shutdownNow();
@@ -391,9 +393,9 @@
              */
             heartbeatTask.cancel();
             LOGGER.log(Level.INFO, "Stopped NodeControllerService");
-            shuttedDown = true;
         } else {
-            LOGGER.log(Level.SEVERE, "Double shutdown calls!!", new Exception("Double shutdown
calls"));
+            LOGGER.log(Level.SEVERE, "Duplicate shutdown call; original: " + Arrays.toString(shuttedDown),
+                    new Exception("Duplicate shutdown call"));
         }
     }
 
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/task/ShutdownTask.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/task/ShutdownTask.java
index cdbd4ad..c3aa5f4 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/task/ShutdownTask.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/task/ShutdownTask.java
@@ -36,6 +36,7 @@
     }
 
     @Override
+    @SuppressWarnings("squid:S1147") // Runtime.exit()
     public void run() {
         IClusterController ccs = ncs.getClusterController();
         try {
@@ -45,19 +46,12 @@
             // proceed with shutdown
         }
 
-        LOGGER.info("JVM Exiting.. Bye!");
         //run the shutdown in a new thread, so we don't block this last work task
         Thread t = new Thread("NC " + ncs.getId() + " Shutdown") {
             @Override
             public void run() {
-                try {
-                    ncs.stop();
-                } catch (Exception e) {
-                    LOGGER.log(Level.SEVERE, "Exception stopping node controller service",
e);
-                } finally {
-                    Runtime rt = Runtime.getRuntime();
-                    rt.exit(terminateNCService ? 99 : 0);
-                }
+                LOGGER.info("JVM Exiting.. Bye!");
+                Runtime.getRuntime().exit(terminateNCService ? 99 : 0);
             }
         };
         t.start();

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1957
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If50651a4c46178f191966e09d365d2015df295bc
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mblow@apache.org>

Mime
View raw message