Author: remy.maucherat(a)jboss.com
Date: 2007-10-10 20:16:16 -0400 (Wed, 10 Oct 2007)
New Revision: 303
Modified:
trunk/java/org/apache/catalina/core/StandardService.java
trunk/java/org/apache/catalina/core/StandardWrapper.java
trunk/java/org/apache/coyote/RequestGroupInfo.java
trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
trunk/java/org/apache/coyote/ajp/AjpProtocol.java
trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
trunk/java/org/apache/coyote/http11/Http11Protocol.java
Log:
- Experiment with a different shutdown procedure, with the connectors being responsible
for waiting
(when pausing).
Modified: trunk/java/org/apache/catalina/core/StandardService.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardService.java 2007-10-09 16:06:54 UTC (rev
302)
+++ trunk/java/org/apache/catalina/core/StandardService.java 2007-10-11 00:16:16 UTC (rev
303)
@@ -573,13 +573,6 @@
}
}
- // Heuristic: Sleep for a while to ensure pause of the connector
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // Ignore
- }
-
lifecycle.fireLifecycleEvent(STOP_EVENT, null);
if(log.isInfoEnabled())
log.info
@@ -594,7 +587,7 @@
}
}
}
- // FIXME pero -- Why container stop first? KeepAlive connetions can send request!
+
// Stop our defined Connectors first
synchronized (connectors) {
for (int i = 0; i < connectors.length; i++) {
Modified: trunk/java/org/apache/catalina/core/StandardWrapper.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapper.java 2007-10-09 16:06:54 UTC (rev
302)
+++ trunk/java/org/apache/catalina/core/StandardWrapper.java 2007-10-11 00:16:16 UTC (rev
303)
@@ -111,8 +111,7 @@
protected NotificationBroadcasterSupport broadcaster = null;
/**
- * The count of allocations that are currently active (even if they
- * are for the same instance, as will be true on a non-STM servlet).
+ * The count of allocations that are currently active for STM servlets.
*/
protected int countAllocated = 0;
@@ -308,9 +307,7 @@
/**
- * Return the number of active allocations of this servlet, even if they
- * are all for the same instance (as will be true for servlets that do
- * not implement <code>SingleThreadModel</code>.
+ * Return the number of active allocations of this servlet.
*/
public int getCountAllocated() {
@@ -791,7 +788,6 @@
if (!singleThreadModel) {
if (log.isTraceEnabled())
log.trace(" Returning non-STM instance");
- countAllocated++;
return (instance);
}
@@ -842,7 +838,6 @@
// If not SingleThreadModel, no action is required
if (!singleThreadModel) {
- countAllocated--;
return;
}
@@ -1237,25 +1232,6 @@
return;
unloading = true;
- // Loaf a while if the current instance is allocated
- // (possibly more than once if non-STM)
- if (countAllocated > 0) {
- int nRetries = 0;
- long delay = unloadDelay / 20;
- while ((nRetries < 21) && (countAllocated > 0)) {
- if ((nRetries % 10) == 0) {
- log.info(sm.getString("standardWrapper.waiting",
- new Integer(countAllocated)));
- }
- try {
- Thread.sleep(delay);
- } catch (InterruptedException e) {
- ;
- }
- nRetries++;
- }
- }
-
PrintStream out = System.out;
if (swallowOutput) {
SystemLogHandler.startCapture();
Modified: trunk/java/org/apache/coyote/RequestGroupInfo.java
===================================================================
--- trunk/java/org/apache/coyote/RequestGroupInfo.java 2007-10-09 16:06:54 UTC (rev 302)
+++ trunk/java/org/apache/coyote/RequestGroupInfo.java 2007-10-11 00:16:16 UTC (rev 303)
@@ -50,6 +50,10 @@
}
}
+ public synchronized RequestInfo[] getRequestProcessors() {
+ return (RequestInfo[]) processors.toArray(new RequestInfo[0]);
+ }
+
public synchronized long getMaxTime() {
long maxTime=deadMaxTime;
for( int i=0; i<processors.size(); i++ ) {
Modified: trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
===================================================================
--- trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java 2007-10-09 16:06:54 UTC (rev
302)
+++ trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java 2007-10-11 00:16:16 UTC (rev
303)
@@ -201,6 +201,24 @@
log.error(sm.getString("ajpprotocol.endpoint.pauseerror"), ex);
throw ex;
}
+ // Wait for a while until all the processors are idle
+ RequestInfo[] states = cHandler.global.getRequestProcessors();
+ int retry = 0;
+ boolean done = false;
+ while (!done && retry < 20) {
+ retry++;
+ for (int i = 0; i < states.length; i++) {
+ if (states[i].getStage() == org.apache.coyote.Constants.STAGE_SERVICE) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ ;
+ }
+ continue;
+ }
+ }
+ done = true;
+ }
if (log.isInfoEnabled())
log.info(sm.getString("ajpprotocol.pause", getName()));
}
Modified: trunk/java/org/apache/coyote/ajp/AjpProtocol.java
===================================================================
--- trunk/java/org/apache/coyote/ajp/AjpProtocol.java 2007-10-09 16:06:54 UTC (rev 302)
+++ trunk/java/org/apache/coyote/ajp/AjpProtocol.java 2007-10-11 00:16:16 UTC (rev 303)
@@ -200,6 +200,24 @@
log.error(sm.getString("ajpprotocol.endpoint.pauseerror"), ex);
throw ex;
}
+ // Wait for a while until all the processors are idle
+ RequestInfo[] states = cHandler.global.getRequestProcessors();
+ int retry = 0;
+ boolean done = false;
+ while (!done && retry < 20) {
+ retry++;
+ for (int i = 0; i < states.length; i++) {
+ if (states[i].getStage() == org.apache.coyote.Constants.STAGE_SERVICE) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ ;
+ }
+ continue;
+ }
+ }
+ done = true;
+ }
if (log.isInfoEnabled())
log.info(sm.getString("ajpprotocol.pause", getName()));
}
Modified: trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
===================================================================
--- trunk/java/org/apache/coyote/http11/Http11AprProtocol.java 2007-10-09 16:06:54 UTC
(rev 302)
+++ trunk/java/org/apache/coyote/http11/Http11AprProtocol.java 2007-10-11 00:16:16 UTC
(rev 303)
@@ -150,6 +150,24 @@
log.error(sm.getString("http11protocol.endpoint.pauseerror"), ex);
throw ex;
}
+ // Wait for a while until all the processors are idle
+ RequestInfo[] states = cHandler.global.getRequestProcessors();
+ int retry = 0;
+ boolean done = false;
+ while (!done && retry < 20) {
+ retry++;
+ for (int i = 0; i < states.length; i++) {
+ if (states[i].getStage() == org.apache.coyote.Constants.STAGE_SERVICE) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ ;
+ }
+ continue;
+ }
+ }
+ done = true;
+ }
if(log.isInfoEnabled())
log.info(sm.getString("http11protocol.pause", getName()));
}
Modified: trunk/java/org/apache/coyote/http11/Http11Protocol.java
===================================================================
--- trunk/java/org/apache/coyote/http11/Http11Protocol.java 2007-10-09 16:06:54 UTC (rev
302)
+++ trunk/java/org/apache/coyote/http11/Http11Protocol.java 2007-10-11 00:16:16 UTC (rev
303)
@@ -216,6 +216,24 @@
log.error(sm.getString("http11protocol.endpoint.pauseerror"), ex);
throw ex;
}
+ // Wait for a while until all the processors are no longer processing requests
+ RequestInfo[] states = cHandler.global.getRequestProcessors();
+ int retry = 0;
+ boolean done = false;
+ while (!done && retry < 20) {
+ retry++;
+ for (int i = 0; i < states.length; i++) {
+ if (states[i].getStage() == org.apache.coyote.Constants.STAGE_SERVICE) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ ;
+ }
+ continue;
+ }
+ }
+ done = true;
+ }
if (log.isInfoEnabled())
log.info(sm.getString("http11protocol.pause", getName()));
}
Show replies by date