Commit 5c2f873f authored by daryl herzmann's avatar daryl herzmann

Merge pull request #135 from tevans/OF-857

OF-857: Improve thread pool management
parents 56b2d7b5 3032cc84
......@@ -97,10 +97,13 @@ public class AdminConsolePlugin implements Plugin {
certificateListener = new CertificateListener();
CertificateManager.addListener(certificateListener);
// the number of threads allocated to each connector/port
int serverThreads = JiveGlobals.getXMLProperty("adminConsole.serverThreads", 2);
adminPort = JiveGlobals.getXMLProperty("adminConsole.port", 9090);
adminSecurePort = JiveGlobals.getXMLProperty("adminConsole.securePort", 9091);
final QueuedThreadPool tp = new QueuedThreadPool(16,2);
final QueuedThreadPool tp = new QueuedThreadPool();
tp.setName("Jetty-QTP-AdminConsole");
adminServer = new Server(tp);
......@@ -118,9 +121,10 @@ public class AdminConsolePlugin implements Plugin {
if (adminPort > 0) {
httpConfig = new HttpConfiguration();
httpConnector = new ServerConnector(adminServer, -1, serverThreads);
// Do not send Jetty info in HTTP headers
httpConfig.setSendServerVersion( false );
httpConnector = new ServerConnector(adminServer, new HttpConnectionFactory(httpConfig));
httpConnector.addConnectionFactory(new HttpConnectionFactory(httpConfig));
// Listen on a specific network interface if it has been set.
String bindInterface = getBindInterface();
httpConnector.setHost(bindInterface);
......@@ -161,7 +165,9 @@ public class AdminConsolePlugin implements Plugin {
HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(httpsConfig);
SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, org.eclipse.jetty.http.HttpVersion.HTTP_1_1.toString());
httpsConnector = new ServerConnector(adminServer, sslConnectionFactory, httpConnectionFactory);
httpsConnector = new ServerConnector(adminServer, -1, serverThreads);
httpsConnector.addConnectionFactory(sslConnectionFactory);
httpsConnector.addConnectionFactory(httpConnectionFactory);
}
String bindInterface = getBindInterface();
......@@ -192,7 +198,7 @@ public class AdminConsolePlugin implements Plugin {
adminServer.start();
}
catch (Exception e) {
Log.error("Could not start admin conosle server", e);
Log.error("Could not start admin console server", e);
}
// Log the ports that the admin server is listening on.
......
......@@ -77,7 +77,7 @@ public final class HttpBindManager {
public static final String HTTP_BIND_THREADS = "httpbind.client.processing.threads";
public static final int HTTP_BIND_THREADS_DEFAULT = 16;
public static final int HTTP_BIND_THREADS_DEFAULT = 8;
private static final String HTTP_BIND_FORWARDED = "httpbind.forwarded.enabled";
......@@ -195,12 +195,13 @@ public final class HttpBindManager {
return JiveGlobals.getBooleanProperty(HTTP_BIND_ENABLED, HTTP_BIND_ENABLED_DEFAULT);
}
private void createConnector(int port) {
private void createConnector(int port, int bindThreads) {
httpConnector = null;
if (port > 0) {
HttpConfiguration httpConfig = new HttpConfiguration();
configureProxiedConnector(httpConfig);
ServerConnector connector = new ServerConnector(httpBindServer, new HttpConnectionFactory(httpConfig));
ServerConnector connector = new ServerConnector(httpBindServer, -1, bindThreads);
connector.addConnectionFactory(new HttpConnectionFactory(httpConfig));
// Listen on a specific network interface if it has been set.
connector.setHost(getBindInterface());
......@@ -209,7 +210,7 @@ public final class HttpBindManager {
}
}
private void createSSLConnector(int securePort) {
private void createSSLConnector(int securePort, int bindThreads) {
httpsConnector = null;
try {
if (securePort > 0 && CertificateManager.isRSACertificate(SSLConfig.getKeyStore(), "*")) {
......@@ -252,8 +253,9 @@ public final class HttpBindManager {
sslConnector = new HTTPSPDYServerConnector(httpBindServer, sslContextFactory);
} else {
sslConnector = new ServerConnector(httpBindServer, new SslConnectionFactory(sslContextFactory, "http/1.1"),
new HttpConnectionFactory(httpsConfig));
sslConnector = new ServerConnector(httpBindServer, -1, bindThreads);
sslConnector.addConnectionFactory(new SslConnectionFactory(sslContextFactory, "http/1.1"));
sslConnector.addConnectionFactory(new HttpConnectionFactory(httpsConfig));
}
sslConnector.setHost(getBindInterface());
sslConnector.setPort(securePort);
......@@ -512,8 +514,10 @@ public final class HttpBindManager {
* @param securePort the port to start the TLS (secure) HTTP Bind service on.
*/
private synchronized void configureHttpBindServer(int port, int securePort) {
int maxThreads = JiveGlobals.getIntProperty(HTTP_BIND_THREADS, HTTP_BIND_THREADS_DEFAULT);
final QueuedThreadPool tp = new QueuedThreadPool(maxThreads, getMinThreads(maxThreads));
// this is the number of threads allocated to each connector/port
int bindThreads = JiveGlobals.getIntProperty(HTTP_BIND_THREADS, HTTP_BIND_THREADS_DEFAULT);
final QueuedThreadPool tp = new QueuedThreadPool();
tp.setName("Jetty-QTP-BOSH");
httpBindServer = new Server(tp);
......@@ -522,8 +526,8 @@ public final class HttpBindManager {
httpBindServer.addBean(jmx.getContainer());
}
createConnector(port);
createSSLConnector(securePort);
createConnector(port, bindThreads);
createSSLConnector(securePort, bindThreads);
if (httpConnector == null && httpsConnector == null) {
httpBindServer = null;
return;
......@@ -544,10 +548,6 @@ public final class HttpBindManager {
collection.setHandlers(new Handler[] { contexts, new DefaultHandler() });
}
private int getMinThreads(int maxThreads) {
return (maxThreads/4)+1;
}
private void createBoshHandler(ContextHandlerCollection contexts, String boshPath)
{
ServletContextHandler context = new ServletContextHandler(contexts, boshPath, ServletContextHandler.SESSIONS);
......
......@@ -88,7 +88,7 @@ public class HttpSessionManager {
int maxPoolSize = JiveGlobals.getIntProperty("xmpp.httpbind.worker.threads",
// use deprecated property as default (shared with ConnectionManagerImpl)
JiveGlobals.getIntProperty("xmpp.client.processing.threads", 16));
JiveGlobals.getIntProperty("xmpp.client.processing.threads", 8));
int keepAlive = JiveGlobals.getIntProperty("xmpp.httpbind.worker.timeout", 60);
sendPacketPool = new ThreadPoolExecutor(getCorePoolSize(maxPoolSize), maxPoolSize, keepAlive, TimeUnit.SECONDS,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment