Adjusted the timeout for abandoned, its in seconds
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 28 Oct 2008 20:31:00 +0000 (20:31 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 28 Oct 2008 20:31:00 +0000 (20:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@708663 13f79535-47bb-0310-9956-ffa450edef68

modules/jdbc-pool/doc/jdbc-pool.xml
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java
modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestTimeout.java

index 8aff55a..3abbb38 100644 (file)
       <p>(int) Property not used. The default value is <code>false</code>.</p>
     </attribute>
    
+    <attribute name="fairQueue" required="false">
+      <p>(boolean) Set to true if you wish that calls to getConnection should be treated
+         fairly in a true FIFO fashion. This uses the <code>org.apache.tomcat.jdbc.pool.FairBlockingQueue</code> 
+         implementation for the list of the idle connections. The default value is <code>false</code>.
+      </p>
+    </attribute>
 
 
   </attributes>
index 8627a87..03c4d9e 100644 (file)
@@ -514,7 +514,7 @@ public class ConnectionPool {
             //if the connection pool is closed\r
             //close the connection instead of returning it\r
             release(con);\r
-            return;\r
+            return; \r
         } //end if\r
 \r
         if (con != null) {\r
@@ -552,7 +552,7 @@ public class ConnectionPool {
 \r
     public void checkAbandoned() {\r
         try {\r
-            long now = System.currentTimeMillis();\r
+            if (busy.size()==0) return;\r
             Iterator<PooledConnection> locked = busy.iterator();\r
             while (locked.hasNext()) {\r
                 PooledConnection con = locked.next();\r
@@ -564,6 +564,7 @@ public class ConnectionPool {
                     if (idle.contains(con))\r
                         continue;\r
                     long time = con.getTimestamp();\r
+                    long now = System.currentTimeMillis();\r
                     if ((now - time) > con.getAbandonTimeout()) {\r
                         busy.remove(con);\r
                         abandon(con);\r
@@ -587,6 +588,7 @@ public class ConnectionPool {
 \r
     public void checkIdle() {\r
         try {\r
+            if (idle.size()==0) return;\r
             long now = System.currentTimeMillis();\r
             Iterator<PooledConnection> unlocked = idle.iterator();\r
             while ( (idle.size()>=getPoolProperties().getMinIdle()) && unlocked.hasNext()) {\r
@@ -621,6 +623,7 @@ public class ConnectionPool {
 \r
     public void testAllIdle() {\r
         try {\r
+            if (idle.size()==0) return;\r
             Iterator<PooledConnection> unlocked = idle.iterator();\r
             while (unlocked.hasNext()) {\r
                 PooledConnection con = unlocked.next();\r
index dafa966..9b83810 100644 (file)
@@ -50,7 +50,7 @@ public class DefaultTestCase extends TestCase {
         p.setMaxActive(threadcount);\r
         p.setInitialSize(threadcount);\r
         p.setMaxWait(10000);\r
-        p.setRemoveAbandonedTimeout(10000);\r
+        p.setRemoveAbandonedTimeout(10);\r
         p.setMinEvictableIdleTimeMillis(10000);\r
         p.setMinIdle(threadcount);\r
         p.setLogAbandoned(false);\r
index 64a4d6c..ec42ec0 100644 (file)
@@ -39,7 +39,7 @@ public class TestTimeout extends DefaultTestCase {
             this.datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(1000);\r
             this.datasource.getPoolProperties().setMaxActive(20);\r
             this.datasource.getPoolProperties().setMaxWait(3000);\r
-            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5000);\r
+            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5);\r
             this.datasource.getPoolProperties().setMinEvictableIdleTimeMillis(5000);\r
             this.datasource.getPoolProperties().setMinIdle(5);\r
             this.datasource.getPoolProperties().setLogAbandoned(true);\r
@@ -69,7 +69,7 @@ public class TestTimeout extends DefaultTestCase {
             this.datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(1000);\r
             this.datasource.getPoolProperties().setMaxActive(20);\r
             this.datasource.getPoolProperties().setMaxWait(3000);\r
-            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5000);\r
+            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5);\r
             this.datasource.getPoolProperties().setMinEvictableIdleTimeMillis(5000);\r
             this.datasource.getPoolProperties().setMinIdle(5);\r
             this.datasource.getPoolProperties().setLogAbandoned(true);\r
@@ -99,7 +99,7 @@ public class TestTimeout extends DefaultTestCase {
             this.datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(1000);\r
             this.datasource.getPoolProperties().setMaxActive(20);\r
             this.datasource.getPoolProperties().setMaxWait(3000);\r
-            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5000);\r
+            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5);\r
             this.datasource.getPoolProperties().setMinEvictableIdleTimeMillis(5000);\r
             this.datasource.getPoolProperties().setMinIdle(5);\r
             this.datasource.getPoolProperties().setRemoveAbandoned(true);\r
@@ -130,7 +130,7 @@ public class TestTimeout extends DefaultTestCase {
             this.datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(1000);\r
             this.datasource.getPoolProperties().setMaxActive(20);\r
             this.datasource.getPoolProperties().setMaxWait(3000);\r
-            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5000);\r
+            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5);\r
             this.datasource.getPoolProperties().setMinEvictableIdleTimeMillis(5000);\r
             this.datasource.getPoolProperties().setMinIdle(5);\r
             this.datasource.getPoolProperties().setRemoveAbandoned(true);\r