Author: remy.maucherat(a)jboss.com
Date: 2011-03-14 09:56:39 -0400 (Mon, 14 Mar 2011)
New Revision: 1677
Modified:
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
trunk/webapps/docs/changelog.xml
Log:
- Lower the static file cache for the low mem scenario (I'll keep it for now).
- Add back the "wait for an available processor" code, which fits the "toy
server" use quite well.
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2011-03-13 17:40:52 UTC (rev
1676)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2011-03-14 13:56:39 UTC (rev
1677)
@@ -610,13 +610,13 @@
/**
* Cache max size in KB.
*/
- protected int cacheMaxSize = 10240; // 10 MB
+ protected int cacheMaxSize = (org.apache.tomcat.util.Constants.LOW_MEMORY) ? 128 :
10240; // 10 MB
/**
* Cache object max size in KB.
*/
- protected int cacheObjectMaxSize = 256; // 256K
+ protected int cacheObjectMaxSize = (org.apache.tomcat.util.Constants.LOW_MEMORY) ? 8
: 256; // 256K
/**
Modified: trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
===================================================================
--- trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2011-03-13 17:40:52 UTC (rev
1676)
+++ trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2011-03-14 13:56:39 UTC (rev
1677)
@@ -964,6 +964,28 @@
/**
+ * Return a new worker thread, and block while to worker is available.
+ */
+ protected Worker getWorkerThread() {
+ // Allocate a new worker thread
+ Worker workerThread = createWorkerThread();
+ if (org.apache.tomcat.util.Constants.LOW_MEMORY) {
+ while (workerThread == null) {
+ try {
+ synchronized (workers) {
+ workers.wait();
+ }
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ workerThread = createWorkerThread();
+ }
+ }
+ return workerThread;
+ }
+
+
+ /**
* Allocate a new poller of the specified size.
*/
protected long allocatePoller(int size, long pool, int timeout) {
@@ -987,7 +1009,7 @@
protected boolean processSocketWithOptions(long socket) {
try {
if (executor == null) {
- Worker worker = createWorkerThread();
+ Worker worker = getWorkerThread();
if (worker != null) {
worker.assignWithOptions(socket);
} else {
@@ -1012,7 +1034,7 @@
protected boolean processSocket(long socket) {
try {
if (executor == null) {
- Worker worker = createWorkerThread();
+ Worker worker = getWorkerThread();
if (worker != null) {
worker.assign(socket);
} else {
@@ -1037,7 +1059,7 @@
protected boolean processSocket(long socket, SocketStatus status) {
try {
if (executor == null) {
- Worker worker = createWorkerThread();
+ Worker worker = getWorkerThread();
if (worker != null) {
worker.assign(socket, status);
} else {
Modified: trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
===================================================================
--- trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java 2011-03-13 17:40:52 UTC (rev
1676)
+++ trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java 2011-03-14 13:56:39 UTC (rev
1677)
@@ -1205,6 +1205,28 @@
/**
+ * Return a new worker thread, and block while to worker is available.
+ */
+ protected Worker getWorkerThread() {
+ // Allocate a new worker thread
+ Worker workerThread = createWorkerThread();
+ if (org.apache.tomcat.util.Constants.LOW_MEMORY) {
+ while (workerThread == null) {
+ try {
+ synchronized (workers) {
+ workers.wait();
+ }
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ workerThread = createWorkerThread();
+ }
+ }
+ return workerThread;
+ }
+
+
+ /**
* Recycle the specified Processor so that it can be used again.
*
* @param workerThread The processor to be recycled
@@ -1224,7 +1246,7 @@
protected boolean processSocket(Socket socket) {
try {
if (executor == null) {
- Worker worker = createWorkerThread();
+ Worker worker = getWorkerThread();
if (worker != null) {
worker.assign(socket);
} else {
@@ -1249,7 +1271,7 @@
protected boolean processSocket(Socket socket, SocketStatus status) {
try {
if (executor == null) {
- Worker worker = createWorkerThread();
+ Worker worker = getWorkerThread();
if (worker != null) {
worker.assign(socket, status);
} else {
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2011-03-13 17:40:52 UTC (rev 1676)
+++ trunk/webapps/docs/changelog.xml 2011-03-14 13:56:39 UTC (rev 1677)
@@ -16,6 +16,16 @@
<body>
+<section name="JBoss Web 7.0.0.Beta5 (remm)">
+ <subsection name="General">
+ <changelog>
+ <fix>
+ Add a set of low memory use defaults. (remm)
+ </fix>
+ </changelog>
+ </subsection>
+</section>
+
<section name="JBoss Web 7.0.0.Beta4 (remm)">
<subsection name="Catalina">
<changelog>