tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r793116 - in /tomcat/trunk/modules/jdbc-pool: java/org/apache/tomcat/jdbc/pool/ test/org/apache/tomcat/jdbc/test/
Date Fri, 10 Jul 2009 21:38:17 GMT
Author: fhanik
Date: Fri Jul 10 21:38:16 2009
New Revision: 793116

URL: http://svn.apache.org/viewvc?rev=793116&view=rev
Log:
Some more concurrency testing

Modified:
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
    tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestConcurrency.java

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java?rev=793116&r1=793115&r2=793116&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java Fri
Jul 10 21:38:16 2009
@@ -847,7 +847,7 @@
                     if (busy.contains(con))
                         continue;
                     long time = con.getTimestamp();
-                    if (((now - time) > con.getReleaseTime()) && (getSize()>getPoolProperties().getMinIdle()))
{
+                    if ((con.getReleaseTime()>0) && ((now - time) > con.getReleaseTime())
&& (getSize()>getPoolProperties().getMinIdle())) {
                         release(con);
                         idle.remove(con);
                         setToNull = true;

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java?rev=793116&r1=793115&r2=793116&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java
(original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java
Fri Jul 10 21:38:16 2009
@@ -108,6 +108,7 @@
     protected final static String PROP_FAIR_QUEUE = "fairQueue";
     
     protected static final String PROP_USE_EQUALS = "useEquals";
+    protected static final String PROP_USE_CON_LOCK = "useLock";
     
     public static final int UNKNOWN_TRANSACTIONISOLATION = -1;
     
@@ -151,7 +152,8 @@
         PROP_USE_EQUALS,
         OBJECT_NAME,
         PROP_ABANDONWHENPERCENTAGEFULL,
-        PROP_MAXAGE
+        PROP_MAXAGE,
+        PROP_USE_CON_LOCK
     };
 
     // -------------------------------------------------- ObjectFactory Methods
@@ -424,6 +426,11 @@
             poolProperties.setMaxAge(Long.parseLong(value));
         }
         
+        value = properties.getProperty(PROP_USE_CON_LOCK);
+        if (value != null) {
+            poolProperties.setUseLock(Boolean.parseBoolean(value));
+        }
+        
         return poolProperties;
     }
 

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java?rev=793116&r1=793115&r2=793116&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java Fri
Jul 10 21:38:16 2009
@@ -287,6 +287,10 @@
         this.getPoolProperties().setFairQueue(fairQueue);
     }
     
+    public void setUseLock(boolean useLock) {
+        this.getPoolProperties().setUseLock(useLock);
+    }
+    
     public void setDefaultCatalog(String catalog) {
         this.getPoolProperties().setDefaultCatalog(catalog);
     }

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java?rev=793116&r1=793115&r2=793116&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java Fri
Jul 10 21:38:16 2009
@@ -72,7 +72,7 @@
     protected boolean useEquals = false;
     protected int abandonWhenPercentageFull = 0;
     protected long maxAge = 0;
-    protected boolean useLock = true;
+    protected boolean useLock = false;
     private InterceptorDefinition[] interceptors = null;
     
     public void setAbandonWhenPercentageFull(int percentage) {

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java?rev=793116&r1=793115&r2=793116&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
(original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
Fri Jul 10 21:38:16 2009
@@ -77,7 +77,7 @@
     /**
      * Timestamp the connection was last 'touched' by the pool
      */
-    private long timestamp;
+    private volatile long timestamp;
     /**
      * Lock for this connection only
      */

Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestConcurrency.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestConcurrency.java?rev=793116&r1=793115&r2=793116&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestConcurrency.java (original)
+++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestConcurrency.java Fri
Jul 10 21:38:16 2009
@@ -91,17 +91,16 @@
     
     public void testBrutal() throws Exception {
         ds.getPoolProperties().setRemoveAbandoned(false);
-        ds.getPoolProperties().setMinEvictableIdleTimeMillis(-1);
+        ds.getPoolProperties().setMinEvictableIdleTimeMillis(10);
         ds.getPoolProperties().setTimeBetweenEvictionRunsMillis(-1);
         ds.getConnection().close();
-        final int iter = 1000 * 10;
+        final int iter = 100000 * 10;
         final AtomicInteger loopcount = new AtomicInteger(0);
         final Runnable run = new Runnable() {
             public void run() {
                 try {
                     while (loopcount.incrementAndGet() < iter) {
                         Connection con = ds.getConnection();
-                        Thread.sleep(10);
                         con.close();
                     }
                 }catch (Exception x) {
@@ -136,7 +135,7 @@
         assertEquals("Size comparison:",10, ds.getPool().getSize());
         assertEquals("Idle comparison:",10, ds.getPool().getIdle());
         assertEquals("Used comparison:",0, ds.getPool().getActive());
-        assertEquals("Connect count",10,Driver.connectCount.get());
+        assertEquals("Connect count",10,Driver.connectCount.get()-Driver.disconnectCount.get());
             
     }
 



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


Mime
View raw message