svn commit: r720170 - /tomcat/tc6.0.x/trunk/STATUS.txt

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 03:30:28 2008
New Revision: 720170

URL: http://svn.apache.org/viewvc?rev=720170&view=rev
Log:
proposal

Modified:
tomcat/tc6.0.x/trunk/STATUS.txt

Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=720170&r1=720169&r2=720170&view=diff
==
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Mon Nov 24 03:30:28 2008
@@ -250,3 +250,9 @@
   http://svn.apache.org/viewvc?rev=719628&view=rev
   +1: markt, fhanik
   -1: 
+
+* Prevent async close NPE on already closed sockets
+  http://people.apache.org/~fhanik/tomcat/comet-close-2.patch
+  +1: fhanik
+  -1: 
+



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r720173 - /tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 03:32:02 2008
New Revision: 720173

URL: http://svn.apache.org/viewvc?rev=720173&view=rev
Log:
Fix NPE

Modified:
tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=720173&r1=720172&r2=720173&view=diff
==
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java 
(original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Mon Nov 
24 03:32:02 2008
@@ -1208,6 +1208,7 @@
 } else if (actionCode == ActionCode.ACTION_COMET_END) {
 comet = false;
 }  else if (actionCode == ActionCode.ACTION_COMET_CLOSE) {
+if (socket==null || socket.getAttachment(false)==null) return;
 NioEndpoint.KeyAttachment attach = 
(NioEndpoint.KeyAttachment)socket.getAttachment(false);
 attach.setCometOps(NioEndpoint.OP_CALLBACK);
 //notify poller if not on a tomcat thread
@@ -1216,6 +1217,7 @@
 socket.getPoller().cometInterest(socket);
 } else if (actionCode == ActionCode.ACTION_COMET_SETTIMEOUT) {
 if (param==null) return;
+if (socket==null || socket.getAttachment(false)==null) return;
 NioEndpoint.KeyAttachment attach = 
(NioEndpoint.KeyAttachment)socket.getAttachment(false);
 long timeout = ((Long)param).longValue();
 //if we are not piggy backing on a worker thread, set the timeout



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r720240 - /tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 09:59:50 2008
New Revision: 720240

URL: http://svn.apache.org/viewvc?rev=720240&view=rev
Log:
properly throw exception

Modified:

tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.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=720240&r1=720239&r2=720240&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 09:59:50 2008
@@ -517,7 +517,9 @@
 if (x instanceof SQLException) {
 throw (SQLException)x;
 } else {
-throw new SQLException(getStackTrace(x));
+SQLException ex  = new SQLException(x.getMessage());
+ex.initCause(x);
+throw ex;
 }
 }
 } finally {



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r720253 - /tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 10:47:49 2008
New Revision: 720253

URL: http://svn.apache.org/viewvc?rev=720253&view=rev
Log:
document how interceptors work and how to configure them

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

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=720253&r1=720252&r2=720253&view=diff
==
--- tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml (original)
+++ tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml Mon Nov 24 10:47:49 2008
@@ -300,7 +300,11 @@
 
   (String) A semicolon separated list of classnames extending 
org.apache.tomcat.jdbc.pool.JdbcInterceptor class.
  These interceptors will be inserted as an interceptor into the chain 
of operations on a java.sql.Connection object.
- The default value is null.
+ The default value is null.
+ Predefined interceptors:
+ org.apache.tomcat.jdbc.pool.interceptor.ConnectionState - keeps track 
of auto commit, read only, catalog and transaction isolation level.
+ org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer - keeps 
track of opened statements, and closes them when the connection is returned to 
the pool.
+  
 
 
 
@@ -373,6 +377,7 @@
 p.setMinIdle(10);
 p.setLogAbandoned(true);
 p.setRemoveAbandoned(true);
+
p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
 DataSource datasource = new DataSource();
 datasource.setPoolProperties(p); 
 
@@ -417,6 +422,7 @@
   logAbandoned="true"
   minEvictableIdleTimeMillis="3" 
   jmxEnabled="true"
+  
jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"
   username="root" 
   password="password" 
   driverClassName="com.mysql.jdbc.Driver"
@@ -426,6 +432,57 @@
 
   
   
+  
+Interceptors are a powerful way to enable, disable or modify 
functionality on a specific connection or its sub components.
+   There are many different use cases for when interceptors are useful. By 
default, and for performance reasons, the connection pool is stateless.
+   The only state the pool itself inserts are defaultAutoCommit, 
defaultReadOnly, defaultTransactionIsolation, defaultCatalog if 
+   these are set. These 4 properties are only set upon connection 
creation. Should these properties be modified during the usage of the 
connection,
+   the pool itself will not reset them.
+An interceptor has to extend the 
org.apache.tomcat.jdbc.pool.JdbcInterceptor class. This class is 
fairly simple, 
+   You will need to have a no arg constructor
+   
+   
+ public JdbcInterceptor() {
+ }
+   
+
+   When a connection is borrowed from the pool, the interceptor can 
initialize or in some other way react to the event by implementing the 
+   
+   
+ public abstract void reset(ConnectionPool parent, PooledConnection 
con);
+   
+   method. This method gets called with two parameters, a reference to the 
connection pool itself ConnectionPool parent 
+   and a reference to the underlying connection PooledConnection 
con.
+
+
+   When a method on the java.sql.Connection object is 
invoked, it will cause the 
+   
+ public Object invoke(Object proxy, Method method, Object[] args) 
throws Throwable
+   
+   method to get invoked. The Method method is the actual 
method invoked, and Object[] args are the arguments.
+   To look at a very simple example, where we demonstrate how to make the 
invokation to java.sql.Connection.close() a noop 
+   if the connection has been closed
+   
+   
+if (CLOSE_VAL==method.getName()) {
+if (isClosed()) return null; //noop for already closed.
+} 
+return super.invoke(proxy,method,args);
+
+There is an observation being made. It is the comparison of the method 
name. One way to do this would be to do
+"close".equals(method.getName()).
+Above we see a direct reference comparison between the method name and 
static final String reference.
+According to the JVM spec, method names and static final String end up 
in a shared constant pool, so the reference comparison should work.
+   
+Configuring interceptors
+   Interceptors are configured using the jdbcInterceptors 
property or the setJdbcInterceptors method.
+   An interceptor can have properties, and would be configured like this
+   
+   
+   String 
jdbcInterc

svn commit: r720254 - /tomcat/trunk/modules/jdbc-pool/doc/changelog.xml

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 10:49:40 2008
New Revision: 720254

URL: http://svn.apache.org/viewvc?rev=720254&view=rev
Log:
update changelog

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

Modified: tomcat/trunk/modules/jdbc-pool/doc/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/doc/changelog.xml?rev=720254&r1=720253&r2=720254&view=diff
==
--- tomcat/trunk/modules/jdbc-pool/doc/changelog.xml (original)
+++ tomcat/trunk/modules/jdbc-pool/doc/changelog.xml Mon Nov 24 10:49:40 2008
@@ -28,9 +28,10 @@
   
 
 
-
+
   
 
+  720253Document how to use interceptors 
   717972Added an interceptor that will clean up non 
closed statements when a connection is returned to the pool. 
(org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer)
   713763Improve connection state handling
713763Improve connection state handling



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r720265 - /tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 11:25:22 2008
New Revision: 720265

URL: http://svn.apache.org/viewvc?rev=720265&view=rev
Log:
Add in framework for comparing on either reference or string value

Modified:

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

Modified: 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java?rev=720265&r1=720264&r2=720265&view=diff
==
--- 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
 (original)
+++ 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
 Mon Nov 24 11:25:22 2008
@@ -35,6 +35,7 @@
 protected List properties = null; 
 
 private JdbcInterceptor next = null;
+private boolean useEquals = false;
 
 public JdbcInterceptor() {
 }
@@ -55,6 +56,14 @@
 this.next = next;
 }
 
+public boolean compare(String methodName, Method method) {
+if (useEquals()) {
+return methodName.equals(method.getName());
+} else {
+return methodName==method.getName();
+}
+}
+
 /**
  * Gets called each time the connection is borrowed from the pool
  * @param parent - the connection pool owning the connection
@@ -70,4 +79,15 @@
 this.properties = properties;
 }
 
+public boolean getUseEquals() {
+return useEquals();
+}
+
+public boolean useEquals() {
+return getUseEquals();
+}
+
+public void setUseEquals(boolean useEquals) {
+this.useEquals = useEquals;
+}
 }



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r720267 - in /tomcat/trunk/modules/jdbc-pool: build.xml doc/changelog.xml doc/jdbc-pool.xml sign.sh test/org/apache/tomcat/jdbc/test/SimplePOJOExample.java

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 11:27:37 2008
New Revision: 720267

URL: http://svn.apache.org/viewvc?rev=720267&view=rev
Log:
Add doc, update version number

Modified:
tomcat/trunk/modules/jdbc-pool/build.xml
tomcat/trunk/modules/jdbc-pool/doc/changelog.xml
tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml
tomcat/trunk/modules/jdbc-pool/sign.sh

tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/SimplePOJOExample.java

Modified: tomcat/trunk/modules/jdbc-pool/build.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/build.xml?rev=720267&r1=720266&r2=720267&view=diff
==
--- tomcat/trunk/modules/jdbc-pool/build.xml (original)
+++ tomcat/trunk/modules/jdbc-pool/build.xml Mon Nov 24 11:27:37 2008
@@ -23,7 +23,7 @@
   
   
   
-  
+  
   
   
   

Modified: tomcat/trunk/modules/jdbc-pool/doc/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/doc/changelog.xml?rev=720267&r1=720266&r2=720267&view=diff
==
--- tomcat/trunk/modules/jdbc-pool/doc/changelog.xml (original)
+++ tomcat/trunk/modules/jdbc-pool/doc/changelog.xml Mon Nov 24 11:27:37 2008
@@ -28,7 +28,7 @@
   
 
 
-
+
   
 
   720253Document how to use interceptors 

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=720267&r1=720266&r2=720267&view=diff
==
--- tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml (original)
+++ tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml Mon Nov 24 11:27:37 2008
@@ -473,6 +473,16 @@
 "close".equals(method.getName()).
 Above we see a direct reference comparison between the method name and 
static final String reference.
 According to the JVM spec, method names and static final String end up 
in a shared constant pool, so the reference comparison should work.
+One could of course do this as well:
+   
+   
+if (compare(CLOSE_VAL,method.getName())) {
+if (isClosed()) return null; //noop for already closed.
+} 
+return super.invoke(proxy,method,args);
+
+The compare(String,Method) will use the 
useEquals flag on an interceptor and do either reference 
comparison or 
+a string value comparison when the useEquals=true flag is 
set.

 Configuring interceptors
Interceptors are configured using the jdbcInterceptors 
property or the setJdbcInterceptors method.

Modified: tomcat/trunk/modules/jdbc-pool/sign.sh
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/sign.sh?rev=720267&r1=720266&r2=720267&view=diff
==
--- tomcat/trunk/modules/jdbc-pool/sign.sh (original)
+++ tomcat/trunk/modules/jdbc-pool/sign.sh Mon Nov 24 11:27:37 2008
@@ -1,4 +1,4 @@
-VERSION=v1.0.3-beta
+VERSION=v1.0.4-beta
 for i in $(find output/release/$VERSION -name "*.zip" -o -name "*.tar.gz"); do
   echo Signing $i
   echo $1|gpg --passphrase-fd 0 -a -b $i

Modified: 
tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/SimplePOJOExample.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/SimplePOJOExample.java?rev=720267&r1=720266&r2=720267&view=diff
==
--- 
tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/SimplePOJOExample.java
 (original)
+++ 
tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/SimplePOJOExample.java
 Mon Nov 24 11:27:37 2008
@@ -44,6 +44,7 @@
 p.setRemoveAbandonedTimeout(60);
 p.setMinEvictableIdleTimeMillis(3);
 p.setMinIdle(10);
+
p.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
 p.setLogAbandoned(true);
 p.setRemoveAbandoned(true);
 DataSource datasource = new DataSource();



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



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

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 12:33:17 2008
New Revision: 720280

URL: http://svn.apache.org/viewvc?rev=720280&view=rev
Log:
implement useEquals for the connection pool itself, does not apply to 
interceptors, they can manage that on their own

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/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/ProxyConnection.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=720280&r1=720279&r2=720280&view=diff
==
--- tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml (original)
+++ tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml Mon Nov 24 12:33:17 2008
@@ -324,7 +324,11 @@
  implementation for the list of the idle connections. The default 
value is false.
   
 
-
+
+  (boolean) Set to true if you wish the ProxyConnection 
class to use String.equals instead of 
+ == when comparing method names. This property does not 
apply to added interceptors as those are configured individually.
+ The default value is false.
+ 
 
   
 

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=720280&r1=720279&r2=720280&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 12:33:17 2008
@@ -131,7 +131,7 @@
 JdbcInterceptor handler = con.getHandler();
 if (handler==null) {
 //build the proxy handler
-handler = new ProxyConnection(this,con);
+handler = new 
ProxyConnection(this,con,getPoolProperties().isUseEquals());
 //set up the interceptor chain
 PoolProperties.InterceptorDefinition[] proxies = 
getPoolProperties().getJdbcInterceptorsAsArray();
 for (int i=proxies.length-1; i>=0; i--) {

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=720280&r1=720279&r2=720280&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
 Mon Nov 24 12:33:17 2008
@@ -102,6 +102,8 @@
 protected final static String PROP_JMX_ENABLED = "jmxEnabled";
 protected final static String PROP_FAIR_QUEUE = "fairQueue";
 
+protected static final String PROP_USE_EQUALS = "useEquals";
+
 public static final int UNKNOWN_TRANSACTIONISOLATION = -1;
 
 
@@ -138,7 +140,8 @@
 PROP_INITSQL,
 PROP_INTERCEPTORS,
 PROP_JMX_ENABLED,
-PROP_FAIR_QUEUE
+PROP_FAIR_QUEUE,
+PROP_USE_EQUALS
 };
 
 // -- ObjectFactory Methods
@@ -389,6 +392,11 @@
 
dataSource.getPoolProperties().setFairQueue(Boolean.parseBoolean(value));
 }
 
+value = properties.getProperty(PROP_USE_EQUALS);
+if (value != null) {
+
dataSource.getPoolProperties().setUseEquals(Boolean.parseBoolean(value));
+}
+
 
 // Return the configured DataSource instance
 DataSource ds = getDataSource(dataSource);

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=720280&r1=720279&r2=720280&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
 Mon Nov 24 12:33:17 2008
@@ -316,5 +316,9 @@
 throw new RuntimeException(x);
 }
 }
+
+public void setUseEquals(boolean useEquals) {
+this.getPoolProperties().setUseEquals(useEquals);
+}
 
 }

Modified: 
tomcat/trunk/mod

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

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 12:41:38 2008
New Revision: 720282

URL: http://svn.apache.org/viewvc?rev=720282&view=rev
Log:
implemented use equals attribute everywhere

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

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

tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/AbstractCreateStatementInterceptor.java

tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.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=720282&r1=720281&r2=720282&view=diff
==
--- tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml (original)
+++ tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml Mon Nov 24 12:41:38 2008
@@ -328,7 +328,8 @@
   (boolean) Set to true if you wish the ProxyConnection 
class to use String.equals instead of 
  == when comparing method names. This property does not 
apply to added interceptors as those are configured individually.
  The default value is false.
- 
+   
+
 
   
 

Modified: 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java?rev=720282&r1=720281&r2=720282&view=diff
==
--- 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
 (original)
+++ 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
 Mon Nov 24 12:41:38 2008
@@ -56,14 +56,18 @@
 this.next = next;
 }
 
-public boolean compare(String methodName, Method method) {
+public boolean compare(String name1, String name2) {
 if (useEquals()) {
-return methodName.equals(method.getName());
+return name1.equals(name2);
 } else {
-return methodName==method.getName();
+return name1==name2;
 }
 }
 
+public boolean compare(String methodName, Method method) {
+return compare(methodName, method.getName());
+}
+
 /**
  * Gets called each time the connection is borrowed from the pool
  * @param parent - the connection pool owning the connection

Modified: 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/AbstractCreateStatementInterceptor.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/AbstractCreateStatementInterceptor.java?rev=720282&r1=720281&r2=720282&view=diff
==
--- 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/AbstractCreateStatementInterceptor.java
 (original)
+++ 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/AbstractCreateStatementInterceptor.java
 Mon Nov 24 12:41:38 2008
@@ -40,7 +40,7 @@
 
 @Override
 public Object invoke(Object proxy, Method method, Object[] args) throws 
Throwable {
-if (CLOSE_VAL==method.getName()) {
+if (compare(CLOSE_VAL,method)) {
 closeInvoked();
 return super.invoke(proxy, method, args);
 } else {
@@ -70,7 +70,7 @@
 
 protected boolean process(String[] names, Method method, boolean process) {
 for (int i=0; (!process) && ihttp://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java?rev=720282&r1=720281&r2=720282&view=diff
==
--- 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java
 (original)
+++ 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java
 Mon Nov 24 12:41:38 2008
@@ -99,12 +99,12 @@
 boolean read = false;
 int index = -1;
 for (int i=0; (!read) && i

svn commit: r720283 - /tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 12:42:12 2008
New Revision: 720283

URL: http://svn.apache.org/viewvc?rev=720283&view=rev
Log:
fix sample code

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

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=720283&r1=720282&r2=720283&view=diff
==
--- tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml (original)
+++ tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml Mon Nov 24 12:42:12 2008
@@ -481,7 +481,7 @@
 One could of course do this as well:


-if (compare(CLOSE_VAL,method.getName())) {
+if (compare(CLOSE_VAL,method)) {
 if (isClosed()) return null; //noop for already closed.
 } 
 return super.invoke(proxy,method,args);



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r720285 - /tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 12:43:32 2008
New Revision: 720285

URL: http://svn.apache.org/viewvc?rev=720285&view=rev
Log:
eclipse autocompletion is gonna kill me

Modified:

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

Modified: 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java?rev=720285&r1=720284&r2=720285&view=diff
==
--- 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
 (original)
+++ 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
 Mon Nov 24 12:43:32 2008
@@ -88,7 +88,7 @@
 }
 
 public boolean useEquals() {
-return useEquals();
+return useEquals;
 }
 
 public void setUseEquals(boolean useEquals) {



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r720284 - /tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 12:43:15 2008
New Revision: 720284

URL: http://svn.apache.org/viewvc?rev=720284&view=rev
Log:
fix bug

Modified:

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

Modified: 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java?rev=720284&r1=720283&r2=720284&view=diff
==
--- 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
 (original)
+++ 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
 Mon Nov 24 12:43:15 2008
@@ -88,7 +88,7 @@
 }
 
 public boolean useEquals() {
-return getUseEquals();
+return useEquals();
 }
 
 public void setUseEquals(boolean useEquals) {



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r720289 - /tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 12:52:26 2008
New Revision: 720289

URL: http://svn.apache.org/viewvc?rev=720289&view=rev
Log:
use same method names everywhere

Modified:

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

Modified: 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java?rev=720289&r1=720288&r2=720289&view=diff
==
--- 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
 (original)
+++ 
tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
 Mon Nov 24 12:52:26 2008
@@ -57,7 +57,7 @@
 }
 
 public boolean compare(String name1, String name2) {
-if (useEquals()) {
+if (isUseEquals()) {
 return name1.equals(name2);
 } else {
 return name1==name2;
@@ -83,11 +83,7 @@
 this.properties = properties;
 }
 
-public boolean getUseEquals() {
-return useEquals();
-}
-
-public boolean useEquals() {
+public boolean isUseEquals() {
 return useEquals;
 }
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r720306 - in /tomcat/trunk/modules/jdbc-pool: java/org/apache/tomcat/jdbc/pool/ConnectionPool.java java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java test/org/apache/tomcat/jdbc/test/

2008-11-24 Thread fhanik
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 c = new ExchangeCountDownLatch(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]



svn commit: r720310 - /tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 14:21:15 2008
New Revision: 720310

URL: http://svn.apache.org/viewvc?rev=720310&view=rev
Log:
make sure the test is time based

Modified:

tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java

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=720310&r1=720309&r2=720310&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:21:15 2008
@@ -48,7 +48,7 @@
 totalfetch += t.nroffetch;
 minfetch = Math.min(minfetch, t.nroffetch);
 maxfetch = Math.max(maxfetch, t.nroffetch);
-//System.out.println(t.getName()+" : Nr-of-fetch:"+t.nroffetch+ " 
Max fetch Time:"+t.max+" :Max close time:"+t.cmax);
+System.out.println(t.getName()+" : Nr-of-fetch:"+t.nroffetch+ " 
Max fetch Time:"+t.max+" :Max close time:"+t.cmax);
 }
 System.out.println("["+name+"] Max fetch:"+maxfetch+" Min 
fetch:"+minfetch+" Average fetch:"+
(((float)totalfetch))/(float)threads.length);
@@ -73,7 +73,9 @@
 for (int i=0; i=FairnessTest.this.complete) break;
 long start = System.nanoTime();
 Connection con = null;
 try {



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r720313 - /tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 14:28:03 2008
New Revision: 720313

URL: http://svn.apache.org/viewvc?rev=720313&view=rev
Log:
print out some useful test data

Modified:

tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java

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=720313&r1=720312&r2=720313&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:28:03 2008
@@ -48,9 +48,9 @@
 totalfetch += t.nroffetch;
 minfetch = Math.min(minfetch, t.nroffetch);
 maxfetch = Math.max(maxfetch, t.nroffetch);
-System.out.println(t.getName()+" : Nr-of-fetch:"+t.nroffetch+ " 
Max fetch Time:"+t.max+" :Max close time:"+t.cmax);
+System.out.println(t.getName()+" : Nr-of-fetch:"+t.nroffetch+ " 
Max fetch Time:"+(((float)t.max)/100f)+"ms. :Max close 
time:"+(((float)t.cmax)/100f)+"ms.");
 }
-System.out.println("["+name+"] Max fetch:"+maxfetch+" Min 
fetch:"+minfetch+" Average fetch:"+
+System.out.println("["+name+"] Max fetch:"+(maxfetch)+" Min 
fetch:"+(minfetch)+" Average fetch:"+
(((float)totalfetch))/(float)threads.length);
 }
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r720317 - /tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java

2008-11-24 Thread fhanik
Author: fhanik
Date: Mon Nov 24 14:39:48 2008
New Revision: 720317

URL: http://svn.apache.org/viewvc?rev=720317&view=rev
Log:
start to add back in features

Modified:

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

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=720317&r1=720316&r2=720317&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:39:48 2008
@@ -76,7 +76,7 @@
 lock.lock();
 try {
 result = items.poll();
-if (result==null) {
+if (result==null && timeout>0) {
 ExchangeCountDownLatch c = new ExchangeCountDownLatch(1);
 waiters.addLast(c);
 lock.unlock();



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DeltaManager initialization delay

2008-11-24 Thread Jason
Adds a threadsafe latch to the DeltaManager which is used to block
processing of cluster messages until local applications have completed
initialization.

Includes changes to the DeltaManager to create the latch based on
configuration, changes to Catalina to automatically open the latch when
initialization is complete, a constant used to as the attribute key in the
ServletContext and an modification to the mbean-descriptor for the new
DeltaManager attribute.

Also includes a handful of style cleanups interspersed (spelling, removing
compiler warnings about type checking, removing spaces before semi colons
and blank lines before and after braces) throughout.

  - Jason

"That's the problem. He's a brilliant lunatic and you can't tell
which way he'll jump --
like his game he's impossible to analyse --
you can't dissect him, predict him --
which of course means he's not a lunatic at all."


Index: catalina/Globals.java
===
--- catalina/Globals.java(revision 719433)
+++ catalina/Globals.java(working copy)
@@ -36,6 +36,14 @@
 "org.apache.catalina.deploy.alt_dd";

 /**
+ * The servlet context attribute under which we store the concurrent
latch
+ * used to block processing cluster messages until after local
application
+ * initialization
+ */
+public static final String CLUSTER_DELAY =
+"org.apache.catalina.ha.delay";
+
+/**
  * The request attribute under which we store the array of
X509Certificate
  * objects representing the certificate chain presented by our client,
  * if any.
Index: catalina/ha/session/DeltaManager.java
===
--- catalina/ha/session/DeltaManager.java(revision 719433)
+++ catalina/ha/session/DeltaManager.java(working copy)
@@ -26,11 +26,15 @@
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
+import java.util.concurrent.CountDownLatch;
+
+import javax.servlet.ServletContext;

 import org.apache.catalina.Cluster;
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.Engine;
+import org.apache.catalina.Globals;
 import org.apache.catalina.Host;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleListener;
@@ -38,13 +42,13 @@
 import org.apache.catalina.Valve;
 import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.ha.CatalinaCluster;
+import org.apache.catalina.ha.ClusterManager;
 import org.apache.catalina.ha.ClusterMessage;
 import org.apache.catalina.ha.tcp.ReplicationValve;
 import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.io.ReplicationStream;
 import org.apache.catalina.util.LifecycleSupport;
 import org.apache.catalina.util.StringManager;
-import org.apache.catalina.ha.ClusterManager;

 /**
  * The DeltaManager manages replicated sessions by only replicating the
deltas
@@ -62,10 +66,11 @@
  * @author Craig R. McClanahan
  * @author Jean-Francois Arcand
  * @author Peter Rossbach
+ * @author Jason Lunn
  * @version $Revision$ $Date$
  */

-public class DeltaManager extends ClusterManagerBase{
+public class DeltaManager extends ClusterManagerBase {

 //  Security
Classes
 public static org.apache.juli.logging.Log log =
org.apache.juli.logging.LogFactory.getLog(DeltaManager.class);
@@ -106,6 +111,18 @@
 protected LifecycleSupport lifecycle = new LifecycleSupport(this);

 /**
+ * Flag indicating that messageReceived(ClusterMessage) should block
until
+ * all local applications have completed initialization
+ */
+protected boolean delay = false;
+
+/**
+ * Barrier used to receive notification from other threads that it is
okay
+ * to process incoming messages from the cluster
+ */
+private CountDownLatch gate = null;
+
+/**
  * The maximum number of active Sessions allowed, or -1 for no limit.
  */
 private int maxActiveSessions = -1;
@@ -121,8 +138,8 @@
 /**
  * wait time between send session block (default 2 sec)
  */
-private int sendAllSessionsWaitTime = 2 * 1000 ;
-private ArrayList receivedMessageQueue = new ArrayList() ;
+private int sendAllSessionsWaitTime = 2 * 1000;
+private ArrayList receivedMessageQueue = new
ArrayList() ;
 private boolean receiverQueue = false ;
 private boolean stateTimestampDrop = true ;
 private long stateTransferCreateSendTime;
@@ -175,6 +192,27 @@
 public String getName() {
 return name;
 }
+
+/**
+ * Set the member that indicates processing messages should wait for
local
+ * initialization of applications to complete
+ *
+ * @param delayed If true, processing messageReceived(ClusterMessage)
will
+ * block until local web applications have completed initialization.
+ */
+public void setDelay ( bool

Re: DeltaManager initialization delay

2008-11-24 Thread Filip Hanik - Dev Lists

Jason, thank you for your patch, please open an incident and attach it there

https://issues.apache.org/bugzilla/index.cgi

Filip

Jason wrote:
Adds a threadsafe latch to the DeltaManager which is used to block 
processing of cluster messages until local applications have completed 
initialization.


Includes changes to the DeltaManager to create the latch based on 
configuration, changes to Catalina to automatically open the latch 
when initialization is complete, a constant used to as the attribute 
key in the ServletContext and an modification to the mbean-descriptor 
for the new DeltaManager attribute.


Also includes a handful of style cleanups interspersed (spelling, 
removing compiler warnings about type checking, removing spaces before 
semi colons and blank lines before and after braces) throughout.


  - Jason

"That's the problem. He's a brilliant lunatic and you can't tell
which way he'll jump --
like his game he's impossible to analyse --
you can't dissect him, predict him --
which of course means he's not a lunatic at all."


Index: catalina/Globals.java
===
--- catalina/Globals.java(revision 719433)
+++ catalina/Globals.java(working copy)
@@ -36,6 +36,14 @@
 "org.apache.catalina.deploy.alt_dd";
 
 /**
+ * The servlet context attribute under which we store the 
concurrent latch
+ * used to block processing cluster messages until after local 
application

+ * initialization
+ */
+public static final String CLUSTER_DELAY =
+"org.apache.catalina.ha.delay";
+
+/**
  * The request attribute under which we store the array of 
X509Certificate
  * objects representing the certificate chain presented by our 
client,

  * if any.
Index: catalina/ha/session/DeltaManager.java
===
--- catalina/ha/session/DeltaManager.java(revision 719433)
+++ catalina/ha/session/DeltaManager.java(working copy)
@@ -26,11 +26,15 @@
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
+import java.util.concurrent.CountDownLatch;
+
+import javax.servlet.ServletContext;
 
 import org.apache.catalina.Cluster;

 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.Engine;
+import org.apache.catalina.Globals;
 import org.apache.catalina.Host;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleListener;
@@ -38,13 +42,13 @@
 import org.apache.catalina.Valve;
 import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.ha.CatalinaCluster;
+import org.apache.catalina.ha.ClusterManager;
 import org.apache.catalina.ha.ClusterMessage;
 import org.apache.catalina.ha.tcp.ReplicationValve;
 import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.io.ReplicationStream;
 import org.apache.catalina.util.LifecycleSupport;
 import org.apache.catalina.util.StringManager;
-import org.apache.catalina.ha.ClusterManager;
 
 /**
  * The DeltaManager manages replicated sessions by only replicating 
the deltas

@@ -62,10 +66,11 @@
  * @author Craig R. McClanahan
  * @author Jean-Francois Arcand
  * @author Peter Rossbach
+ * @author Jason Lunn
  * @version $Revision$ $Date$
  */
 
-public class DeltaManager extends ClusterManagerBase{

+public class DeltaManager extends ClusterManagerBase {
 
 //  Security 
Classes
 public static org.apache.juli.logging.Log log = 
org.apache.juli.logging.LogFactory.getLog(DeltaManager.class);

@@ -106,6 +111,18 @@
 protected LifecycleSupport lifecycle = new LifecycleSupport(this);
 
 /**
+ * Flag indicating that messageReceived(ClusterMessage) should 
block until

+ * all local applications have completed initialization
+ */
+protected boolean delay = false;
+   
+/**
+ * Barrier used to receive notification from other threads that 
it is okay

+ * to process incoming messages from the cluster
+ */
+private CountDownLatch gate = null;
+   
+/**

  * The maximum number of active Sessions allowed, or -1 for no limit.
  */
 private int maxActiveSessions = -1;
@@ -121,8 +138,8 @@
 /**
  * wait time between send session block (default 2 sec)
  */
-private int sendAllSessionsWaitTime = 2 * 1000 ;
-private ArrayList receivedMessageQueue = new ArrayList() ;
+private int sendAllSessionsWaitTime = 2 * 1000;
+private ArrayList receivedMessageQueue = new 
ArrayList() ;

 private boolean receiverQueue = false ;
 private boolean stateTimestampDrop = true ;
 private long stateTransferCreateSendTime;
@@ -175,6 +192,27 @@
 public String getName() {
 return name;
 }
+   
+/**
+ * Set the member that indicates processing messages should wait 
for local

+ * initialization of applications to complete
+ *
+ 

DO NOT REPLY [Bug 46284] New: Add flag to DeltaManager that blocks processing cluster messages until local applicaiton initialization is completed

2008-11-24 Thread bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=46284

   Summary: Add flag to DeltaManager that blocks processing cluster
messages until local applicaiton initialization is
completed
   Product: Tomcat 6
   Version: 6.0.18
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Cluster
AssignedTo: dev@tomcat.apache.org
ReportedBy: [EMAIL PROTECTED]


Created an attachment (id=22928)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=22928)
A multi-file patch that includes changes that allow DeltaManager to block
processing of cluster messages until local application initialization is
complete

Suggested enhancement to DeltaManager that allows a configuration element to
control whether incoming cluster messages should be blocked until after local
applications are done initializing.

The idea is that there exist some web applications (I know of at least one
commercial app [that I happen to support during working hours]) that, when
deployed on a cluster with session replication, fails when the cluster is
implemented with Tomcat but works fine when using other application containers.

The inspiration for this enhancement is a comment from the vendor's engineering
support, who tell me that other application containers (WebSphere and WebLogic,
at least) initialize local applications before beginning to process session
replication messages from the cluster.

The attached patch gives the Tomcat user the option of continuing to begin
processing session replication messages from the cluster immediately (the
default), or block processing those messages until local applications have
completed initialization.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]