This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 204f0fe75d Add task queue size configuration on the Connector element
204f0fe75d is described below

commit 204f0fe75d1bdae7a071ac2a49ecd42fc033afe6
Author: remm <r...@apache.org>
AuthorDate: Wed Jun 12 11:52:34 2024 +0200

    Add task queue size configuration on the Connector element
    
    BZ 69133
---
 java/org/apache/coyote/AbstractProtocol.java          |  8 ++++++++
 java/org/apache/tomcat/util/net/AbstractEndpoint.java | 18 +++++++++++++++++-
 webapps/docs/changelog.xml                            |  5 +++++
 webapps/docs/config/http.xml                          | 18 ++++++++++++++++++
 4 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/coyote/AbstractProtocol.java 
b/java/org/apache/coyote/AbstractProtocol.java
index 878718938e..f8f35876b7 100644
--- a/java/org/apache/coyote/AbstractProtocol.java
+++ b/java/org/apache/coyote/AbstractProtocol.java
@@ -275,6 +275,14 @@ public abstract class AbstractProtocol<S> implements 
ProtocolHandler, MBeanRegis
     }
 
 
+    public int getMaxQueueSize() {
+        return endpoint.getMaxQueueSize();
+    }
+
+    public void setMaxQueueSize(int maxQueueSize) {
+        endpoint.setMaxQueueSize(maxQueueSize);
+    }
+
     public int getAcceptCount() {
         return endpoint.getAcceptCount();
     }
diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 4da1e460cb..76dbf09d42 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -980,6 +980,22 @@ public abstract class AbstractEndpoint<S,U> {
     }
 
 
+    /**
+     * Task queue capacity for the thread pool.
+     */
+    private int maxQueueSize = Integer.MAX_VALUE;
+    public void setMaxQueueSize(int maxQueueSize) {
+        this.maxQueueSize = maxQueueSize;
+    }
+    public int getMaxQueueSize() {
+        if (internalExecutor) {
+            return maxQueueSize;
+        } else {
+            return -1;
+        }
+    }
+
+
     /**
      * Amount of time in milliseconds before the internal thread pool stops 
any idle threads
      * if the amount of thread is greater than the minimum amount of spare 
threads.
@@ -1225,7 +1241,7 @@ public abstract class AbstractEndpoint<S,U> {
         if (getUseVirtualThreads()) {
             executor = new VirtualThreadExecutor(getName() + "-virt-");
         } else {
-            TaskQueue taskqueue = new TaskQueue();
+            TaskQueue taskqueue = new TaskQueue(maxQueueSize);
             TaskThreadFactory tf = new TaskThreadFactory(getName() + "-exec-", 
daemon, getThreadPriority());
             executor = new ThreadPoolExecutor(getMinSpareThreads(), 
getMaxThreads(), getThreadsMaxIdleTime(),
                     TimeUnit.MILLISECONDS, taskqueue, tf);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 5cc937d544..132a3ffb3c 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -144,6 +144,11 @@
         <bug>69068</bug>: Ensure read timouts are triggered for asynchronous,
         non-blocking reads when using HTTP/2. (markt)
       </fix>
+      <update>
+        <bug>69133</bug>: Add task queue size configuration on the
+        <code>Connector</code> element, similar to the <code>Executor</code>
+        element, for consistency. (remm)
+      </update>
     </changelog>
   </subsection>
   <subsection name="Jasper">
diff --git a/webapps/docs/config/http.xml b/webapps/docs/config/http.xml
index fcd8453921..bd2ec287d1 100644
--- a/webapps/docs/config/http.xml
+++ b/webapps/docs/config/http.xml
@@ -543,6 +543,24 @@
       If not specified, this attribute is set to 100.</p>
     </attribute>
 
+    <attribute name="maxQueueSize" required="false">
+      <p>(int) The maximum number of runnable tasks that can queue up awaiting
+      execution before they are rejected. The default value is
+      <code>Integer.MAX_VALUE</code></p>
+    </attribute>
+
+    <attribute name="maxThreads" required="false">
+      <p>The maximum number of request processing threads to be created
+      by this <strong>Connector</strong>, which therefore determines the
+      maximum number of simultaneous requests that can be handled.  If
+      not specified, this attribute is set to 200. If an executor is associated
+      with this connector, this attribute is ignored as the connector will
+      execute tasks using the executor rather than an internal thread pool. 
Note
+      that if an executor is configured any value set for this attribute will 
be
+      recorded correctly but it will be reported (e.g. via JMX) as
+      <code>-1</code> to make clear that it is not used.</p>
+    </attribute>
+
     <attribute name="maxSwallowSize" required="false">
       <p>The maximum number of request body bytes (excluding transfer encoding
       overhead) that will be swallowed by Tomcat for an aborted upload. An


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to