You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2015/11/19 22:54:19 UTC

svn commit: r1715292 - in /felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal: ConfigMetaTypeProvider.java JettyConfig.java JettyService.java

Author: cziegeler
Date: Thu Nov 19 21:54:18 2015
New Revision: 1715292

URL: http://svn.apache.org/viewvc?rev=1715292&view=rev
Log: (empty)

Modified:
    felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java
    felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
    felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java

Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java?rev=1715292&r1=1715291&r2=1715292&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java (original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java Thu Nov 19 21:54:18 2015
@@ -155,6 +155,24 @@ class ConfigMetaTypeProvider implements
                 0,
                 bundle.getBundleContext().getProperty(JettyConfig.FELIX_SESSION_TIMEOUT)));
 
+        adList.add(new AttributeDefinitionImpl(JettyConfig.FELIX_JETTY_THREADPOOL_MAX,
+                "Thread Pool Max",
+                "Maximum number of jetty threads. Using the default -1 uses Jetty's default (200).",
+                -1,
+                bundle.getBundleContext().getProperty(JettyConfig.FELIX_JETTY_THREADPOOL_MAX)));
+
+        adList.add(new AttributeDefinitionImpl(JettyConfig.FELIX_JETTY_ACCEPTORS,
+                "Acceptors",
+                "Number of acceptor threads to use, or -1 for a default value. Acceptors accept new TCP/IP connections. If 0, then the selector threads are used to accept connections.",
+                -1,
+                bundle.getBundleContext().getProperty(JettyConfig.FELIX_JETTY_ACCEPTORS)));
+
+        adList.add(new AttributeDefinitionImpl(JettyConfig.FELIX_JETTY_SELECTORS,
+                "Selectors",
+                "Number of selector threads, or <=0 for a default value. Selectors notice and schedule established connection that can make IO progress.",
+                -1,
+                bundle.getBundleContext().getProperty(JettyConfig.FELIX_JETTY_SELECTORS)));
+
         adList.add(new AttributeDefinitionImpl(JettyConfig.FELIX_JETTY_HEADER_BUFFER_SIZE,
                 "Header Buffer Size",
                 "Size of the buffer for request and response headers. Default is 16KB.",

Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java?rev=1715292&r1=1715291&r2=1715292&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java (original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java Thu Nov 19 21:54:18 2015
@@ -85,6 +85,15 @@ public final class JettyConfig
     /** Felix specific property to configure the session timeout in minutes (same session-timout in web.xml). Default is servlet container specific */
     public static final String FELIX_SESSION_TIMEOUT = "org.apache.felix.http.session.timeout";
 
+    /** Felix specific property to control the maximum size of the jetty thread pool */
+    public static final String FELIX_JETTY_THREADPOOL_MAX = "org.apache.felix.http.jetty.threadpool.max";
+
+    /** Felix specific property to control the number of jetty acceptor threads */
+    public static final String FELIX_JETTY_ACCEPTORS = "org.apache.felix.http.jetty.acceptors";
+
+    /** Felix specific property to control the number of jetty selector threads */
+    public static final String FELIX_JETTY_SELECTORS = "org.apache.felix.http.jetty.selectors";
+
     /** Felix specific property to configure the request buffer size. Default is 16KB (instead of Jetty's default of 4KB) */
     public static final String FELIX_JETTY_HEADER_BUFFER_SIZE = "org.apache.felix.http.jetty.headerBufferSize";
 
@@ -295,6 +304,21 @@ public final class JettyConfig
         return value != null ? String.valueOf(value) : defValue;
     }
 
+    public int getThreadPoolMax()
+    {
+        return getIntProperty(FELIX_JETTY_THREADPOOL_MAX, -1);
+    }
+
+    public int getAcceptors()
+    {
+        return getIntProperty(FELIX_JETTY_ACCEPTORS, -1);
+    }
+
+    public int getSelectors()
+    {
+        return getIntProperty(FELIX_JETTY_SELECTORS, -1);
+    }
+
     public int getRequestBufferSize()
     {
         return getIntProperty(FELIX_JETTY_REQUEST_BUFFER_SIZE, 8 * 1024);

Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java?rev=1715292&r1=1715291&r2=1715292&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java (original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java Thu Nov 19 21:54:18 2015
@@ -62,6 +62,8 @@ import org.eclipse.jetty.servlet.Servlet
 import org.eclipse.jetty.util.component.AbstractLifeCycle;
 import org.eclipse.jetty.util.component.LifeCycle;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
+import org.eclipse.jetty.util.thread.ThreadPool;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
@@ -240,7 +242,13 @@ public final class JettyService extends
         if (this.config.isUseHttp() || this.config.isUseHttps())
         {
             final String version = fixJettyVersion();
-            this.server = new Server();
+
+            final int threadPoolMax = this.config.getThreadPoolMax();
+            if (threadPoolMax >= 0) {
+                this.server = new Server( new QueuedThreadPool(threadPoolMax) );
+            } else {
+                this.server = new Server();
+            }
             this.server.addLifeCycleListener(this);
 
             this.server.addBean(new HashLoginService("OSGi HTTP Service Realm"));
@@ -286,6 +294,22 @@ public final class JettyService extends
             if (this.server.getConnectors() != null && this.server.getConnectors().length > 0)
             {
                 message.append(" on context path ").append(this.config.getContextPath());
+
+                message.append(" [");
+                ThreadPool threadPool = this.server.getThreadPool();
+                if (threadPool instanceof ThreadPool.SizedThreadPool) {
+                    ThreadPool.SizedThreadPool sizedThreadPool = (ThreadPool.SizedThreadPool) threadPool;
+                    message.append("minThreads=").append(sizedThreadPool.getMinThreads()).append(",");
+                    message.append("maxThreads=").append(sizedThreadPool.getMaxThreads()).append(",");
+                }
+                Connector connector = this.server.getConnectors()[0];
+                if (connector instanceof ServerConnector) {
+                    ServerConnector serverConnector = (ServerConnector) connector;
+                    message.append("acceptors=").append(serverConnector.getAcceptors()).append(",");
+                    message.append("selectors=").append(serverConnector.getSelectorManager().getSelectorCount());
+                }
+                message.append("]");
+
                 SystemLogger.info(message.toString());
                 publishServiceProperties();
             }
@@ -321,7 +345,14 @@ public final class JettyService extends
     {
         HttpConnectionFactory connFactory = new HttpConnectionFactory();
         configureHttpConnectionFactory(connFactory);
-        ServerConnector connector = new ServerConnector(server, connFactory);
+
+        ServerConnector connector = new ServerConnector(
+            server,
+            config.getAcceptors(),
+            config.getSelectors(),
+            connFactory
+        );
+
         configureConnector(connector, this.config.getHttpPort());
 
         if (this.config.isProxyLoadBalancerConnection())
@@ -340,7 +371,14 @@ public final class JettyService extends
         SslContextFactory sslContextFactory = new SslContextFactory();
         configureSslContextFactory(sslContextFactory);
 
-        ServerConnector connector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.toString()), connFactory);
+        ServerConnector connector = new ServerConnector(
+            server,
+            config.getAcceptors(),
+            config.getSelectors(),
+            new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.toString()),
+            connFactory
+        );
+
         HttpConfiguration httpConfiguration = connFactory.getHttpConfiguration();
         httpConfiguration.addCustomizer(new SecureRequestCustomizer());