drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ar...@apache.org
Subject [01/17] drill git commit: DRILL-5994: Enable configuring number of Jetty acceptors and selectors (default to 1 acceptor and 2 selectors)
Date Sat, 03 Mar 2018 18:47:07 GMT
Repository: drill
Updated Branches:
  refs/heads/master 9073aed67 -> cf2478f7a


DRILL-5994: Enable configuring number of Jetty acceptors and selectors (default to 1 acceptor
and 2 selectors)

closes #1148


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

Branch: refs/heads/master
Commit: 49faae0452935e9ee1054c056df3e038391048ba
Parents: 9073aed
Author: Vlad Rozov <vrozov@apache.org>
Authored: Fri Mar 2 10:39:31 2018 -0800
Committer: Arina Ielchiieva <arina.yelchiyeva@gmail.com>
Committed: Sat Mar 3 19:47:31 2018 +0200

----------------------------------------------------------------------
 .../org/apache/drill/exec/ExecConstants.java    |  3 +-
 .../drill/exec/server/rest/WebServer.java       | 55 +++++++++-----------
 .../src/main/resources/drill-module.conf        | 11 ++--
 3 files changed, 34 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/49faae04/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
index fb2907d..54fb46a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
@@ -142,6 +142,8 @@ public final class ExecConstants {
   public static final String HTTP_MAX_PROFILES = "drill.exec.http.max_profiles";
   public static final String HTTP_PORT = "drill.exec.http.port";
   public static final String HTTP_PORT_HUNT = "drill.exec.http.porthunt";
+  public static final String HTTP_JETTY_SERVER_ACCEPTORS = "drill.exec.http.jetty.server.acceptors";
+  public static final String HTTP_JETTY_SERVER_SELECTORS = "drill.exec.http.jetty.server.selectors";
   public static final String HTTP_ENABLE_SSL = "drill.exec.http.ssl_enabled";
   public static final String HTTP_CORS_ENABLED = "drill.exec.http.cors.enabled";
   public static final String HTTP_CORS_ALLOWED_ORIGINS = "drill.exec.http.cors.allowedOrigins";
@@ -174,7 +176,6 @@ public final class ExecConstants {
   public static final String USE_LOGIN_PRINCIPAL = "drill.exec.security.bit.auth.use_login_principal";
   public static final String USER_ENCRYPTION_SASL_ENABLED = "drill.exec.security.user.encryption.sasl.enabled";
   public static final String USER_ENCRYPTION_SASL_MAX_WRAPPED_SIZE = "drill.exec.security.user.encryption.sasl.max_wrapped_size";
-  public static final String WEB_SERVER_THREAD_POOL_MAX = "drill.exec.web_server.thread_pool_max";
 
   public static final String USER_SSL_ENABLED = "drill.exec.security.user.encryption.ssl.enabled";
   public static final String BIT_ENCRYPTION_SASL_ENABLED = "drill.exec.security.bit.encryption.sasl.enabled";

http://git-wip-us.apache.org/repos/asf/drill/blob/49faae04/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java
index 4566e7d..bfb6d90 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java
@@ -111,8 +111,6 @@ public class WebServer implements AutoCloseable {
 
   private final Drillbit drillbit;
 
-  private int port;
-
   /**
    * Create Jetty based web server.
    *
@@ -154,35 +152,31 @@ public class WebServer implements AutoCloseable {
 
     final boolean authEnabled = config.getBoolean(ExecConstants.USER_AUTHENTICATION_ENABLED);
 
-    port = config.getInt(ExecConstants.HTTP_PORT);
-    boolean portHunt = config.getBoolean(ExecConstants.HTTP_PORT_HUNT);
-    int retry = 0;
-
-    for (; retry < PORT_HUNT_TRIES; retry++) {
-      embeddedJetty = new Server(new QueuedThreadPool(config.getInt(ExecConstants.WEB_SERVER_THREAD_POOL_MAX)));
-      embeddedJetty.setHandler(createServletContextHandler(authEnabled));
-      embeddedJetty.addConnector(createConnector(port));
-
+    int port = config.getInt(ExecConstants.HTTP_PORT);
+    final boolean portHunt = config.getBoolean(ExecConstants.HTTP_PORT_HUNT);
+    final int acceptors = config.getInt(ExecConstants.HTTP_JETTY_SERVER_ACCEPTORS);
+    final int selectors = config.getInt(ExecConstants.HTTP_JETTY_SERVER_SELECTORS);
+    final QueuedThreadPool threadPool = new QueuedThreadPool(2, 2, 60000);
+    embeddedJetty = new Server(threadPool);
+    embeddedJetty.setHandler(createServletContextHandler(authEnabled));
+    ServerConnector connector = createConnector(port, acceptors, selectors);
+    threadPool.setMaxThreads(1 + connector.getAcceptors() + connector.getSelectorManager().getSelectorCount());
+    embeddedJetty.addConnector(connector);
+    for (int retry = 0; retry < PORT_HUNT_TRIES; retry++) {
+      connector.setPort(port);
       try {
         embeddedJetty.start();
+        return;
       } catch (BindException e) {
         if (portHunt) {
-          int nextPort = port + 1;
-          logger.info("Failed to start on port {}, trying port {}", port, nextPort);
-          port = nextPort;
-          embeddedJetty.stop();
+          logger.info("Failed to start on port {}, trying port {}", port, ++port, e);
           continue;
         } else {
           throw e;
         }
       }
-
-      break;
-    }
-
-    if (retry == PORT_HUNT_TRIES) {
-      throw new IOException("Failed to find a port");
     }
+    throw new IOException("Failed to find a port");
   }
 
   private ServletContextHandler createServletContextHandler(final boolean authEnabled) throws
DrillbitStartupException {
@@ -302,23 +296,22 @@ public class WebServer implements AutoCloseable {
   }
 
   public int getPort() {
-    if (!config.getBoolean(ExecConstants.HTTP_ENABLE)) {
+    if (embeddedJetty == null || embeddedJetty.getConnectors().length != 1) {
       throw new UnsupportedOperationException("Http is not enabled");
     }
-
-    return port;
+    return ((ServerConnector)embeddedJetty.getConnectors()[0]).getPort();
   }
 
-  private ServerConnector createConnector(int port) throws Exception {
+  private ServerConnector createConnector(int port, int acceptors, int selectors) throws
Exception {
     final ServerConnector serverConnector;
     if (config.getBoolean(ExecConstants.HTTP_ENABLE_SSL)) {
       try {
-        serverConnector = createHttpsConnector(port);
+        serverConnector = createHttpsConnector(port, acceptors, selectors);
       } catch (DrillException e) {
         throw new DrillbitStartupException(e.getMessage(), e);
       }
     } else {
-      serverConnector = createHttpConnector(port);
+      serverConnector = createHttpConnector(port, acceptors, selectors);
     }
 
     return serverConnector;
@@ -331,7 +324,7 @@ public class WebServer implements AutoCloseable {
    * @return Initialized {@link ServerConnector} for HTTPS connections.
    * @throws Exception
    */
-  private ServerConnector createHttpsConnector(int port) throws Exception {
+  private ServerConnector createHttpsConnector(int port, int acceptors, int selectors) throws
Exception {
     logger.info("Setting up HTTPS connector for web server");
 
     final SslContextFactory sslContextFactory = new SslContextFactory();
@@ -411,6 +404,7 @@ public class WebServer implements AutoCloseable {
 
     // SSL Connector
     final ServerConnector sslConnector = new ServerConnector(embeddedJetty,
+        null, null, null, acceptors, selectors,
         new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
         new HttpConnectionFactory(httpsConfig));
     sslConnector.setPort(port);
@@ -424,10 +418,11 @@ public class WebServer implements AutoCloseable {
    * @return Initialized {@link ServerConnector} instance for HTTP connections.
    * @throws Exception
    */
-  private ServerConnector createHttpConnector(int port) throws Exception {
+  private ServerConnector createHttpConnector(int port, int acceptors, int selectors) throws
Exception {
     logger.info("Setting up HTTP connector for web server");
     final HttpConfiguration httpConfig = new HttpConfiguration();
-    final ServerConnector httpConnector = new ServerConnector(embeddedJetty, new HttpConnectionFactory(httpConfig));
+    final ServerConnector httpConnector =
+        new ServerConnector(embeddedJetty, null, null, null, acceptors, selectors, new HttpConnectionFactory(httpConfig));
     httpConnector.setPort(port);
 
     return httpConnector;

http://git-wip-us.apache.org/repos/asf/drill/blob/49faae04/exec/java-exec/src/main/resources/drill-module.conf
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/drill-module.conf b/exec/java-exec/src/main/resources/drill-module.conf
index 2305a30..fc365d2 100644
--- a/exec/java-exec/src/main/resources/drill-module.conf
+++ b/exec/java-exec/src/main/resources/drill-module.conf
@@ -120,6 +120,12 @@ drill.exec: {
     ssl_enabled: false,
     porthunt: false,
     port: 8047,
+    jetty : {
+      server : {
+        acceptors : 1,
+        selectors : 2
+      }
+    }
     max_profiles: 100,
     session_max_idle_secs: 3600, # Default value 1hr
     cors: {
@@ -379,10 +385,7 @@ drill.exec: {
   # refresh time.
   grace_period_ms : 0,
   //port hunting for drillbits. Enabled only for testing purposes.
-  port_hunt : false,
-  // Max threads of embedded Jetty
-  web_server.thread_pool_max: 200
-
+  port_hunt : false
 }
 
 drill.jdbc: {


Mime
View raw message