This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 8feb72bab9 Add task queue size configuration on the Connector element
8feb72bab9 is described below
commit 8feb72bab946b9da1ddb16553b8f2e4e9b0b8fd5
Author: remm <[email protected]>
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 a5e33ef174..4434e21800 100644
--- a/java/org/apache/coyote/AbstractProtocol.java
+++ b/java/org/apache/coyote/AbstractProtocol.java
@@ -282,6 +282,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 d6dfe75f5f..468ab3e984 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -875,6 +875,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.
@@ -1123,7 +1139,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 bb20f254ea..7d8285ae41 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -148,6 +148,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 dcd1778d53..9dbbb8a8e8 100644
--- a/webapps/docs/config/http.xml
+++ b/webapps/docs/config/http.xml
@@ -563,6 +563,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: [email protected]
For additional commands, e-mail: [email protected]