Github user ilooner commented on a diff in the pull request:

    https://github.com/apache/drill/pull/1148#discussion_r171988996
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java 
---
    @@ -154,35 +152,31 @@ public void start() throws Exception {
     
         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);
    --- End diff --
    
    I see thx


---

Reply via email to