Author: markt
Date: Wed Dec 31 05:17:41 2008
New Revision: 730384
URL: http://svn.apache.org/viewvc?rev=730384&view=rev
Log:
Make thread pool limits configurable via JMX (they were already read/write but
changing them caused various errors)
Modified:
tomcat/tc6.0.x/trunk/ (props changed)
tomcat/tc6.0.x/trunk/STATUS.txt
tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
Propchange: tomcat/tc6.0.x/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec 31 05:17:41 2008
@@ -1 +1 @@
-/tomcat/trunk:601180,606992,612607,630314,652744,653247,673796,673820,683982,684001,684081,684234,684269-684270,687503,687645,690781,691392,691805,692748,695053,695311,696780,696782,698012,698227,698236,698613,699427,699634,709294,709811,709816,710063,710125,710205,711126,711600,712461,718360,726052,728032,728947,729057
+/tomcat/trunk:601180,606992,612607,630314,652744,653247,673796,673820,683982,684001,684081,684234,684269-684270,687503,687645,690781,691392,691805,692748,695053,695311,696780,696782,698012,698227,698236,698613,699427,699634,709294,709811,709816,710063,710125,710205,711126,711600,712461,718360,719602,719626,719628,726052,728032,728947,729057
Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=730384&r1=730383&r2=730384&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Wed Dec 31 05:17:41 2008
@@ -131,14 +131,6 @@
Just did that for trunk (r711934; but it contains also other changes).
Caution: at the moment there's no @VERSION@ substitution for
service.bat.
-* Make thread pool limits dynamically configurable
- http://svn.apache.org/viewvc?rev=719602&view=rev
- http://svn.apache.org/viewvc?rev=719628&view=rev
- +1: markt, fhanik, jim
- 0: remm (risky, would it be possible to stop backporting risky changes and
behavior modifications to 6.0.x ?
- on this particular one, if people want fancy behavior, maybe they should
use an executor)
- -1:
-
* I have summarized all the NIO fixes into one patch for those who wish to
test it
* It includes patch [1]-[6] below and can be found at:
* http://people.apache.org/~fhanik/tomcat/uber-patch.txt
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java?rev=730384&r1=730383&r2=730384&view=diff
==============================================================================
---
tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java
(original)
+++
tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java
Wed Dec 31 05:17:41 2008
@@ -130,14 +130,23 @@
public void setMaxIdleTime(int maxIdleTime) {
this.maxIdleTime = maxIdleTime;
+ if (executor != null) {
+ executor.setKeepAliveTime(maxIdleTime, TimeUnit.MILLISECONDS);
+ }
}
public void setMaxThreads(int maxThreads) {
this.maxThreads = maxThreads;
+ if (executor != null) {
+ executor.setMaximumPoolSize(maxThreads);
+ }
}
public void setMinSpareThreads(int minSpareThreads) {
this.minSpareThreads = minSpareThreads;
+ if (executor != null) {
+ executor.setCorePoolSize(minSpareThreads);
+ }
}
public void setName(String name) {
Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=730384&r1=730383&r2=730384&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Wed
Dec 31 05:17:41 2008
@@ -36,6 +36,7 @@
import org.apache.tomcat.jni.SSLSocket;
import org.apache.tomcat.jni.Socket;
import org.apache.tomcat.jni.Status;
+import org.apache.tomcat.util.net.JIoEndpoint.Worker;
import org.apache.tomcat.util.res.StringManager;
/**
@@ -179,7 +180,14 @@
* Maximum amount of worker threads.
*/
protected int maxThreads = 200;
- public void setMaxThreads(int maxThreads) { this.maxThreads = maxThreads; }
+ public void setMaxThreads(int maxThreads) {
+ this.maxThreads = maxThreads;
+ if (running) {
+ synchronized(workers) {
+ workers.resize(maxThreads);
+ }
+ }
+ }
public int getMaxThreads() { return maxThreads; }
@@ -1883,12 +1891,18 @@
}
/**
- * Put the object into the queue.
+ * Put the object into the queue. If the queue is full (for example if
+ * the queue has been reduced in size) the object will be dropped.
*
- * @param object the object to be appended to the queue (first
element).
+ * @param object the object to be appended to the queue (first
+ * element).
*/
public void push(Worker worker) {
- workers[end++] = worker;
+ if (end < workers.length) {
+ workers[end++] = worker;
+ } else {
+ curThreads--;
+ }
}
/**
@@ -1923,6 +1937,22 @@
public int size() {
return (end);
}
+
+ /**
+ * Resize the queue. If there are too many objects in the queue for the
+ * new size, drop the excess.
+ *
+ * @param newSize
+ */
+ public void resize(int newSize) {
+ Worker[] newWorkers = new Worker[newSize];
+ int len = workers.length;
+ if (newSize < len) {
+ len = newSize;
+ }
+ System.arraycopy(workers, 0, newWorkers, 0, len);
+ workers = newWorkers;
+ }
}
Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java?rev=730384&r1=730383&r2=730384&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Wed
Dec 31 05:17:41 2008
@@ -152,7 +152,14 @@
* Maximum amount of worker threads.
*/
protected int maxThreads = 200;
- public void setMaxThreads(int maxThreads) { this.maxThreads = maxThreads; }
+ public void setMaxThreads(int maxThreads) {
+ this.maxThreads = maxThreads;
+ if (running) {
+ synchronized(workers) {
+ workers.resize(maxThreads);
+ }
+ }
+ }
public int getMaxThreads() { return maxThreads; }
@@ -760,12 +767,18 @@
}
/**
- * Put the object into the queue.
+ * Put the object into the queue. If the queue is full (for example if
+ * the queue has been reduced in size) the object will be dropped.
*
- * @param object the object to be appended to the queue (first
element).
+ * @param object the object to be appended to the queue (first
+ * element).
*/
public void push(Worker worker) {
- workers[end++] = worker;
+ if (end < workers.length) {
+ workers[end++] = worker;
+ } else {
+ curThreads--;
+ }
}
/**
@@ -800,6 +813,22 @@
public int size() {
return (end);
}
+
+ /**
+ * Resize the queue. If there are too many objects in the queue for the
+ * new size, drop the excess.
+ *
+ * @param newSize
+ */
+ public void resize(int newSize) {
+ Worker[] newWorkers = new Worker[newSize];
+ int len = workers.length;
+ if (newSize < len) {
+ len = newSize;
+ }
+ System.arraycopy(workers, 0, newWorkers, 0, len);
+ workers = newWorkers;
+ }
}
}
Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=730384&r1=730383&r2=730384&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Wed
Dec 31 05:17:41 2008
@@ -52,6 +52,7 @@
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.IntrospectionUtils;
+import org.apache.tomcat.util.net.JIoEndpoint.Worker;
import org.apache.tomcat.util.net.SecureNioChannel.ApplicationBufferHandler;
import org.apache.tomcat.util.res.StringManager;
@@ -350,7 +351,20 @@
* Maximum amount of worker threads.
*/
protected int maxThreads = 200;
- public void setMaxThreads(int maxThreads) { this.maxThreads = maxThreads; }
+ public void setMaxThreads(int maxThreads) {
+ this.maxThreads = maxThreads;
+ if (running) {
+ if (getUseExecutor() && executor!=null) {
+ if (executor instanceof ThreadPoolExecutor) {
+
((ThreadPoolExecutor)executor).setMaximumPoolSize(maxThreads);
+ }
+ }else if (workers!=null){
+ synchronized(workers) {
+ workers.resize(maxThreads);
+ }
+ }
+ }
+ }
public int getMaxThreads() { return maxThreads; }
@@ -2018,12 +2032,18 @@
}
/**
- * Put the object into the queue.
+ * Put the object into the queue. If the queue is full (for example if
+ * the queue has been reduced in size) the object will be dropped.
*
- * @param object the object to be appended to the queue (first
element).
+ * @param object the object to be appended to the queue (first
+ * element).
*/
public void push(Worker worker) {
- workers[end++] = worker;
+ if (end < workers.length) {
+ workers[end++] = worker;
+ } else {
+ curThreads--;
+ }
}
/**
@@ -2058,6 +2078,22 @@
public int size() {
return (end);
}
+
+ /**
+ * Resize the queue. If there are too many objects in the queue for the
+ * new size, drop the excess.
+ *
+ * @param newSize
+ */
+ public void resize(int newSize) {
+ Worker[] newWorkers = new Worker[newSize];
+ int len = workers.length;
+ if (newSize < len) {
+ len = newSize;
+ }
+ System.arraycopy(workers, 0, newWorkers, 0, len);
+ workers = newWorkers;
+ }
}
Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=730384&r1=730383&r2=730384&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Wed Dec 31 05:17:41 2008
@@ -254,6 +254,9 @@
<add>
Log a message if we reach maxThreads in a connector thread pool.
(markt)
</add>
+ <add>
+ Enable the thread pool limits to be modified via JMX. (markt)
+ </add>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]