diff options
author | Martin Domig | 2015-07-30 16:40:06 +0000 |
---|---|---|
committer | Thomas Watson | 2015-07-30 16:40:06 +0000 |
commit | f5c7f2e557be1127862111282aca47e356c8174c (patch) | |
tree | 6930e68d957590a80607c247570672dfa984f498 /bundles/org.eclipse.equinox.http.jetty9 | |
parent | 340ebc87b394a075fa8920d00255f69b1ed6e4ab (diff) | |
download | rt.equinox.bundles-f5c7f2e557be1127862111282aca47e356c8174c.tar.gz rt.equinox.bundles-f5c7f2e557be1127862111282aca47e356c8174c.tar.xz rt.equinox.bundles-f5c7f2e557be1127862111282aca47e356c8174c.zip |
Bug 473606 - HttpConfiguration minThreads and maxThreads
Signed-off-by: Martin Domig <martin@domig.net>
Diffstat (limited to 'bundles/org.eclipse.equinox.http.jetty9')
7 files changed, 86 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.http.jetty9/.settings/.api_filters b/bundles/org.eclipse.equinox.http.jetty9/.settings/.api_filters new file mode 100644 index 000000000..2cf99fd43 --- /dev/null +++ b/bundles/org.eclipse.equinox.http.jetty9/.settings/.api_filters @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<component id="org.eclipse.equinox.http.jetty9" version="2">
+ <resource path="src/org/eclipse/equinox/http/jetty/JettyConstants.java" type="org.eclipse.equinox.http.jetty.JettyConstants">
+ <filter comment="Use package version" id="1209008130">
+ <message_arguments>
+ <message_argument value="1.2"/>
+ <message_argument value="3.2"/>
+ <message_argument value="HTTP_MAXTHREADS"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Use package version" id="1209008130">
+ <message_arguments>
+ <message_argument value="1.2"/>
+ <message_argument value="3.2"/>
+ <message_argument value="HTTP_MINTHREADS"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
diff --git a/bundles/org.eclipse.equinox.http.jetty9/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.http.jetty9/META-INF/MANIFEST.MF index 27baf9ea1..bf875565a 100644 --- a/bundles/org.eclipse.equinox.http.jetty9/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.http.jetty9/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: %bundleName Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.equinox.http.jetty -Bundle-Version: 3.1.100.qualifier +Bundle-Version: 3.2.0.qualifier Bundle-Activator: org.eclipse.equinox.http.jetty.internal.Activator Import-Package: javax.servlet;version="[2.6.0,4.0.0)", javax.servlet.http;version="[2.6.0,4.0.0)", @@ -19,11 +19,12 @@ Import-Package: javax.servlet;version="[2.6.0,4.0.0)", org.eclipse.jetty.util.component;version="[9.0.0,10.0.0)", org.eclipse.jetty.util.log;version="[9.0.0,10.0.0)", org.eclipse.jetty.util.ssl;version="[9.0.0,10.0.0)", + org.eclipse.jetty.util.thread;version="[9.0.0,10.0.0)", org.osgi.framework;version="1.3.0", org.osgi.service.cm;version="1.2.0", org.osgi.service.startlevel;version="1.0" Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Export-Package: org.eclipse.equinox.http.jetty;version="1.1.0" +Export-Package: org.eclipse.equinox.http.jetty;version="1.2.0" Comment-Header: Both Eclipse-LazyStart and Bundle-ActivationPolicy are specified for compatibility with 3.2 Eclipse-LazyStart: true Bundle-ActivationPolicy: lazy diff --git a/bundles/org.eclipse.equinox.http.jetty9/OSGI-INF/metatype/config.xml b/bundles/org.eclipse.equinox.http.jetty9/OSGI-INF/metatype/config.xml index cb766a9d7..61b1fb3be 100644 --- a/bundles/org.eclipse.equinox.http.jetty9/OSGI-INF/metatype/config.xml +++ b/bundles/org.eclipse.equinox.http.jetty9/OSGI-INF/metatype/config.xml @@ -5,6 +5,8 @@ <AD id="http.port" type="Integer" default="0"/> <AD id="http.host" type="String" cardinality="1"/> <AD id="http.nio" type="Boolean" default="true"/> + <AD id="http.minThreads" type="Integer" default="8"/> + <AD id="http.maxThreads" type="Integer" default="200"/> <AD id="https.enabled" type="Boolean" default="false"/> <AD id="https.port" type="Integer" default="0"/> <AD id="https.host" type="String" cardinality="1"/> diff --git a/bundles/org.eclipse.equinox.http.jetty9/pom.xml b/bundles/org.eclipse.equinox.http.jetty9/pom.xml index 5dc827a45..ab1e250a8 100644 --- a/bundles/org.eclipse.equinox.http.jetty9/pom.xml +++ b/bundles/org.eclipse.equinox.http.jetty9/pom.xml @@ -20,6 +20,6 @@ </parent> <groupId>org.eclipse.equinox</groupId> <artifactId>org.eclipse.equinox.http.jetty</artifactId> - <version>3.1.100-SNAPSHOT</version> + <version>3.2.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/JettyConstants.java b/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/JettyConstants.java index 36c78b140..1f18c5d0d 100644 --- a/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/JettyConstants.java +++ b/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/JettyConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 IBM Corporation and others. + * Copyright (c) 2007, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -57,6 +57,18 @@ public interface JettyConstants { public static final String HTTPS_PORT = "https.port"; //$NON-NLS-1$ /** + * name="http.maxThreads" type="Integer" (default: 200 -- max number of threads) + * @since 1.2 + */ + public static final String HTTP_MAXTHREADS = "http.maxThreads"; //$NON-NLS-1$ + + /** + * name="http.maxThreads" type="Integer" (default: 8 -- max number of threads) + * @since 1.2 + */ + public static final String HTTP_MINTHREADS = "http.minThreads"; //$NON-NLS-1$ + + /** * name="ssl.keystore" type="String" */ public static final String SSL_KEYSTORE = "ssl.keystore"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/internal/Activator.java b/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/internal/Activator.java index 76a9473e2..ef142d7f2 100644 --- a/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/internal/Activator.java +++ b/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/internal/Activator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2011 Cognos Incorporated, IBM Corporation and others. + * Copyright (c) 2005, 2015 Cognos Incorporated, IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -135,6 +135,28 @@ public class Activator implements BundleActivator { Boolean httpsEnabled = Boolean.valueOf(context.getProperty(PROPERTY_PREFIX + JettyConstants.HTTPS_ENABLED)); defaultSettings.put(JettyConstants.HTTPS_ENABLED, httpsEnabled); + // minimum number of threads + String minThreadsProperty = context.getProperty(PROPERTY_PREFIX + JettyConstants.HTTP_MINTHREADS); + if (minThreadsProperty != null) { + try { + int minThreads = Integer.parseInt(minThreadsProperty); + defaultSettings.put(JettyConstants.HTTP_MINTHREADS, new Integer(minThreads)); + } catch (NumberFormatException e) { + //(log this) ignore and use default + } + } + + // maximum number of threads + String maxThreadsProperty = context.getProperty(PROPERTY_PREFIX + JettyConstants.HTTP_MAXTHREADS); + if (maxThreadsProperty != null) { + try { + int maxThreads = Integer.parseInt(maxThreadsProperty); + defaultSettings.put(JettyConstants.HTTP_MAXTHREADS, new Integer(maxThreads)); + } catch (NumberFormatException e) { + //(log this) ignore and use default + } + } + if (httpsEnabled.booleanValue()) { // HTTPS Port String httpsPortProperty = context.getProperty(PROPERTY_PREFIX + JettyConstants.HTTPS_PORT); diff --git a/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java b/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java index 542d2ef17..358d27547 100644 --- a/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java +++ b/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2013 IBM Corporation and others. + * Copyright (c) 2007, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,6 +29,7 @@ import org.eclipse.jetty.server.session.SessionHandler; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.osgi.framework.Constants; import org.osgi.service.cm.ConfigurationException; import org.osgi.service.cm.ManagedServiceFactory; @@ -68,7 +69,7 @@ public class HttpServerManager implements ManagedServiceFactory { @SuppressWarnings("unchecked") public synchronized void updated(String pid, @SuppressWarnings("rawtypes") Dictionary dictionary) throws ConfigurationException { deleted(pid); - Server server = new Server(); + Server server = new Server(new QueuedThreadPool(getMaxThreads(dictionary), getMinThreads(dictionary))); JettyCustomizer customizer = createJettyCustomizer(dictionary); @@ -263,6 +264,28 @@ public class HttpServerManager implements ManagedServiceFactory { return httpsEnabled; } + private int getMaxThreads(@SuppressWarnings("rawtypes") Dictionary dictionary) { + Integer maxThreads = 200; + Object maxThreadsObj = dictionary.get(JettyConstants.HTTP_MAXTHREADS); + if (maxThreadsObj instanceof Integer) { + maxThreads = (Integer) maxThreadsObj; + } else if (maxThreadsObj instanceof String) { + maxThreads = Integer.parseInt(maxThreadsObj.toString()); + } + return maxThreads; + } + + private int getMinThreads(@SuppressWarnings("rawtypes") Dictionary dictionary) { + Integer minThreads = 8; + Object minThreadsObj = dictionary.get(JettyConstants.HTTP_MINTHREADS); + if (minThreadsObj instanceof Integer) { + minThreads = (Integer) minThreadsObj; + } else if (minThreadsObj instanceof String) { + minThreads = Integer.parseInt(minThreadsObj.toString()); + } + return minThreads; + } + private ServletContextHandler createHttpContext(@SuppressWarnings("rawtypes") Dictionary dictionary) { ServletContextHandler httpContext = new ServletContextHandler(); // hack in the mime type for xsd until jetty fixes it (bug 393218) |