Skip to content

Commit

Permalink
Bump jetty to v9.4.12 (#2811)
Browse files Browse the repository at this point in the history
The recent proxy changes (#2801) tickled some issues in jetty's 9.3
series, where clients can hang if running on machines with a lot of
cores. This causes some tests to fail CI, while being impossible to
repro locally (unless you have a 24 core machine lying around).

Jetty reworked a lot of their selector code in 9.4, which appears to
make the issue go away.
  • Loading branch information
ivankelly committed Oct 22, 2018
1 parent f3a027b commit b73a967
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 74 deletions.
35 changes: 18 additions & 17 deletions distribution/server/src/assemble/LICENSE.bin.txt
Expand Up @@ -395,22 +395,23 @@ The Apache Software License, Version 2.0
- org.asynchttpclient-async-http-client-2.1.0-alpha26.jar - org.asynchttpclient-async-http-client-2.1.0-alpha26.jar
- org.asynchttpclient-async-http-client-netty-utils-2.1.0-alpha26.jar - org.asynchttpclient-async-http-client-netty-utils-2.1.0-alpha26.jar
* Jetty * Jetty
- org.eclipse.jetty-jetty-client-9.3.11.v20160721.jar - org.eclipse.jetty-jetty-client-9.4.12.v20180830.jar
- org.eclipse.jetty-jetty-continuation-9.3.11.v20160721.jar - org.eclipse.jetty-jetty-continuation-9.4.12.v20180830.jar
- org.eclipse.jetty-jetty-http-9.3.11.v20160721.jar - org.eclipse.jetty-jetty-http-9.4.12.v20180830.jar
- org.eclipse.jetty-jetty-io-9.3.11.v20160721.jar - org.eclipse.jetty-jetty-io-9.4.12.v20180830.jar
- org.eclipse.jetty-jetty-proxy-9.3.11.v20160721.jar - org.eclipse.jetty-jetty-proxy-9.4.12.v20180830.jar
- org.eclipse.jetty-jetty-security-9.3.11.v20160721.jar - org.eclipse.jetty-jetty-security-9.4.12.v20180830.jar
- org.eclipse.jetty-jetty-server-9.3.11.v20160721.jar - org.eclipse.jetty-jetty-server-9.4.12.v20180830.jar
- org.eclipse.jetty-jetty-servlet-9.3.11.v20160721.jar - org.eclipse.jetty-jetty-servlet-9.4.12.v20180830.jar
- org.eclipse.jetty-jetty-servlets-9.3.11.v20160721.jar - org.eclipse.jetty-jetty-servlets-9.4.12.v20180830.jar
- org.eclipse.jetty-jetty-util-9.3.11.v20160721.jar - org.eclipse.jetty-jetty-util-9.4.12.v20180830.jar
- org.eclipse.jetty.websocket-javax-websocket-client-impl-9.3.11.v20160721.jar - org.eclipse.jetty-jetty-xml-9.4.12.v20180830.jar
- org.eclipse.jetty.websocket-websocket-api-9.3.11.v20160721.jar - org.eclipse.jetty.websocket-javax-websocket-client-impl-9.4.12.v20180830.jar
- org.eclipse.jetty.websocket-websocket-client-9.3.11.v20160721.jar - org.eclipse.jetty.websocket-websocket-api-9.4.12.v20180830.jar
- org.eclipse.jetty.websocket-websocket-common-9.3.11.v20160721.jar - org.eclipse.jetty.websocket-websocket-client-9.4.12.v20180830.jar
- org.eclipse.jetty.websocket-websocket-server-9.3.11.v20160721.jar - org.eclipse.jetty.websocket-websocket-common-9.4.12.v20180830.jar
- org.eclipse.jetty.websocket-websocket-servlet-9.3.11.v20160721.jar - org.eclipse.jetty.websocket-websocket-server-9.4.12.v20180830.jar
- org.eclipse.jetty.websocket-websocket-servlet-9.4.12.v20180830.jar
* SnakeYaml -- org.yaml-snakeyaml-1.15.jar * SnakeYaml -- org.yaml-snakeyaml-1.15.jar
* RocksDB - org.rocksdb-rocksdbjni-5.13.3.jar * RocksDB - org.rocksdb-rocksdbjni-5.13.3.jar
* HttpClient * HttpClient
Expand Down Expand Up @@ -501,7 +502,7 @@ CDDL-1.1 -- licenses/LICENSE-CDDL-1.1.txt
* Java Annotations API * Java Annotations API
- javax.annotation-javax.annotation-api-1.2.jar - javax.annotation-javax.annotation-api-1.2.jar
* Java Servlet API -- javax.servlet-javax.servlet-api-3.1.0.jar * Java Servlet API -- javax.servlet-javax.servlet-api-3.1.0.jar
* WebSocket Server API -- javax.websocket-javax.websocket-api-1.0.jar * WebSocket Server API -- javax.websocket-javax.websocket-client-api-1.0.jar
* Java Web Service REST API -- javax.ws.rs-javax.ws.rs-api-2.1.jar * Java Web Service REST API -- javax.ws.rs-javax.ws.rs-api-2.1.jar
* HK2 - Dependency Injection Kernel * HK2 - Dependency Injection Kernel
- org.glassfish.hk2-hk2-api-2.5.0-b30.jar - org.glassfish.hk2-hk2-api-2.5.0-b30.jar
Expand Down
2 changes: 1 addition & 1 deletion distribution/server/src/assemble/NOTICE.bin.txt
Expand Up @@ -169,7 +169,7 @@ This product contains a forked and modified version of Tomcat Native
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------


Jetty Web Container Jetty Web Container
Copyright 1995-2016 Mort Bay Consulting Pty Ltd. Copyright 1995-2018 Mort Bay Consulting Pty Ltd.


The Jetty Web Container is Copyright Mort Bay Consulting Pty Ltd The Jetty Web Container is Copyright Mort Bay Consulting Pty Ltd
unless otherwise noted. unless otherwise noted.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -144,7 +144,7 @@ flexible messaging model and an intuitive client API.</description>
<zookeeper.version>3.4.13</zookeeper.version> <zookeeper.version>3.4.13</zookeeper.version>
<netty.version>4.1.22.Final</netty.version> <netty.version>4.1.22.Final</netty.version>
<storm.version>1.0.5</storm.version> <storm.version>1.0.5</storm.version>
<jetty.version>9.3.11.v20160721</jetty.version> <jetty.version>9.4.12.v20180830</jetty.version>
<jersey.version>2.25</jersey.version> <jersey.version>2.25</jersey.version>
<athenz.version>1.7.17</athenz.version> <athenz.version>1.7.17</athenz.version>
<prometheus.version>0.5.0</prometheus.version> <prometheus.version>0.5.0</prometheus.version>
Expand Down
Expand Up @@ -24,8 +24,6 @@
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


import javax.servlet.DispatcherType; import javax.servlet.DispatcherType;


Expand Down Expand Up @@ -59,7 +57,6 @@
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;


import io.netty.util.concurrent.DefaultThreadFactory;
import io.prometheus.client.jetty.JettyStatisticsCollector; import io.prometheus.client.jetty.JettyStatisticsCollector;


/** /**
Expand All @@ -71,19 +68,19 @@ public class WebService implements AutoCloseable {


public static final String ATTRIBUTE_PULSAR_NAME = "pulsar"; public static final String ATTRIBUTE_PULSAR_NAME = "pulsar";
public static final String HANDLER_CACHE_CONTROL = "max-age=3600"; public static final String HANDLER_CACHE_CONTROL = "max-age=3600";
public static final int NUM_ACCEPTORS = 32; // make it configurable?
public static final int MAX_CONCURRENT_REQUESTS = 1024; // make it configurable? public static final int MAX_CONCURRENT_REQUESTS = 1024; // make it configurable?


private final PulsarService pulsar; private final PulsarService pulsar;
private final Server server; private final Server server;
private final List<Handler> handlers; private final List<Handler> handlers;
private final ExecutorService webServiceExecutor; private final ExecutorThreadPool webServiceExecutor;


public WebService(PulsarService pulsar) throws PulsarServerException { public WebService(PulsarService pulsar) throws PulsarServerException {
this.handlers = Lists.newArrayList(); this.handlers = Lists.newArrayList();
this.pulsar = pulsar; this.pulsar = pulsar;
this.webServiceExecutor = Executors.newFixedThreadPool(WebService.NUM_ACCEPTORS, new DefaultThreadFactory("pulsar-web")); this.webServiceExecutor = new ExecutorThreadPool();
this.server = new Server(new ExecutorThreadPool(webServiceExecutor)); this.webServiceExecutor.setName("pulsar-web");
this.server = new Server(webServiceExecutor);
List<ServerConnector> connectors = new ArrayList<>(); List<ServerConnector> connectors = new ArrayList<>();


ServerConnector connector = new PulsarServerConnector(server, 1, 1); ServerConnector connector = new PulsarServerConnector(server, 1, 1);
Expand Down Expand Up @@ -169,22 +166,23 @@ public void start() throws PulsarServerException {
handlers.add(0, new ContextHandlerCollection()); handlers.add(0, new ContextHandlerCollection());
handlers.add(requestLogHandler); handlers.add(requestLogHandler);


ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));

HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });

// Metrics handler // Metrics handler
StatisticsHandler stats = new StatisticsHandler(); StatisticsHandler stats = new StatisticsHandler();
stats.setHandler(server.getHandler()); stats.setHandler(handlerCollection);
try { try {
new JettyStatisticsCollector(stats).register(); new JettyStatisticsCollector(stats).register();
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
// Already registered. Eg: in unit tests // Already registered. Eg: in unit tests
} }
handlers.add(stats); handlers.add(stats);


ContextHandlerCollection contexts = new ContextHandlerCollection(); server.setHandler(stats);
contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));

HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler, stats });
server.setHandler(handlerCollection);


server.start(); server.start();


Expand All @@ -198,7 +196,7 @@ public void start() throws PulsarServerException {
public void close() throws PulsarServerException { public void close() throws PulsarServerException {
try { try {
server.stop(); server.stop();
webServiceExecutor.shutdown(); webServiceExecutor.stop();
log.info("Web service closed"); log.info("Web service closed");
} catch (Exception e) { } catch (Exception e) {
throw new PulsarServerException(e); throw new PulsarServerException(e);
Expand Down
Expand Up @@ -23,10 +23,7 @@
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


import javax.net.ssl.SSLContext;
import javax.servlet.Servlet; import javax.servlet.Servlet;


import org.apache.pulsar.common.util.SecurityUtility; import org.apache.pulsar.common.util.SecurityUtility;
Expand All @@ -48,21 +45,20 @@


import com.google.common.collect.Lists; import com.google.common.collect.Lists;


import io.netty.util.concurrent.DefaultThreadFactory;

/** /**
* Manages web-service startup/stop on jetty server. * Manages web-service startup/stop on jetty server.
* *
*/ */
public class ServerManager { public class ServerManager {
private final Server server; private final Server server;
private final ExecutorService webServiceExecutor; private final ExecutorThreadPool webServiceExecutor;
private final List<Handler> handlers = Lists.newArrayList(); private final List<Handler> handlers = Lists.newArrayList();
protected final int externalServicePort; protected final int externalServicePort;


public ServerManager(ServiceConfig config) { public ServerManager(ServiceConfig config) {
this.webServiceExecutor = Executors.newFixedThreadPool(32, new DefaultThreadFactory("pulsar-external-web")); this.webServiceExecutor = new ExecutorThreadPool();
this.server = new Server(new ExecutorThreadPool(webServiceExecutor)); this.webServiceExecutor.setName("pulsar-external-web");
this.server = new Server(webServiceExecutor);
this.externalServicePort = config.getWebServicePort(); this.externalServicePort = config.getWebServicePort();


List<ServerConnector> connectors = Lists.newArrayList(); List<ServerConnector> connectors = Lists.newArrayList();
Expand Down Expand Up @@ -134,7 +130,7 @@ public void start() throws Exception {


public void stop() throws Exception { public void stop() throws Exception {
server.stop(); server.stop();
webServiceExecutor.shutdown(); webServiceExecutor.stop();
log.info("Server stopped successfully"); log.info("Server stopped successfully");
} }


Expand Down
Expand Up @@ -26,8 +26,6 @@
import javax.servlet.DispatcherType; import javax.servlet.DispatcherType;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.broker.web.AuthenticationFilter; import org.apache.pulsar.broker.web.AuthenticationFilter;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.pulsar.common.util.SecurityUtility; import org.apache.pulsar.common.util.SecurityUtility;
import org.apache.pulsar.functions.worker.WorkerConfig; import org.apache.pulsar.functions.worker.WorkerConfig;
import org.apache.pulsar.functions.worker.WorkerService; import org.apache.pulsar.functions.worker.WorkerService;
Expand Down Expand Up @@ -55,17 +53,14 @@


import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;


import io.netty.util.concurrent.DefaultThreadFactory;

@Slf4j @Slf4j
public class WorkerServer { public class WorkerServer {


private final WorkerConfig workerConfig; private final WorkerConfig workerConfig;
private final WorkerService workerService; private final WorkerService workerService;
private static final String MATCH_ALL = "/*"; private static final String MATCH_ALL = "/*";
private static final int NUM_ACCEPTORS = 16;
private static final int MAX_CONCURRENT_REQUESTS = 1024; private static final int MAX_CONCURRENT_REQUESTS = 1024;
private final ExecutorService webServerExecutor; private final ExecutorThreadPool webServerExecutor;
private Server server; private Server server;


private static String getErrorMessage(Server server, int port, Exception ex) { private static String getErrorMessage(Server server, int port, Exception ex) {
Expand All @@ -80,7 +75,8 @@ private static String getErrorMessage(Server server, int port, Exception ex) {
public WorkerServer(WorkerService workerService) { public WorkerServer(WorkerService workerService) {
this.workerConfig = workerService.getWorkerConfig(); this.workerConfig = workerService.getWorkerConfig();
this.workerService = workerService; this.workerService = workerService;
this.webServerExecutor = Executors.newFixedThreadPool(NUM_ACCEPTORS, new DefaultThreadFactory("function-web")); this.webServerExecutor = new ExecutorThreadPool();
this.webServerExecutor.setName("function-web");
init(); init();
} }


Expand All @@ -90,7 +86,7 @@ public void start() throws Exception {
} }


private void init() { private void init() {
server = new Server(new ExecutorThreadPool(webServerExecutor)); server = new Server(webServerExecutor);


List<ServerConnector> connectors = new ArrayList<>(); List<ServerConnector> connectors = new ArrayList<>();
ServerConnector connector = new ServerConnector(server, 1, 1); ServerConnector connector = new ServerConnector(server, 1, 1);
Expand Down Expand Up @@ -167,8 +163,12 @@ public void stop() {
log.error("Failed to stop function web-server ", e); log.error("Failed to stop function web-server ", e);
} }
} }
if (this.webServerExecutor != null && !this.webServerExecutor.isShutdown()) { if (this.webServerExecutor != null && this.webServerExecutor.isRunning()) {
this.webServerExecutor.shutdown(); try {
this.webServerExecutor.stop();
} catch (Exception e) {
log.warn("Error stopping function web-server executor", e);
}
} }
} }


Expand Down
Expand Up @@ -21,7 +21,6 @@
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;


import io.netty.util.concurrent.DefaultThreadFactory;
import io.prometheus.client.jetty.JettyStatisticsCollector; import io.prometheus.client.jetty.JettyStatisticsCollector;


import java.io.IOException; import java.io.IOException;
Expand All @@ -34,8 +33,6 @@
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


import javax.servlet.DispatcherType; import javax.servlet.DispatcherType;


Expand Down Expand Up @@ -72,7 +69,7 @@ public class WebServer {
private static final String MATCH_ALL = "/*"; private static final String MATCH_ALL = "/*";


private final Server server; private final Server server;
private final ExecutorService webServiceExecutor; private final ExecutorThreadPool webServiceExecutor;
private final AuthenticationService authenticationService; private final AuthenticationService authenticationService;
private final List<String> servletPaths = Lists.newArrayList(); private final List<String> servletPaths = Lists.newArrayList();
private final List<Handler> handlers = Lists.newArrayList(); private final List<Handler> handlers = Lists.newArrayList();
Expand All @@ -81,8 +78,9 @@ public class WebServer {
private URI serviceURI = null; private URI serviceURI = null;


public WebServer(ProxyConfiguration config, AuthenticationService authenticationService) { public WebServer(ProxyConfiguration config, AuthenticationService authenticationService) {
this.webServiceExecutor = Executors.newFixedThreadPool(32, new DefaultThreadFactory("pulsar-external-web")); this.webServiceExecutor = new ExecutorThreadPool();
this.server = new Server(new ExecutorThreadPool(webServiceExecutor)); this.webServiceExecutor.setName("pulsar-external-web");
this.server = new Server(webServiceExecutor);
this.externalServicePort = config.getWebServicePort(); this.externalServicePort = config.getWebServicePort();
this.authenticationService = authenticationService; this.authenticationService = authenticationService;
this.config = config; this.config = config;
Expand Down Expand Up @@ -176,18 +174,19 @@ public void start() throws Exception {
ContextHandlerCollection contexts = new ContextHandlerCollection(); ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(handlers.toArray(new Handler[handlers.size()])); contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));


HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });

// Metrics handler // Metrics handler
StatisticsHandler stats = new StatisticsHandler(); StatisticsHandler stats = new StatisticsHandler();
stats.setHandler(server.getHandler()); stats.setHandler(handlerCollection);
try { try {
new JettyStatisticsCollector(stats).register(); new JettyStatisticsCollector(stats).register();
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
// Already registered. Eg: in unit tests // Already registered. Eg: in unit tests
} }


HandlerCollection handlerCollection = new HandlerCollection(); server.setHandler(stats);
handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler, stats });
server.setHandler(handlerCollection);


try { try {
server.start(); server.start();
Expand Down Expand Up @@ -220,7 +219,7 @@ public void start() throws Exception {


public void stop() throws Exception { public void stop() throws Exception {
server.stop(); server.stop();
webServiceExecutor.shutdown(); webServiceExecutor.stop();
log.info("Server stopped successfully"); log.info("Server stopped successfully");
} }


Expand Down
2 changes: 1 addition & 1 deletion pulsar-sql/presto-distribution/LICENSE
Expand Up @@ -281,7 +281,7 @@ The Apache Software License, Version 2.0
- jetty-server-9.4.11.v20180605.jar - jetty-server-9.4.11.v20180605.jar
- jetty-servlet-9.4.11.v20180605.jar - jetty-servlet-9.4.11.v20180605.jar
- jetty-util-9.4.11.v20180605.jar - jetty-util-9.4.11.v20180605.jar
- jetty-util-9.3.11.v20160721.jar - jetty-util-9.4.12.v20180830.jar
* Javassist * Javassist
- javassist-3.22.0-CR2.jar - javassist-3.22.0-CR2.jar
* Asynchronous Http Client * Asynchronous Http Client
Expand Down
Expand Up @@ -21,15 +21,11 @@
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;


import io.netty.util.concurrent.DefaultThreadFactory;

import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.security.GeneralSecurityException; import java.security.GeneralSecurityException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


import javax.servlet.Servlet; import javax.servlet.Servlet;
import javax.servlet.ServletException; import javax.servlet.ServletException;
Expand Down Expand Up @@ -60,14 +56,14 @@ public class ProxyServer {
private final Server server; private final Server server;
private final List<Handler> handlers = Lists.newArrayList(); private final List<Handler> handlers = Lists.newArrayList();
private final WebSocketProxyConfiguration conf; private final WebSocketProxyConfiguration conf;
private final ExecutorService executorService; private final ExecutorThreadPool executorService;


public ProxyServer(WebSocketProxyConfiguration config) public ProxyServer(WebSocketProxyConfiguration config)
throws PulsarClientException, MalformedURLException, PulsarServerException { throws PulsarClientException, MalformedURLException, PulsarServerException {
this.conf = config; this.conf = config;
executorService = Executors.newFixedThreadPool(WebSocketProxyConfiguration.PROXY_SERVER_EXECUTOR_THREADS, executorService = new ExecutorThreadPool();
new DefaultThreadFactory("pulsar-websocket-web")); executorService.setName("pulsar-websocket-web");
this.server = new Server(new ExecutorThreadPool(executorService)); this.server = new Server(executorService);
List<ServerConnector> connectors = new ArrayList<>(); List<ServerConnector> connectors = new ArrayList<>();


ServerConnector connector = new ServerConnector(server); ServerConnector connector = new ServerConnector(server);
Expand Down Expand Up @@ -150,7 +146,7 @@ public void start() throws PulsarServerException {


public void stop() throws Exception { public void stop() throws Exception {
server.stop(); server.stop();
executorService.shutdown(); executorService.stop();
} }


private static final Logger log = LoggerFactory.getLogger(ProxyServer.class); private static final Logger log = LoggerFactory.getLogger(ProxyServer.class);
Expand Down

0 comments on commit b73a967

Please sign in to comment.