azkaban-aplcache

delaying shutting executor down (#2007) Executor will be

10/25/2018 11:40:03 PM
3.60.0

Details

diff --git a/azkaban-exec-server/src/main/java/azkaban/execapp/AzkabanExecutorServer.java b/azkaban-exec-server/src/main/java/azkaban/execapp/AzkabanExecutorServer.java
index ad0c167..2fb2f1c 100644
--- a/azkaban-exec-server/src/main/java/azkaban/execapp/AzkabanExecutorServer.java
+++ b/azkaban-exec-server/src/main/java/azkaban/execapp/AzkabanExecutorServer.java
@@ -62,6 +62,7 @@ import java.nio.file.Paths;
 import java.security.Permission;
 import java.security.Policy;
 import java.security.ProtectionDomain;
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.TimeZone;
@@ -508,6 +509,14 @@ public class AzkabanExecutorServer {
     return getHost() + ":" + getPort();
   }
 
+  private void sleep(final Duration duration) {
+    try {
+      Thread.sleep(duration.toMillis());
+    } catch (final InterruptedException e) {
+      logger.error(e);
+    }
+  }
+
   /**
    * Shutdown the server. - performs a safe shutdown. Waits for completion of current tasks - spawns
    * a shutdown thread and returns immediately.
@@ -515,12 +524,8 @@ public class AzkabanExecutorServer {
   public void shutdown() {
     logger.warn("Shutting down AzkabanExecutorServer...");
     new Thread(() -> {
-      try {
-        // Hack: Sleep for a little time to allow API calls to complete
-        Thread.sleep(2000);
-      } catch (InterruptedException e) {
-        logger.error(e);
-      }
+      // Hack: Sleep for a little time to allow API calls to complete
+      sleep(Duration.ofSeconds(2));
       shutdownInternal();
     }, "shutdown").start();
   }
@@ -532,6 +537,9 @@ public class AzkabanExecutorServer {
    */
   private void shutdownInternal() {
     getFlowRunnerManager().shutdown();
+    // Sleep for an hour to wait for web server updater thread
+    // {@link azkaban.executor.RunningExecutionsUpdaterThread#updateExecutions} to finalize updating
+    sleep(Duration.ofHours(1));
     // trigger shutdown hook
     System.exit(0);
   }