This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 4bddc82b64 Add task queue size configuration on the Connector element
4bddc82b64 is described below
commit 4bddc82b64d2bc2777092024a71f1d177463703e
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 95179c0d2a..02f4e3f288 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 03a12d1959..26040fd0d9 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -812,6 +812,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.
@@ -1070,7 +1086,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 8071722be4..f7bcecdd55 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 61317d8b5c..b84fee2e2a 100644
--- a/webapps/docs/config/http.xml
+++ b/webapps/docs/config/http.xml
@@ -557,6 +557,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]