diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpClientTransportOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpClientTransportOverHTTP.java index 2e491cfe4dd..2f752ff8180 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpClientTransportOverHTTP.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpClientTransportOverHTTP.java @@ -27,7 +27,7 @@ public class HttpClientTransportOverHTTP extends AbstractHttpClientTransport { public HttpClientTransportOverHTTP() { - this(1); + this(Runtime.getRuntime().availableProcessors()); } public HttpClientTransportOverHTTP(int selectors) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java index 6c64f6dc9b8..97195afe488 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java @@ -424,7 +424,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa String name = _thread.getName(); try { - _thread.setName(name + "-selector-" + _id); + _thread.setName(name + "-selector-" + SelectorManager.this.getClass().getSimpleName()+"@"+Integer.toHexString(SelectorManager.this.hashCode())+"/"+_id); LOG.debug("Starting {} on {}", _thread, this); while (isRunning()) select(); diff --git a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ConnectHandler.java b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ConnectHandler.java index 2e0760f4bd5..b1b6b3b76fe 100644 --- a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ConnectHandler.java +++ b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ConnectHandler.java @@ -177,7 +177,7 @@ public class ConnectHandler extends HandlerWrapper protected SelectorManager newSelectorManager() { - return new Manager(getExecutor(), getScheduler(), 1); + return new ConnectManager(getExecutor(), getScheduler(), 1); } @Override @@ -429,10 +429,10 @@ public class ConnectHandler extends HandlerWrapper dump(out, indent, getBeans(), TypeUtil.asList(getHandlers())); } - protected class Manager extends SelectorManager + protected class ConnectManager extends SelectorManager { - private Manager(Executor executor, Scheduler scheduler, int selectors) + private ConnectManager(Executor executor, Scheduler scheduler, int selectors) { super(executor, scheduler, selectors); } diff --git a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyServlet.java b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyServlet.java index a283b0d6406..3c6ab64263e 100644 --- a/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyServlet.java +++ b/jetty-proxy/src/main/java/org/eclipse/jetty/proxy/ProxyServlet.java @@ -28,8 +28,10 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Locale; import java.util.Set; +import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; + import javax.servlet.AsyncContext; import javax.servlet.ServletConfig; import javax.servlet.ServletException; @@ -47,7 +49,6 @@ import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpVersion; -import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.util.HttpCookieStore; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -206,7 +207,8 @@ public class ProxyServlet extends HttpServlet * * maxThreads * 256 - * The max number of threads of HttpClient's Executor + * The max number of threads of HttpClient's Executor. If not set, or set to the value of "-", then the + * Jetty server thread pool will be used. * * * maxConnections @@ -244,21 +246,30 @@ public class ProxyServlet extends HttpServlet ServletConfig config = getServletConfig(); HttpClient client = newHttpClient(); + // Redirects must be proxied as is, not followed client.setFollowRedirects(false); // Must not store cookies, otherwise cookies of different clients will mix client.setCookieStore(new HttpCookieStore.Empty()); + Executor executor; String value = config.getInitParameter("maxThreads"); - if (value == null) - value = "256"; - QueuedThreadPool executor = new QueuedThreadPool(Integer.parseInt(value)); - String servletName = config.getServletName(); - int dot = servletName.lastIndexOf('.'); - if (dot >= 0) - servletName = servletName.substring(dot + 1); - executor.setName(servletName); + if (value == null || "-".equals(value)) + { + executor = (Executor)getServletContext().getAttribute("org.eclipse.jetty.server.Executor"); + } + else + { + QueuedThreadPool qtp= new QueuedThreadPool(Integer.parseInt(value)); + String servletName = config.getServletName(); + int dot = servletName.lastIndexOf('.'); + if (dot >= 0) + servletName = servletName.substring(dot + 1); + qtp.setName(servletName); + executor=qtp; + } + client.setExecutor(executor); value = config.getInitParameter("maxConnections"); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java index 6b430011b3c..d932adab910 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java @@ -97,6 +97,8 @@ import org.eclipse.jetty.util.resource.Resource; *

* The maximum size of a form that can be processed by this context is controlled by the system properties org.eclipse.jetty.server.Request.maxFormKeys * and org.eclipse.jetty.server.Request.maxFormContentSize. These can also be configured with {@link #setMaxFormContentSize(int)} and {@link #setMaxFormKeys(int)} + *

+ * This servers executore is made available via a context attributed "org.eclipse.jetty.server.Executor". * * @org.apache.xbean.XBean description="Creates a basic HTTP context" */ @@ -719,6 +721,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu Thread current_thread = null; Context old_context = null; + _attributes.setAttribute("org.eclipse.jetty.server.Executor",getServer().getThreadPool()); + try { // Set the classloader