geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r803194 - in /geronimo/components/txmanager/trunk: ./ geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/
Date Tue, 11 Aug 2009 16:30:28 GMT
Author: djencks
Date: Tue Aug 11 16:30:27 2009
New Revision: 803194

URL: http://svn.apache.org/viewvc?rev=803194&view=rev
Log:
GERONIMO-4786 merge changes from 2.1 branch r780437, r801468, r801849, r803183

Modified:
    geronimo/components/txmanager/trunk/   (props changed)
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionReturnAction.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java
    geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java

Propchange: geronimo/components/txmanager/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Aug 11 16:30:27 2009
@@ -0,0 +1 @@
+/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1:780438-803185

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java?rev=803194&r1=803193&r2=803194&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java
Tue Aug 11 16:30:27 2009
@@ -103,7 +103,7 @@
     public void returnConnection(ConnectionInfo connectionInfo,
                                  ConnectionReturnAction connectionReturnAction) {
         if (log.isTraceEnabled()) {
-            log.trace("returning connection " + connectionInfo.getConnectionHandle() + "
for MCI " + connectionInfo.getManagedConnectionInfo() + " and MC " + connectionInfo.getManagedConnectionInfo().getManagedConnection()
+ " to pool " + this);
+            log.trace("returning connection " + connectionInfo.getConnectionHandle() + "
for MCI " + connectionInfo.getManagedConnectionInfo() + " to pool " + this);
         }
 
         // not strictly synchronized with destroy(), but pooled operations in internalReturn()
are...
@@ -120,9 +120,7 @@
         try {
             ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
             if (connectionReturnAction == ConnectionReturnAction.RETURN_HANDLE &&
mci.hasConnectionHandles()) {
-                if (log.isTraceEnabled()) {
-                    log.trace("Return request at pool with connection handles! " + connectionInfo.getConnectionHandle()
+ " for MCI " + connectionInfo.getManagedConnectionInfo() + " and MC " + connectionInfo.getManagedConnectionInfo().getManagedConnection()
+ " to pool " + this, new Exception("Stack trace"));
-                }
+                log.warn("Return request at pool with connection handles! " + connectionInfo.getConnectionHandle()
+ " for MCI " + connectionInfo.getManagedConnectionInfo() + " and MC " + connectionInfo.getManagedConnectionInfo().getManagedConnection()
+ " to pool " + this, new Exception("Stack trace"));
                 return;
             }
 
@@ -136,6 +134,14 @@
         }
     }
 
+
+    /**
+     *
+     * @param connectionInfo connection info to return to pool
+     * @param connectionReturnAction whether to return to pool or destroy
+     * @return true if a connection for which a permit was issued was returned (so the permit
should be released),
+     * false if no permit was issued (for instance if the connection was already in the pool
and we are destroying it).
+     */
     protected boolean internalReturn(ConnectionInfo connectionInfo, ConnectionReturnAction
connectionReturnAction) {
         ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
         ManagedConnection mc = mci.getManagedConnection();

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionReturnAction.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionReturnAction.java?rev=803194&r1=803193&r2=803194&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionReturnAction.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionReturnAction.java
Tue Aug 11 16:30:27 2009
@@ -27,12 +27,18 @@
  * @version 1.0
  */
 public class ConnectionReturnAction {
+    private final String name;
     public final static ConnectionReturnAction RETURN_HANDLE =
-            new ConnectionReturnAction();
+            new ConnectionReturnAction("RETURN_HANDLE");
     public final static ConnectionReturnAction DESTROY =
-            new ConnectionReturnAction();
+            new ConnectionReturnAction("DESTROY");
 
-    private ConnectionReturnAction() {
+    private ConnectionReturnAction(String name) {
+        this.name = name;
     }
 
+    @Override
+    public String toString() {
+        return "ConnectionReturnAction{" + name + '}';
+    }
 }

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java?rev=803194&r1=803193&r2=803194&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java
Tue Aug 11 16:30:27 2009
@@ -151,4 +151,9 @@
         return listener.isFirstConnectionInfo(connectionInfo);
     }
 
+    @Override
+    public String toString() {
+        return "ManagedConnectionInfo: " + super.toString() + ". mc: " + managedConnection
+ "]";
+    }
+    
 }

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java?rev=803194&r1=803193&r2=803194&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java
Tue Aug 11 16:30:27 2009
@@ -45,7 +45,6 @@
     private boolean selectOneAssumeMatch;
 
     //pool is mutable but only changed when protected by write lock on resizelock in superclass
-//    private PoolDeque pool;
     private final List<ManagedConnectionInfo> pool;
 
     public SinglePoolConnectionInterceptor(final ConnectionInterceptor next,
@@ -55,7 +54,6 @@
                                            int idleTimeoutMinutes,
                                            boolean selectOneAssumeMatch) {
         super(next, maxSize, minSize, blockingTimeoutMilliseconds, idleTimeoutMinutes);
-//        pool = new PoolDeque(maxSize);
         pool = new ArrayList<ManagedConnectionInfo>(maxSize);
         this.selectOneAssumeMatch = selectOneAssumeMatch;
     }
@@ -71,7 +69,7 @@
                 next.getConnection(connectionInfo);
                 connectionCount++;
                 if (log.isTraceEnabled()) {
-                    log.trace("Supplying new connection MCI: " + connectionInfo.getManagedConnectionInfo()
+ " MC: " + connectionInfo.getManagedConnectionInfo().getManagedConnection() + " from pool:
" + this);
+                    log.trace("Supplying new connection MCI: " + connectionInfo.getManagedConnectionInfo()
+ " from pool: " + this);
                 }
                 return;
             } else {
@@ -83,27 +81,16 @@
             if (selectOneAssumeMatch) {
                 connectionInfo.setManagedConnectionInfo(newMCI);
                 if (log.isTraceEnabled()) {
-                    log.trace("Supplying pooled connection without checking matching MCI:
" + connectionInfo.getManagedConnectionInfo() + " MC: " + connectionInfo.getManagedConnectionInfo().getManagedConnection()
+ " from pool: " + this);
+                    log.trace("Supplying pooled connection without checking matching MCI:
" + connectionInfo.getManagedConnectionInfo() + " from pool: " + this);
                 }
                 return;
             }
+            ManagedConnection matchedMC;
             try {
                 ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
-                ManagedConnection matchedMC = newMCI.getManagedConnectionFactory().matchManagedConnections(Collections.singleton(newMCI.getManagedConnection()),
+                matchedMC = newMCI.getManagedConnectionFactory().matchManagedConnections(Collections.singleton(newMCI.getManagedConnection()),
                         mci.getSubject(),
                         mci.getConnectionRequestInfo());
-                if (matchedMC != null) {
-                    connectionInfo.setManagedConnectionInfo(newMCI);
-                    if (log.isTraceEnabled()) {
-                        log.trace("Supplying pooled connection  MCI: " + connectionInfo.getManagedConnectionInfo()
+ " MC: " + connectionInfo.getManagedConnectionInfo().getManagedConnection() + " from pool:
" + this);
-                    }
-                } else {
-                    //matching failed.
-                    ConnectionInfo returnCI = new ConnectionInfo();
-                    returnCI.setManagedConnectionInfo(newMCI);
-                    returnConnection(returnCI, ConnectionReturnAction.RETURN_HANDLE);
-                    throw new ResourceException("The pooling strategy does not match the
MatchManagedConnections implementation.  Please investigate and reconfigure this pool");
-                }
             } catch (ResourceException e) {
                 //something is wrong: destroy connection, rethrow, release permit
                 ConnectionInfo returnCI = new ConnectionInfo();
@@ -111,6 +98,18 @@
                 returnConnection(returnCI, ConnectionReturnAction.DESTROY);
                 throw e;
             }
+            if (matchedMC != null) {
+                connectionInfo.setManagedConnectionInfo(newMCI);
+                if (log.isTraceEnabled()) {
+                    log.trace("Supplying pooled connection  MCI: " + connectionInfo.getManagedConnectionInfo()
+ " from pool: " + this);
+                }
+            } else {
+                //matching failed.
+                ConnectionInfo returnCI = new ConnectionInfo();
+                returnCI.setManagedConnectionInfo(newMCI);
+                returnConnection(returnCI, ConnectionReturnAction.RETURN_HANDLE);
+                throw new ResourceException("The pooling strategy does not match the MatchManagedConnections
implementation.  Please investigate and reconfigure this pool");
+            }
         }
     }
 
@@ -138,7 +137,12 @@
         pool.add(mci);
     }
 
+    /**
+     * @param mci managedConnectionInfo to remove from pool
+     * @return true if mci was not in pool already, false if mci was in pool already.
+     */
     protected boolean doRemove(ManagedConnectionInfo mci) {
+        log.info("Removing " + mci + " from pool " + this);
         return !pool.remove(mci);
     }
 

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java?rev=803194&r1=803193&r2=803194&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java
Tue Aug 11 16:30:27 2009
@@ -72,7 +72,12 @@
     }
 
     public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction)
{
-        if (connectionReturnAction == ConnectionReturnAction.DESTROY || connectionInfo.isUnshareable())
{
+        if (connectionReturnAction == ConnectionReturnAction.DESTROY
+                || connectionInfo.isUnshareable()
+                || !connectionInfo.getManagedConnectionInfo().hasConnectionHandles()) {
+            if (connections.get() == connectionInfo.getManagedConnectionInfo()) {
+                connections.remove();
+            }
             next.returnConnection(connectionInfo, connectionReturnAction);
         }
     }

Modified: geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java?rev=803194&r1=803193&r2=803194&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java
(original)
+++ geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java
Tue Aug 11 16:30:27 2009
@@ -77,18 +77,25 @@
             } else {
                 ManagedConnectionInfo managedConnectionInfo = managedConnectionInfos.getShared();
                 if (managedConnectionInfo != null) {
-                    connectionInfo.setManagedConnectionInfo(managedConnectionInfo);
-                    //return;
-                    if (log.isTraceEnabled()) {
-                        log.trace(
-                                "supplying connection from tx cache " + connectionInfo.getConnectionHandle()
+ " for managed connection " + connectionInfo.getManagedConnectionInfo().getManagedConnection()
+ " to tx caching interceptor " + this);
+                    ManagedConnectionInfo previousMci = connectionInfo.getManagedConnectionInfo();
+                    if (previousMci != null && previousMci != managedConnectionInfo
&& previousMci.getManagedConnection() != null) {
+                        //This might occur if more than one connection were obtained before
a UserTransaction were started.
+                        //enlists connection
+                        next.getConnection(connectionInfo);
+                        managedConnectionInfos.addUnshared(previousMci);
+                    } else {
+                        connectionInfo.setManagedConnectionInfo(managedConnectionInfo);
+
+                        //return;
+                        if (log.isTraceEnabled()) {
+                            log.trace("supplying connection from tx cache " + connectionInfo.getConnectionHandle()
+ " for managed connection " + connectionInfo.getManagedConnectionInfo().getManagedConnection()
+ " to tx caching interceptor " + this);
+                        }
                     }
                 } else {
                     next.getConnection(connectionInfo);
                     managedConnectionInfos.setShared(connectionInfo.getManagedConnectionInfo());
                     if (log.isTraceEnabled()) {
-                        log.trace(
-                                "supplying connection from pool " + connectionInfo.getConnectionHandle()
+ " for managed connection " + connectionInfo.getManagedConnectionInfo().getManagedConnection()
+ " to tx caching interceptor " + this);
+                        log.trace("supplying connection from pool " + connectionInfo.getConnectionHandle()
+ " for managed connection " + connectionInfo.getManagedConnectionInfo().getManagedConnection()
+ " to tx caching interceptor " + this);
                     }
                 }
             }
@@ -112,8 +119,7 @@
             if (transaction != null) {
                 if (TxUtil.isActive(transaction)) {
                     if (log.isTraceEnabled()) {
-                        log.trace(
-                                "tx active, not returning connection" + connectionInfo.getConnectionHandle()
+ " for managed connection " + connectionInfo.getManagedConnectionInfo().getManagedConnection()
+ " to tx caching interceptor " + this);
+                        log.trace("tx active, not returning connection" + connectionInfo.getConnectionHandle()
+ " for managed connection " + connectionInfo.getManagedConnectionInfo().getManagedConnection()
+ " to tx caching interceptor " + this);
                     }
                     return;
                 }
@@ -137,16 +143,14 @@
     private void internalReturn(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction)
{
         if (connectionInfo.getManagedConnectionInfo().hasConnectionHandles()) {
             if (log.isTraceEnabled()) {
-                log.trace(
-                        "not returning connection from tx cache (has handles) " + connectionInfo.getConnectionHandle()
+ " for managed connection " + connectionInfo.getManagedConnectionInfo().getManagedConnection()
+ " to tx caching interceptor " + this);
+                log.trace("not returning connection from tx cache (has handles) " + connectionInfo.getConnectionHandle()
+ " for managed connection " + connectionInfo.getManagedConnectionInfo().getManagedConnection()
+ " to tx caching interceptor " + this);
             }
             return;
         }
         //No transaction, no handles, we return it.
         next.returnConnection(connectionInfo, connectionReturnAction);
         if (log.isTraceEnabled()) {
-            log.trace(
-                    "completed return of connection through tx cache " + connectionInfo.getConnectionHandle()
+ " for MCI: " + connectionInfo.getManagedConnectionInfo() + " and MC " + connectionInfo.getManagedConnectionInfo().getManagedConnection()
+ " to tx caching interceptor " + this);
+            log.trace("completed return of connection through tx cache " + connectionInfo.getConnectionHandle()
+ " for MCI: " + connectionInfo.getManagedConnectionInfo() + " and MC " + connectionInfo.getManagedConnectionInfo().getManagedConnection()
+ " to tx caching interceptor " + this);
         }
     }
 



Mime
View raw message