tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1197158 - in /tomcat/trunk: java/org/apache/tomcat/util/net/AbstractEndpoint.java test/org/apache/catalina/startup/TomcatBaseTest.java
Date Thu, 03 Nov 2011 14:40:21 GMT
Author: kkolinko
Date: Thu Nov  3 14:40:21 2011
New Revision: 1197158

URL: http://svn.apache.org/viewvc?rev=1197158&view=rev
Log:
Add new attribute to AbstractEndpoint and use it to speed up Tomcat tests.
If the attribute "fastShutdown" is set on the endpoint,
the usual wait of 1 sec during pause() is skipped.

I think it needs to be added to http.xml/ajp.xml docs, but that will be a separate commit
sometime later.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java
    tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java?rev=1197158&r1=1197157&r2=1197158&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java Thu Nov  3 14:40:21
2011
@@ -112,6 +112,23 @@ public abstract class AbstractEndpoint {
 
     // ----------------------------------------------------------------- Properties
 
+    /**
+     * A flag that can be used to speed up Tomcat shutdown by testing
+     * environments where we control external connections to Tomcat. Set it to
+     * {@code true} if it is known that there are no active or pending
+     * connections and all requests have already been processed. The default
+     * value is {@code false}.
+     */
+    private boolean fastShutdown = false;
+
+    public void setFastShutdown(boolean fastShutdown) {
+        this.fastShutdown = fastShutdown;
+    }
+
+    public boolean isFastShutdown() {
+        return fastShutdown;
+    }
+
     private int maxConnections = 10000;
     public void setMaxConnections(int maxCon) {
         this.maxConnections = maxCon;
@@ -514,6 +531,11 @@ public abstract class AbstractEndpoint {
     public void pause() {
         if (running && !paused) {
             paused = true;
+            if (isFastShutdown()) {
+                // unlockAccept will also be called by stopInternal(),
+                // so when shutting down it can be skipped here.
+                return;
+            }
             unlockAccept();
             // Heuristic: Sleep for a while to ensure pause of the endpoint
             try {

Modified: tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java?rev=1197158&r1=1197157&r2=1197158&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java Thu Nov  3 14:40:21
2011
@@ -200,6 +200,10 @@ public abstract class TomcatBaseTest {
 
     @After
     public void tearDown() throws Exception {
+        // Speed up Tomcat shutdown
+        if (tomcat.connector != null) {
+            tomcat.connector.setProperty("fastShutdown", "true");
+        }
         // Some tests may call tomcat.destroy(), some tests may just call
         // tomcat.stop(), some not call either method. Make sure that stop() &
         // destroy() are called as necessary.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message