Author: fhanik Date: Mon Nov 24 14:04:23 2008 New Revision: 720306 URL: http://svn.apache.org/viewvc?rev=720306&view=rev Log: Fix fair blocking queue for now, we will add back the ability to not have a timeout later
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/FairBlockingQueue.java tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.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=720306&r1=720305&r2=720306&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 Mon Nov 24 14:04:23 2008 @@ -424,8 +424,8 @@ //we didn't get a connection, lets see if we timed out if (con == null) { if ((System.currentTimeMillis() - now) >= maxWait) { - throw new SQLException( - "Pool empty. Unable to fetch a connection in " + (maxWait / 1000) + + throw new SQLException("[" + Thread.currentThread().getName()+"] " + + "Timeout: Pool empty. Unable to fetch a connection in " + (maxWait / 1000) + " seconds, none available["+busy.size()+" in use]."); } else { //no timeout, lets try again Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java?rev=720306&r1=720305&r2=720306&view=diff ============================================================================== --- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java (original) +++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java Mon Nov 24 14:04:23 2008 @@ -76,7 +76,7 @@ lock.lock(); try { result = items.poll(); - if (result==null && timeout>0) { + if (result==null) { ExchangeCountDownLatch<E> c = new ExchangeCountDownLatch<E>(1); waiters.addLast(c); lock.unlock(); Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java?rev=720306&r1=720305&r2=720306&view=diff ============================================================================== --- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java (original) +++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java Mon Nov 24 14:04:23 2008 @@ -55,6 +55,7 @@ } public void testDBCPThreads20Connections10() throws Exception { + System.out.println("Starting fairness - DBCP"); init(); this.datasource.getPoolProperties().setMaxActive(10); this.threadcount = 20; @@ -76,10 +77,12 @@ this.run = false; long delta = System.currentTimeMillis() - start; printThreadResults(threads,"testDBCPThreads20Connections10"); + System.out.println("Completed fairness - DBCP"); tearDown(); } public void testPoolThreads20Connections10() throws Exception { + System.out.println("Starting fairness - Tomcat JDBC - Non Fair"); init(); this.datasource.getPoolProperties().setMaxActive(10); this.threadcount = 20; @@ -101,11 +104,13 @@ this.run = false; long delta = System.currentTimeMillis() - start; printThreadResults(threads,"testPoolThreads20Connections10"); + System.out.println("Completed fairness - Tomcat JDBC - Non Fair"); tearDown(); } public void testPoolThreads20Connections10Fair() throws Exception { + System.out.println("Starting fairness - Tomcat JDBC - Fair"); init(); this.datasource.getPoolProperties().setMaxActive(10); this.datasource.getPoolProperties().setFairQueue(true); @@ -128,6 +133,7 @@ this.run = false; long delta = System.currentTimeMillis() - start; printThreadResults(threads,"testPoolThreads20Connections10Fair"); + System.out.println("Completed fairness - Tomcat JDBC - Fair"); tearDown(); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]