Merge maxConnections and pollerSize for the APR connectors.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 5 May 2011 15:42:59 +0000 (15:42 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 5 May 2011 15:42:59 +0000 (15:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1099850 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/ajp/AjpAprProtocol.java
java/org/apache/coyote/http11/Http11AprProtocol.java
java/org/apache/tomcat/util/net/AprEndpoint.java
webapps/docs/changelog.xml
webapps/docs/config/http.xml

index 68facef..e056fee 100644 (file)
@@ -94,8 +94,9 @@ public class AjpAprProtocol extends AbstractAjpProtocol {
     public int getPollTime() { return ((AprEndpoint)endpoint).getPollTime(); }
     public void setPollTime(int pollTime) { ((AprEndpoint)endpoint).setPollTime(pollTime); }
 
-    public void setPollerSize(int pollerSize) { ((AprEndpoint)endpoint).setPollerSize(pollerSize); }
-    public int getPollerSize() { return ((AprEndpoint)endpoint).getPollerSize(); }
+    // pollerSize is now a synonym for maxConnections
+    public void setPollerSize(int pollerSize) { endpoint.setMaxConnections(pollerSize); }
+    public int getPollerSize() { return endpoint.getMaxConnections(); }
 
 
     // ----------------------------------------------------- JMX related methods
index 93a18d2..3fa7a56 100644 (file)
@@ -86,8 +86,8 @@ public class Http11AprProtocol extends AbstractHttp11Protocol {
     public int getPollTime() { return ((AprEndpoint)endpoint).getPollTime(); }
     public void setPollTime(int pollTime) { ((AprEndpoint)endpoint).setPollTime(pollTime); }
 
-    public void setPollerSize(int pollerSize) { ((AprEndpoint)endpoint).setPollerSize(pollerSize); }
-    public int getPollerSize() { return ((AprEndpoint)endpoint).getPollerSize(); }
+    public void setPollerSize(int pollerSize) { endpoint.setMaxConnections(pollerSize); }
+    public int getPollerSize() { return endpoint.getMaxConnections(); }
 
     public void setPollerThreadCount(int pollerThreadCount) { ((AprEndpoint)endpoint).setPollerThreadCount(pollerThreadCount); }
     public int getPollerThreadCount() { return ((AprEndpoint)endpoint).getPollerThreadCount(); }
index e26a938..5b806e4 100644 (file)
@@ -99,6 +99,14 @@ public class AprEndpoint extends AbstractEndpoint {
     protected ConcurrentLinkedQueue<SocketWrapper<Long>> waitingRequests =
         new ConcurrentLinkedQueue<SocketWrapper<Long>>();
 
+    // ------------------------------------------------------------ Constructor
+
+    public AprEndpoint() {
+        // Need to override the default for maxConnections to align it with what
+        // was pollerSize (before the two were merged)
+        setMaxConnections(8 * 1024);
+    }
+
     // ------------------------------------------------------------- Properties
 
 
@@ -112,14 +120,6 @@ public class AprEndpoint extends AbstractEndpoint {
 
 
     /**
-     * Size of the socket poller.
-     */
-    protected int pollerSize = 8 * 1024;
-    public void setPollerSize(int pollerSize) { this.pollerSize = pollerSize; }
-    public int getPollerSize() { return pollerSize; }
-
-
-    /**
      * Size of the sendfile (= concurrent files which can be served).
      */
     protected int sendfileSize = 1 * 1024;
@@ -428,11 +428,12 @@ public class AprEndpoint extends AbstractEndpoint {
             acceptorThreadCount = 1;
         }
         if (pollerThreadCount == 0) {
-            if ((OS.IS_WIN32 || OS.IS_WIN64) && (pollerSize > 1024)) {
+            if ((OS.IS_WIN32 || OS.IS_WIN64) && (getMaxConnections() > 1024)) {
                 // The maximum per poller to get reasonable performance is 1024
-                pollerThreadCount = pollerSize / 1024;
+                pollerThreadCount = getMaxConnections() / 1024;
                 // Adjust poller size so that it won't reach the limit
-                pollerSize = pollerSize - (pollerSize % 1024);
+                setMaxConnections(
+                        getMaxConnections() - (getMaxConnections() % 1024));
             } else {
                 // No explicit poller size limitation
                 pollerThreadCount = 1;
@@ -1083,7 +1084,7 @@ public class AprEndpoint extends AbstractEndpoint {
          */
         protected void init() {
             pool = Pool.create(serverSockPool);
-            int size = pollerSize / pollerThreadCount;
+            int size = getMaxConnections() / pollerThreadCount;
             int timeout = getKeepAliveTimeout();
             if (timeout <= 0) {
                 timeout = socketProperties.getSoTimeout();
index 6a93172..9151cc7 100644 (file)
         connector once 75% of the processing threads are in use and make the
         threshold configurable. (markt)
       </fix>
+      <fix>
+        Make pollerSize and maxConnections synonyms for the APR connectors since
+        they perform the same function. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">
index 483f104..4254071 100644 (file)
       <strong>connectionTimeout</strong> attribute.</p>
     </attribute>
 
+    <attribute name="maxConnections" required="false">
+      <p>The maximum number of connections that the server will accept and
+      process at any given time. When this number has been reached, the server
+      will not accept any more connections until the number of connections
+      falls below this value. The operating system may still accept
+      connections based on the <code>acceptCount</code> setting. Default value
+      varies by connector type. For BIO and NIO the default is
+      <code>10000</code>. For APR/native, the default is <code>8192</code>.</p>
+      <p>Note that for APR/native on Windows, the configured value will be
+      reduced to the highest multiple of 1024 that is less than or equal to
+      maxConnections. This is done for performance reasons.</p>
+    </attribute>
+
     <attribute name="maxHttpHeaderSize" required="false">
       <p>The maximum size of the request and response HTTP header, specified
       in bytes. If not specified, this attribute is set to 8192 (8 KB).</p>
         the default value is <code>75</code>.</p>
       </attribute>
 
-      <attribute name="maxConnections" required="false">
-        <p>The maximum number of connections that the server will accept and
-        process at any given time. When this number has been reached, the server
-        will not accept any more connections until the number of connections
-        falls below this value. The operating system may still accept
-        connections based on the <code>acceptCount</code> setting. Default value
-        is <code>10000</code>.</p>
-      </attribute>
-
     </attributes>
 
   </subsection>
         <p>Amount of sockets that the poller responsible for polling kept alive
         connections can hold at a given time. Extra connections will be closed
         right away. The default value is 8192, corresponding to 8192 keep-alive
-        connections.</p>
+        connections. This is a synonym for maxConnections.</p>
       </attribute>
 
       <attribute name="pollerThreadCount" required="false">