svn commit: r797528 - in /tomcat/trunk/modules/jdbc-pool: doc/ java/org/apache/tomcat/jdbc/pool/

2009-07-24 Thread fhanik
Author: fhanik
Date: Fri Jul 24 15:24:52 2009
New Revision: 797528

URL: http://svn.apache.org/viewvc?rev=797528view=rev
Log:
Add in Linux special case for performance optimization around locking.
Set default queue to be the fair one
Remove unused code


Modified:
tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml

tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.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/FairBlockingQueue.java

tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java

tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java

Modified: tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml?rev=797528r1=797527r2=797528view=diff
==
--- tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml (original)
+++ tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml Fri Jul 24 15:24:52 2009
@@ -353,10 +353,16 @@
 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 
codeorg.apache.tomcat.jdbc.pool.FairBlockingQueue/code 
- implementation for the list of the idle connections. The default 
value is codefalse/code.
+ implementation for the list of the idle connections. The default 
value is codetrue/code.
  This flag is required when you want to use asynchronous connection 
retrieval.br/
- During performance tests, the fairQueue does very well on a multi 
core Solaris system,
- but performs terribly on a Linux Fedora 11 system. On Linux we 
recommend setting this to false. 
+ Setting this flag ensures that threads receive connections in the 
order they arrive.br/
+ During performance tests, there is a very large difference in how 
locks
+ and lock waiting is implemented. When codefairQueue=true/code
+ there is a decision making process based on what operating system the 
system is running.
+ If the system is running on Linux (property 
codeos.name=Linux/code.
+ To disable this Linux specific behavior and still use the fair queue, 
simply add the property
+ 
codeorg.apache.tomcat.jdbc.pool.FairBlockingQueue.ignoreOS=true/code to 
your system properties
+ before the connection pool classes are loaded.
   /p
 /attribute
 

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=797528r1=797527r2=797528view=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 24 15:24:52 2009
@@ -148,6 +148,9 @@
 if (idle instanceof FairBlockingQueue) {
 FuturePooledConnection pcf = 
((FairBlockingQueuePooledConnection)idle).pollAsync();
 return new ConnectionFuture(pcf);
+} else if (idle instanceof MultiLockFairBlockingQueue) {
+FuturePooledConnection pcf = 
((MultiLockFairBlockingQueuePooledConnection)idle).pollAsync();
+return new ConnectionFuture(pcf);
 } else {
 throw new SQLException(Connection pool is misconfigured, doesn't 
support async retrieval. Set the 'fair' property to 'true');
 }
@@ -306,21 +309,6 @@
 }
 
 /**
- * If the connection pool gets garbage collected, lets make sure we clean 
up
- * and close all the connections.
- * {...@inheritdoc}
- */
-@Override
-protected void finalize() throws Throwable {
-//Runnable closer = new Runnable() {
-//public void run() {
-//close(true);
-//}
-//};
-//this.cancellator.execute(closer);
-}
-
-/**
  * Closes the pool and all disconnects all idle connections
  * Active connections will be closed upon the {...@link 
java.sql.Connection#close close} method is called
  * on the underlying connection instead of being returned to the pool
@@ -381,6 +369,7 @@
 //make space for 10 extra in case we flow over a bit
 if (properties.isFairQueue()) {
 idle = new FairBlockingQueuePooledConnection();
+//idle = new MultiLockFairBlockingQueuePooledConnection();
 } else {
 idle = new 
ArrayBlockingQueuePooledConnection(properties.getMaxActive(),properties.isFairQueue());
 }

Modified: 

Re: svn commit: r797528 - in /tomcat/trunk/modules/jdbc-pool: doc/ java/org/apache/tomcat/jdbc/pool/

2009-07-24 Thread sebb
On 24/07/2009, fha...@apache.org fha...@apache.org wrote:
 Author: fhanik
  Date: Fri Jul 24 15:24:52 2009
  New Revision: 797528

  URL: http://svn.apache.org/viewvc?rev=797528view=rev
  Log:
  Add in Linux special case for performance optimization around locking.
  Set default queue to be the fair one
  Remove unused code


  Modified:
 tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml
 
 tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.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/FairBlockingQueue.java
 
 tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java
 
 tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java

  Modified: tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml
  URL: 
 http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml?rev=797528r1=797527r2=797528view=diff
  
 ==
  --- tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml (original)
  +++ tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml Fri Jul 24 15:24:52 2009
  @@ -353,10 +353,16 @@
  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 
 codeorg.apache.tomcat.jdbc.pool.FairBlockingQueue/code
  - implementation for the list of the idle connections. The default 
 value is codefalse/code.
  + implementation for the list of the idle connections. The default 
 value is codetrue/code.
   This flag is required when you want to use asynchronous connection 
 retrieval.br/
  - During performance tests, the fairQueue does very well on a multi 
 core Solaris system,
  - but performs terribly on a Linux Fedora 11 system. On Linux we 
 recommend setting this to false.
  + Setting this flag ensures that threads receive connections in the 
 order they arrive.br/
  + During performance tests, there is a very large difference in how 
 locks
  + and lock waiting is implemented. When codefairQueue=true/code
  + there is a decision making process based on what operating system 
 the system is running.
  + If the system is running on Linux (property 
 codeos.name=Linux/code.
  + To disable this Linux specific behavior and still use the fair 
 queue, simply add the property
  + 
 codeorg.apache.tomcat.jdbc.pool.FairBlockingQueue.ignoreOS=true/code to 
 your system properties
  + before the connection pool classes are loaded.
/p
  /attribute


  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=797528r1=797527r2=797528view=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 24 15:24:52 2009
  @@ -148,6 +148,9 @@
  if (idle instanceof FairBlockingQueue) {
  FuturePooledConnection pcf = 
 ((FairBlockingQueuePooledConnection)idle).pollAsync();
  return new ConnectionFuture(pcf);
  +} else if (idle instanceof MultiLockFairBlockingQueue) {
  +FuturePooledConnection pcf = 
 ((MultiLockFairBlockingQueuePooledConnection)idle).pollAsync();
  +return new ConnectionFuture(pcf);
  } else {
  throw new SQLException(Connection pool is misconfigured, 
 doesn't support async retrieval. Set the 'fair' property to 'true');
  }
  @@ -306,21 +309,6 @@
  }

  /**
  - * If the connection pool gets garbage collected, lets make sure we 
 clean up
  - * and close all the connections.
  - * {...@inheritdoc}
  - */
  -@Override
  -protected void finalize() throws Throwable {
  -//Runnable closer = new Runnable() {
  -//public void run() {
  -//close(true);
  -//}
  -//};
  -//this.cancellator.execute(closer);
  -}
  -
  -/**
   * Closes the pool and all disconnects all idle connections
   * Active connections will be closed upon the {...@link 
 java.sql.Connection#close close} method is called
   * on the underlying connection instead of being returned to the pool
  @@ -381,6 +369,7 @@
  //make space for 10 extra in case we flow over a bit
  if (properties.isFairQueue()) {
  idle = new FairBlockingQueuePooledConnection();
  +//idle = new