Repository: incubator-drill
Updated Branches:
  refs/heads/master e764479c1 -> b956e45e6


DRILL-1484: shutdown executors when connection is closed


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

Branch: refs/heads/master
Commit: eff3764f226a81394f9220400d4b2d50f514137d
Parents: e764479
Author: Hanifi Gunes <hgu...@maprtech.com>
Authored: Thu Oct 2 18:27:01 2014 -0700
Committer: Mehant Baid <meha...@gmail.com>
Committed: Thu Oct 23 14:12:51 2014 -0700

----------------------------------------------------------------------
 .../java/org/apache/drill/exec/client/DrillClient.java  | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/eff3764f/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java 
b/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java
index 2c9d2fe..04b955b 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java
@@ -29,6 +29,7 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Vector;
 
+import io.netty.channel.EventLoopGroup;
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.exec.ExecConstants;
 import org.apache.drill.exec.coord.ClusterCoordinator;
@@ -76,6 +77,7 @@ public class DrillClient implements Closeable, 
ConnectionThrottle{
   private boolean supportComplexTypes;
   private final boolean ownsZkConnection;
   private final boolean ownsAllocator;
+  private EventLoopGroup eventLoopGroup;
 
   public DrillClient() {
     this(DrillConfig.create());
@@ -167,13 +169,16 @@ public class DrillClient implements Closeable, 
ConnectionThrottle{
     // just use the first endpoint for now
     DrillbitEndpoint endpoint = endpoints.iterator().next();
 
-    this.client = new UserClient(supportComplexTypes, allocator,
-                                 
TransportCheck.createEventLoopGroup(config.getInt(ExecConstants.CLIENT_RPC_THREADS),
 "Client-"));
+    eventLoopGroup = 
createEventLoop(config.getInt(ExecConstants.CLIENT_RPC_THREADS), "Client-");
+    client = new UserClient(supportComplexTypes, allocator, eventLoopGroup);
     logger.debug("Connecting to server {}:{}", endpoint.getAddress(), 
endpoint.getUserPort());
     connect(endpoint);
     connected = true;
   }
 
+  protected EventLoopGroup createEventLoop(int size, String prefix) {
+    return TransportCheck.createEventLoopGroup(size, prefix);
+  }
 
   public synchronized boolean reconnect() {
     if (client.isActive()) {
@@ -228,6 +233,9 @@ public class DrillClient implements Closeable, 
ConnectionThrottle{
         logger.warn("Error while closing Cluster Coordinator.", e);
       }
     }
+    if (eventLoopGroup != null) {
+      eventLoopGroup.shutdownGracefully();
+    }
 
     // TODO: fix tests that fail when this is called.
     //allocator.close();

Reply via email to