drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [11/15] drill git commit: Reduce test time by not waiting 2 seconds for newly submitted tasks before shutting down RPC thread pool.
Date Mon, 14 Sep 2015 05:28:58 GMT
Reduce test time by not waiting 2 seconds for newly submitted tasks before shutting down RPC
thread pool.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/71086bf8
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/71086bf8
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/71086bf8

Branch: refs/heads/master
Commit: 71086bf82b5dd3aca3674147df3fd97455883fae
Parents: fe07b6c
Author: Jacques Nadeau <jacques@apache.org>
Authored: Sun Sep 13 18:51:46 2015 -0700
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Sun Sep 13 21:58:33 2015 -0700

----------------------------------------------------------------------
 .../org/apache/drill/exec/rpc/BasicServer.java  |  3 +-
 .../org/apache/drill/exec/work/WorkManager.java | 32 ++++++++++++++------
 2 files changed, 25 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/71086bf8/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java
index c20afc0..00bbcb4 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java
@@ -31,6 +31,7 @@ import io.netty.handler.timeout.ReadTimeoutHandler;
 import java.io.IOException;
 import java.net.BindException;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.drill.common.exceptions.UserException;
 import org.apache.drill.exec.exception.DrillbitStartupException;
@@ -215,7 +216,7 @@ public abstract class BasicServer<T extends EnumLite, C extends RemoteConnection
   @Override
   public void close() throws IOException {
     try {
-      eventLoopGroup.shutdownGracefully().get();
+      eventLoopGroup.shutdownGracefully(0, 2, TimeUnit.SECONDS).get();
     } catch (final InterruptedException | ExecutionException e) {
       logger.warn("Failure while shutting down {}. ", this.getClass().getName(), e);
 

http://git-wip-us.apache.org/repos/asf/drill/blob/71086bf8/exec/java-exec/src/main/java/org/apache/drill/exec/work/WorkManager.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/WorkManager.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/WorkManager.java
index 5939113..8209277 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/WorkManager.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/WorkManager.java
@@ -168,16 +168,26 @@ public class WorkManager implements AutoCloseable {
 
   @Override
   public void close() throws Exception {
-    try {
-      if (executor != null) {
-        executor.awaitTermination(1, TimeUnit.SECONDS);
-      }
-    } catch (final InterruptedException e) {
-      logger.warn("Executor interrupted while awaiting termination");
 
-      // Preserve evidence that the interruption occurred so that code higher up on the call
stack can learn of the
-      // interruption and respond to it if it wants to.
-      Thread.currentThread().interrupt();
+    if (executor != null) {
+      executor.shutdown(); // Disable new tasks from being submitted
+      try {
+        // Wait a while for existing tasks to terminate
+        if (!executor.awaitTermination(1, TimeUnit.SECONDS)) {
+          executor.shutdownNow(); // Cancel currently executing tasks
+          // Wait a while for tasks to respond to being cancelled
+          if (!executor.awaitTermination(1, TimeUnit.SECONDS)) {
+            logger.error("Pool did not terminate");
+          }
+        }
+      } catch (InterruptedException ie) {
+        logger.warn("Executor interrupted while awaiting termination");
+
+        // (Re-)Cancel if current thread also interrupted
+        executor.shutdownNow();
+        // Preserve interrupt status
+        Thread.currentThread().interrupt();
+      }
     }
 
     if (!runningFragments.isEmpty()) {
@@ -191,6 +201,10 @@ public class WorkManager implements AutoCloseable {
     }
   }
 
+  private void shutdownAndAwaitTermination(long timeInSeconds) {
+
+  }
+
   public DrillbitContext getContext() {
     return dContext;
   }


Mime
View raw message