diff --git a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/ResourceHandle.java b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/ResourceHandle.java index 0ac1f7f0cc5..be672a1660a 100644 --- a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/ResourceHandle.java +++ b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/ResourceHandle.java @@ -359,7 +359,7 @@ public int hashCode() { @Override public String toString() { - return String.valueOf(id); + return ""; } public void setConnectionErrorOccurred() { diff --git a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/listener/LocalTxConnectionEventListener.java b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/listener/LocalTxConnectionEventListener.java index 36c03a57491..508cf05c7d8 100644 --- a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/listener/LocalTxConnectionEventListener.java +++ b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/listener/LocalTxConnectionEventListener.java @@ -17,21 +17,24 @@ package com.sun.enterprise.resource.listener; +import java.util.IdentityHashMap; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; import com.sun.enterprise.connectors.ConnectorRuntime; import com.sun.enterprise.resource.ResourceHandle; import com.sun.enterprise.resource.pool.PoolManager; - +import com.sun.logging.LogDomains; import jakarta.resource.spi.ConnectionEvent; import jakarta.resource.spi.ManagedConnection; -import java.util.IdentityHashMap; -import java.util.Map; - /** * @author Binod P.G */ public class LocalTxConnectionEventListener extends ConnectionEventListener { + private static final Logger logger = LogDomains.getLogger(ResourceHandle.class, LogDomains.RSR_LOGGER); + /** * A shortcut to the singleton PoolManager instance. Field could also be removed. */ @@ -56,14 +59,33 @@ public class LocalTxConnectionEventListener extends ConnectionEventListener { public LocalTxConnectionEventListener(ResourceHandle resource) { this.resource = resource; + + if (logger.isLoggable(Level.FINE)) { + logger.log(Level.FINE, "LocalTxConnectionEventListener constructor, resource=" + resource + ", this=" + this); + } } @Override public synchronized void connectionClosed(ConnectionEvent evt) { + if (logger.isLoggable(Level.FINE)) { + logger.log(Level.FINE, "LocalTxConnectionEventListener.connectionClosed START, resource=" + resource + ", this=" + this); + for (Object key : associatedHandles.keySet()) { + ResourceHandle associatedHandle = associatedHandles.get(key); + logger.log(Level.FINE, + "LocalTxConnectionEventListener.connectionClosed associatedHandles: key=" + key + ", handle=" + associatedHandle); + logger.log(Level.FINE, + "LocalTxConnectionEventListener.connectionClosed associatedHandles: resource=" + associatedHandle.getResource()); + } + } + Object connectionHandle = evt.getConnectionHandle(); ResourceHandle handle = associatedHandles.getOrDefault(connectionHandle, resource); // ManagedConnection instance is still valid and put back in the pool: do not remove the event listener. poolManager.resourceClosed(handle); + + if (logger.isLoggable(Level.FINE)) { + logger.log(Level.FINE, "LocalTxConnectionEventListener.connectionClosed END, resource=" + resource + ", handle=" + handle + ", this=" + this); + } } @Override @@ -117,6 +139,9 @@ public void localTransactionRolledback(ConnectionEvent evt) { * @param resourceHandle the original Handle */ public synchronized void associateHandle(Object userHandle, ResourceHandle resourceHandle) { + if (logger.isLoggable(Level.FINE)) { + logger.log(Level.FINE, "LocalTxConnectionEventListener associateHandle, userHandle=" + userHandle + ", resourceHandle=" + resourceHandle + ", this=" + this); + } associatedHandles.put(userHandle, resourceHandle); } @@ -128,6 +153,9 @@ public synchronized void associateHandle(Object userHandle, ResourceHandle resou * can also indicate that the map previously associated null with userHandle. */ public synchronized ResourceHandle removeAssociation(Object userHandle) { + if (logger.isLoggable(Level.FINE)) { + logger.log(Level.FINE, "LocalTxConnectionEventListener removeAssociation, userHandle=" + userHandle + ", this=" + this); + } return associatedHandles.remove(userHandle); } @@ -136,6 +164,8 @@ public synchronized ResourceHandle removeAssociation(Object userHandle) { * @return The clone of the associatedHandles map. */ public synchronized Map getAssociatedHandlesAndClearMap() { + logger.log(Level.FINE, "LocalTxConnectionEventListener getAssociatedHandlesAndClearMap, this=" + this); + // Clone the associatedHandles, because we will clear the list in this method IdentityHashMap result = (IdentityHashMap) associatedHandles.clone(); diff --git a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/AbstractPoolManager.java b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/AbstractPoolManager.java index e8b8c557417..9171c6664c5 100644 --- a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/AbstractPoolManager.java +++ b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/AbstractPoolManager.java @@ -17,15 +17,6 @@ package com.sun.enterprise.resource.pool; -<<<<<<< Upstream, based on origin/master -import com.sun.enterprise.resource.ResourceSpec; - -import java.util.concurrent.ConcurrentHashMap; - -import org.glassfish.resourcebase.resources.api.PoolInfo; - -======= ->>>>>>> f4ffa0b Part 3 for issue #24900 More documentation and more unit test coverage. /** * Abstract Pool manager for unimplemented features. Throws UnsupportedOperationException when invoked. */ diff --git a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/ConnectionPool.java b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/ConnectionPool.java index 799f2aad290..8ca41313a51 100644 --- a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/ConnectionPool.java +++ b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/ConnectionPool.java @@ -1099,6 +1099,8 @@ public void resourceClosed(ResourceHandle handle) throws IllegalStateException { if (state.isUnenlisted() || (poolTxHelper.isNonXAResource(handle) && poolTxHelper.isLocalTransactionInProgress() && poolTxHelper.isLocalResourceEligibleForReuse(handle))) { + // Note: the call to isLocalResourceEligibleForReuse can change the enlisted state of the + // handle to false if the resource is eligible for reuse. freeUnenlistedResource(handle); } @@ -1139,6 +1141,7 @@ protected void freeUnenlistedResource(ResourceHandle h) { } protected void freeResource(ResourceHandle resourceHandle) { + LOG.log(FINE, "freeResource handle: {0}", resourceHandle); try { getResourceFromPoolAndFreeResourceMethodsLock.lock(); if (cleanupResource(resourceHandle)) { @@ -1162,7 +1165,6 @@ protected void freeResource(ResourceHandle resourceHandle) { } finally { getResourceFromPoolAndFreeResourceMethodsLock.unlock(); } - } /** diff --git a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/PoolManagerImpl.java b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/PoolManagerImpl.java index 3b6875b4d98..99321943d88 100644 --- a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/PoolManagerImpl.java +++ b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/PoolManagerImpl.java @@ -140,7 +140,10 @@ void createAndInitPool(final PoolInfo poolInfo, PoolType poolType, Hashtable env // invoked by DataSource objects to obtain a connection @Override public Object getResource(ResourceSpec resourceSpec, ResourceAllocator resourceAllocator, ClientSecurityInfo clientSecurityInfo) throws PoolingException, RetryableUnavailableException { - + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "PoolManagerImpl.getResource START, resourceSpec=" + resourceSpec + "\nresourceAllocator=" + + resourceAllocator + "\nclientSecurityInfo=" + clientSecurityInfo); + } Transaction transaction = null; boolean transactional = resourceAllocator.isTransactional(); @@ -149,7 +152,9 @@ public Object getResource(ResourceSpec resourceSpec, ResourceAllocator resourceA } ResourceHandle resourceHandle = getResourceFromPool(resourceSpec, resourceAllocator, clientSecurityInfo, transaction); - + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "PoolManagerImpl.getResource handle=" + resourceHandle + ", poolStatus" + getPoolStatus(resourceSpec.getPoolInfo())); + } if (!resourceHandle.supportsLazyAssociation()) { resourceSpec.setLazyAssociatable(false); } @@ -178,6 +183,11 @@ public Object getResource(ResourceSpec resourceSpec, ResourceAllocator resourceA // resourceAllocator. resourceHandle.setResourceSpec(resourceSpec); + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "PoolManagerImpl.getResource, transaction=" + transaction + " resourceHandle=" + resourceHandle + " isUnenlisted=" + + resourceHandle.getResourceState().isUnenlisted()); + } + try { if (resourceHandle.getResourceState().isUnenlisted()) { // The spec being used here is the spec with the updated lazy enlistment info. @@ -188,6 +198,10 @@ public Object getResource(ResourceSpec resourceSpec, ResourceAllocator resourceA // LazyEnlistableResourceManager getResourceManager(resourceSpec).enlistResource(resourceHandle); + } else { + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "PoolManagerImpl.getResource - DO NOT ENLIST because it is already Enlisted, resource=" + resourceHandle); + } } } catch (Exception e) { // In the rare cases where enlistResource throws exception, we should return the resource to the pool @@ -200,7 +214,11 @@ public Object getResource(ResourceSpec resourceSpec, ResourceAllocator resourceA throw new PoolingException(e); } - return resourceHandle.getUserConnection(); + Object result = resourceHandle.getUserConnection(); + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "PoolManagerImpl.getResource END, resourceHandle=" + resourceHandle); + } + return result; } @Override @@ -343,8 +361,18 @@ public void unregisterResource(com.sun.appserv.connectors.internal.api.ResourceH @Override public void resourceClosed(ResourceHandle resource) { + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "PoolManagerImpl.resourceClosed START, resource=" + resource); + } + getResourceManager(resource.getResourceSpec()).delistResource(resource, TMSUCCESS); putbackResourceToPool(resource, false); + + if (LOG.isLoggable(Level.FINE)) { + // Warning resource state logged here might not be valid, could be part of another thread already + // but logging the resource id is useful. + LOG.log(Level.FINE, "PoolManagerImpl.resourceClosed END, resource=" + resource); + } } @Override @@ -401,6 +429,9 @@ private void putbackBadResourceToPool(ResourceHandle resourceHandle) { @Override public void putbackResourceToPool(ResourceHandle resourceHandle, boolean errorOccurred) { + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "PoolManagerImpl.putbackResourceToPool START, resource=" + resourceHandle + ", errorOccurred=" + errorOccurred); + } // Notify pool PoolInfo poolInfo = resourceHandle.getResourceSpec().getPoolInfo(); if (poolInfo != null) { @@ -415,6 +446,9 @@ public void putbackResourceToPool(ResourceHandle resourceHandle, boolean errorOc } } } + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "PoolManagerImpl.putbackResourceToPool END, resource=" + resourceHandle + ", errorOccurred=" + errorOccurred); + } } @Override diff --git a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/PoolStatus.java b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/PoolStatus.java index 6bf484a3d8d..011029c6bcb 100644 --- a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/PoolStatus.java +++ b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/PoolStatus.java @@ -62,4 +62,9 @@ public void setPoolInfo(PoolInfo poolInfo) { public PoolStatus(PoolInfo poolInfo) { this.poolInfo = poolInfo; } + + @Override + public String toString() { + return "PoolStatus [poolInfo=" + poolInfo + ", numConnFree=" + numConnFree + ", numConnUsed=" + numConnUsed + "]"; + } } diff --git a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/PoolTxHelper.java b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/PoolTxHelper.java index 4b66f2ca461..074d1235839 100644 --- a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/PoolTxHelper.java +++ b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/PoolTxHelper.java @@ -55,7 +55,8 @@ public PoolTxHelper(PoolInfo poolInfo) { * Check whether the local resource can be put back to pool If true, unenlist the resource * * @param h ResourceHandle to be verified - * @return boolean + * @return true if the resource handle is eligible for reuse, otherwise false. NOTE in case of true, this method alters + * the handle state to enlisted=false */ public boolean isLocalResourceEligibleForReuse(ResourceHandle h) { boolean result = false; @@ -70,9 +71,17 @@ public boolean isLocalResourceEligibleForReuse(ResourceHandle h) { } return result; } + h.getResourceState().setEnlisted(false); + if (_logger.isLoggable(Level.FINE)) { + _logger.log(Level.FINE, "Pool: isLocalResourceEligibleForReuse, eligible=true, enlisted changed to true for handle=" + h); + } result = true; } + + if (_logger.isLoggable(Level.FINE)) { + _logger.log(Level.FINE, "Pool: isLocalResourceEligibleForReuse, eligible=false, handle=" + h); + } return result; } @@ -153,7 +162,6 @@ public boolean isNonXAResource(ResourceHandle resource) { * @return boolean indicating whether thegiven non-xa resource is in transaction */ private boolean isNonXAResourceInTransaction(JavaEETransaction tran, ResourceHandle resource) { - return resource.equals(tran.getNonXAResource()); } @@ -175,6 +183,9 @@ public boolean isNonXAResourceAndFree(JavaEETransaction tran, ResourceHandle res * @param resource Resource to be enlisted in the transaction */ public void resourceEnlisted(Transaction tran, ResourceHandle resource) { + if (_logger.isLoggable(Level.FINE)) { + _logger.log(Level.FINE, "Pool: resourceEnlisted START, tran=" + tran + ", resource=" + resource + ", poolInfo=" + poolInfo); + } try { JavaEETransaction j2eetran = (JavaEETransaction) tran; Set set = j2eetran.getResources(poolInfo); @@ -192,7 +203,7 @@ public void resourceEnlisted(Transaction tran, ResourceHandle resource) { ResourceState state = resource.getResourceState(); state.setEnlisted(true); if (_logger.isLoggable(Level.FINE)) { - _logger.log(Level.FINE, "Pool [ " + poolInfo + " ]: resourceEnlisted: " + resource); + _logger.log(Level.FINE, "Pool: resourceEnlisted END, tran=" + tran + ", resource=" + resource); } } @@ -205,6 +216,10 @@ public void resourceEnlisted(Transaction tran, ResourceHandle resource) { * @return delisted resources */ public List transactionCompleted(Transaction tran, int status, PoolInfo poolInfo) { + if (_logger.isLoggable(Level.FINE)) { + _logger.log(Level.FINE, "Pool: transactionCompleted START, tran= " + tran + ", poolInfo=" + poolInfo); + } + JavaEETransaction j2eetran; List delistedResources = new ArrayList<>(); try { @@ -233,6 +248,10 @@ public List transactionCompleted(Transaction tran, int status, P _logger.log(Level.FINE, "Pool: transactionCompleted: " + resource); } } + + if (_logger.isLoggable(Level.FINE)) { + _logger.log(Level.FINE, "Pool: transactionCompleted END, tran= " + tran); + } return delistedResources; } } diff --git a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/UnpooledResource.java b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/UnpooledResource.java index a01ee55a8b5..bb9767c5f50 100644 --- a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/UnpooledResource.java +++ b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/UnpooledResource.java @@ -81,6 +81,9 @@ protected ResourceHandle getUnenlistedResource(ResourceSpec spec, ResourceAlloca throw ex; } handle.getResourceState().reset(); + + // TODO: document that all get(Unenlisted)Resource methods must return state busy resource + // TODO: rename variables, they currently have 2 or 3 names by default: handle, resource and resourceHandle setResourceStateToBusy(handle); return handle; } diff --git a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/rm/ResourceManagerImpl.java b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/rm/ResourceManagerImpl.java index b9fd0b269ca..03aa5623eb8 100755 --- a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/rm/ResourceManagerImpl.java +++ b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/rm/ResourceManagerImpl.java @@ -100,6 +100,11 @@ public void enlistResource(ResourceHandle resourceHandle) throws PoolingExceptio */ @Override public void registerResource(ResourceHandle handle) throws PoolingException { + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "ResourceManagerImpl.registerResource START: handle=" + handle + ", resource=" + + handle.getResource() + ", transactional=" + handle.isTransactional()); + } + try { JavaEETransactionManager transactionManager = getTransactionManager(); @@ -107,6 +112,10 @@ public void registerResource(ResourceHandle handle) throws PoolingException { if (handle.isTransactional()) { ComponentInvocation componentInvocation = getCurrentInvocation(); + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "ResourceManagerImpl.registerResource: componentInvocation=" + componentInvocation); + } + Transaction transaction = null; if (componentInvocation == null) { @@ -115,12 +124,18 @@ public void registerResource(ResourceHandle handle) throws PoolingException { // method/ in that, you return the transaction from the TxManager try { transaction = transactionManager.getTransaction(); + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "ResourceManagerImpl.registerResource: A transaction=" + transaction); + } } catch (Exception e) { transaction = null; LOG.log(INFO, e.getMessage()); } } else { transaction = (Transaction) componentInvocation.getTransaction(); + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "ResourceManagerImpl.registerResource: B transaction=" + transaction); + } transactionManager.registerComponentResource(handle); } @@ -129,7 +144,7 @@ public void registerResource(ResourceHandle handle) throws PoolingException { transactionManager.enlistResource(transaction, handle); } catch (Exception ex) { if (LOG.isLoggable(Level.FINE)) { - LOG.fine("Exception whle trying to enlist resource " + ex.getMessage()); + LOG.fine("Exception while trying to enlist resource " + ex.getMessage()); } // If transactional, remove the connection handle from the @@ -149,6 +164,11 @@ public void registerResource(ResourceHandle handle) throws PoolingException { LOG.log(SEVERE, "poolmgr.component_register_exception", ex); throw new PoolingException(ex.toString(), ex); } + + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "ResourceManagerImpl.registerResource END: handle=" + handle + ", resource=" + + handle.getResource() + ", transactional=" + handle.isTransactional()); + } } // Overridden by the LazyEnlistableResourceManager to be a No-Op @@ -210,7 +230,8 @@ public void delistResource(ResourceHandle resource, int xaresFlag) { } /** - * Unregister the ResourceHandle from the transaction + * Unregister the ResourceHandle from the transaction TODO: document what the resource state should be: + * enlisted? busy? TODO: move documentation to the interface * * @param resource ResourceHandle object * @param xaresFlag flag indicating transaction success. This can be XAResource.TMSUCCESS or XAResource.TMFAIL @@ -218,6 +239,12 @@ public void delistResource(ResourceHandle resource, int xaresFlag) { */ @Override public void unregisterResource(ResourceHandle resource, int xaresFlag) { + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, + "ResourceManagerImpl.unregisterResource START: handle=" + resource + ", resource=" + + resource.getResource() + + ", transactional=" + resource.isTransactional()); + } JavaEETransactionManager transactionManager = getTransactionManager(); Transaction transaction = null; @@ -245,6 +272,9 @@ public void unregisterResource(ResourceHandle resource, int xaresFlag) { } if (transaction != null && resource.isEnlisted()) { + // TODO: delistResource seems to return always true, or throws an exception + // which is ok, but return type could be removed! Since it is not used here to see + // if something went wrong. transactionManager.delistResource(transaction, resource, xaresFlag); } } @@ -258,6 +288,12 @@ public void unregisterResource(ResourceHandle resource, int xaresFlag) { // UnregisterResource is called outside of component context // likely to be container-forced destroy. Do nothing } + + if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "ResourceManagerImpl.unregisterResource END: handle=" + resource + ", resource=" + + resource.getResource() + + ", transactional=" + resource.isTransactional()); + } } private static ComponentInvocation getCurrentInvocation() { diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBContainerTransactionManager.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBContainerTransactionManager.java index c0a2784f01f..a03a1d0fc08 100755 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBContainerTransactionManager.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBContainerTransactionManager.java @@ -136,6 +136,10 @@ int findTxAttr(MethodDescriptor md) { * Handle transaction requirements, if any, before invoking bean method */ final void preInvokeTx(EjbInvocation inv) throws Exception { + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("preInvokeTx START, inv=" + inv); + } + // Get existing Tx status: this tells us if the client // started a transaction which was propagated on this invocation. Integer preInvokeTxStatus = inv.getPreInvokeTxStatus(); @@ -162,6 +166,9 @@ final void preInvokeTx(EjbInvocation inv) throws Exception { throw new EJBException(ex); } } + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("preInvokeTx END (1), inv=" + inv); + } return; } @@ -275,6 +282,10 @@ final void preInvokeTx(EjbInvocation inv) throws Exception { default: throw new EJBException("Bad transaction attribute"); } + + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("preInvokeTx END (2), inv=" + inv); + } } /** @@ -282,6 +293,9 @@ final void preInvokeTx(EjbInvocation inv) throws Exception { * no-op in those containers that do not need this callback */ private void startNewTx(Transaction prevTx, EjbInvocation inv) throws Exception { + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("startNewTx START, inv=" + inv + "\n prevTx=" + prevTx); + } container.checkUnfinishedTx(prevTx, inv); @@ -313,12 +327,19 @@ private void startNewTx(Transaction prevTx, EjbInvocation inv) throws Exception // a Synchronization object with the TM, the afterCompletion // will get called. container.afterBegin(context); + + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("startNewTx END, inv=" + inv); + } } /** * Use caller transaction to execute a bean method */ protected void useClientTx(Transaction prevTx, EjbInvocation inv) { + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("useClientTx START, inv=" + inv + "\n prevTx=" + prevTx); + } Transaction clientTx; int status=-1; int prevStatus=-1; @@ -410,12 +431,19 @@ protected void useClientTx(Transaction prevTx, EjbInvocation inv) { } } } + + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("useClientTx END, inv=" + inv); + } } /** * Handle transaction requirements, if any, after invoking bean method */ protected void postInvokeTx(EjbInvocation inv) throws Exception { + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("postInvokeTx START, inv=" + inv); + } Throwable exception = inv.exception; @@ -436,6 +464,9 @@ protected void postInvokeTx(EjbInvocation inv) throws Exception { inv.exception = ((BaseContainer.PreInvokeException)exception).exception; } + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("postInvokeTx END (1), inv=" + inv); + } return; } @@ -533,6 +564,10 @@ protected void postInvokeTx(EjbInvocation inv) throws Exception { // XXX If any of the TM commit/rollback/suspend calls throws an // exception, should the transaction be rolled back if not already so ? + + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("postInvokeTx END (2), inv=" + inv); + } } final UserTransaction getUserTransaction() { @@ -664,6 +699,10 @@ Throwable checkExceptionClientTx(EJBContextImpl context, Throwable exception) th // this is the counterpart of startNewTx private Throwable completeNewTx(EJBContextImpl context, Throwable exception, int status) throws Exception { + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("completeNewTx START, context=" + context + ", status=" + status + ", exception=" + exception); + } + Throwable newException = exception; if (exception instanceof BaseContainer.PreInvokeException) { newException = ((BaseContainer.PreInvokeException) exception).exception; @@ -672,6 +711,10 @@ private Throwable completeNewTx(EJBContextImpl context, Throwable exception, int if (status == Status.STATUS_NO_TRANSACTION) { // no tx was started, probably an exception was thrown // before tm.begin() was called + + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("completeNewTx END (1), context=" + context); + } return newException; } @@ -684,6 +727,10 @@ private Throwable completeNewTx(EJBContextImpl context, Throwable exception, int // EJB2.0 section 18.3.1, Table 15 // Rollback the Tx we started destroyBeanAndRollback(context, null); + + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("completeNewTx END (2), context=" + context); + } return processSystemException(newException); } try { @@ -705,15 +752,25 @@ private Throwable completeNewTx(EJBContextImpl context, Throwable exception, int transactionManager.commit(); } } + + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("completeNewTx END (3), context=" + context); + } return newException; } catch (RollbackException ex) { _logger.log(Level.FINE, "ejb.transaction_abort_exception", ex); // EJB2.0 section 18.3.6 + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("completeNewTx END (4), context=" + context); + } return new EJBException("Transaction aborted", ex); } catch (Exception ex) { _logger.log(Level.FINE, "ejb.cmt_exception", ex); // Commit or rollback failed. // EJB2.0 section 18.3.6 + if (_logger.isLoggable(Level.FINE)) { + _logger.fine("completeNewTx END (5), context=" + context); + } return new EJBException("Unable to complete" + " container-managed transaction.", ex); } } diff --git a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/base/ConnectionHolder.java b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/base/ConnectionHolder.java index 92f5dbde5b2..cbf2a13e0a6 100644 --- a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/base/ConnectionHolder.java +++ b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/base/ConnectionHolder.java @@ -179,6 +179,10 @@ public void clearWarnings() throws SQLException { * @throws SQLException In case of a database error. */ public void close() throws SQLException { + if (_logger.isLoggable(Level.FINE)) { + _logger.log(Level.FINE, "ConnectionHolder.close() START managedConnectionImpl=" + managedConnectionImpl); + } + if (isClosed) { if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "jdbc.duplicate_close_connection", this); @@ -192,6 +196,10 @@ public void close() throws SQLException { // and has not been associated yet or has been disassociated managedConnectionImpl.connectionClosed(null, this); } + + if (_logger.isLoggable(Level.FINE)) { + _logger.log(Level.FINE, "ConnectionHolder.close() END managedConnectionImpl=" + managedConnectionImpl); + } } /** diff --git a/appserver/transaction/internal-api/src/main/java/com/sun/enterprise/transaction/spi/TransactionalResource.java b/appserver/transaction/internal-api/src/main/java/com/sun/enterprise/transaction/spi/TransactionalResource.java index a6206d8a783..04597ed4406 100644 --- a/appserver/transaction/internal-api/src/main/java/com/sun/enterprise/transaction/spi/TransactionalResource.java +++ b/appserver/transaction/internal-api/src/main/java/com/sun/enterprise/transaction/spi/TransactionalResource.java @@ -48,8 +48,6 @@ public interface TransactionalResource { public boolean isShareable(); - public void destroyResource(); - /** * @return the String that can identify this resource */ diff --git a/appserver/transaction/jta/src/main/java/com/sun/enterprise/transaction/JavaEETransactionImpl.java b/appserver/transaction/jta/src/main/java/com/sun/enterprise/transaction/JavaEETransactionImpl.java index 966f39aec10..dd9842e4dee 100644 --- a/appserver/transaction/jta/src/main/java/com/sun/enterprise/transaction/JavaEETransactionImpl.java +++ b/appserver/transaction/jta/src/main/java/com/sun/enterprise/transaction/JavaEETransactionImpl.java @@ -646,7 +646,7 @@ public void registerSynchronization(Synchronization sync) throws RollbackExcepti // START OF IASRI 4660742 if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, - "--In JavaEETransactionImpl.registerSynchronization, jtsTx=" + jtsTx + " nonXAResource=" + nonXAResource); + "--In JavaEETransactionImpl.registerSynchronization START, jtsTx=" + jtsTx + ", nonXAResource=" + nonXAResource + ", sync=" + sync); } // END OF IASRI 4660742 @@ -655,6 +655,11 @@ public void registerSynchronization(Synchronization sync) throws RollbackExcepti jtsTx.registerSynchronization(sync); else syncs.add(sync); + + if (_logger.isLoggable(Level.FINE)) { + _logger.log(Level.FINE, + "--In JavaEETransactionImpl.registerSynchronization END, jtsTx=" + jtsTx + ", nonXAResource=" + nonXAResource + ", sync=" + sync); + } } public void setRollbackOnly() throws IllegalStateException, SystemException { diff --git a/appserver/transaction/jta/src/main/java/com/sun/enterprise/transaction/JavaEETransactionManagerSimplified.java b/appserver/transaction/jta/src/main/java/com/sun/enterprise/transaction/JavaEETransactionManagerSimplified.java index 8a0f764fa0c..a922693bb59 100644 --- a/appserver/transaction/jta/src/main/java/com/sun/enterprise/transaction/JavaEETransactionManagerSimplified.java +++ b/appserver/transaction/jta/src/main/java/com/sun/enterprise/transaction/JavaEETransactionManagerSimplified.java @@ -1404,13 +1404,6 @@ private void handleResourceError(TransactionalResource h, Exception ex, Transact } catch (Exception ex2) { // Log.err.println(ex2); } - } else { - // destroy resource. RM Error. - try { - h.destroyResource(); - } catch (Exception ex2) { - // Log.err.println(ex2); - } } } diff --git a/appserver/transaction/jts/src/main/java/com/sun/enterprise/transaction/jts/JavaEETransactionManagerJTSDelegate.java b/appserver/transaction/jts/src/main/java/com/sun/enterprise/transaction/jts/JavaEETransactionManagerJTSDelegate.java index 7a0862cb18a..6cc2702fb65 100644 --- a/appserver/transaction/jts/src/main/java/com/sun/enterprise/transaction/jts/JavaEETransactionManagerJTSDelegate.java +++ b/appserver/transaction/jts/src/main/java/com/sun/enterprise/transaction/jts/JavaEETransactionManagerJTSDelegate.java @@ -143,7 +143,7 @@ public void setUseLAO(boolean b) { @Override public void commitDistributedTransaction() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { - logger.log(FINE, "TM: commit"); + logger.log(FINE, "JavaEETransactionManagerJTSDelegate.commitDistributedTransaction START"); validateTransactionManager(); TransactionManager transactionManager = transactionManagerLocal.get(); @@ -175,6 +175,7 @@ public void commitDistributedTransaction() throws RollbackException, HeuristicMi javaEETMS.setTransactionCompeting(false); } } + logger.log(FINE, "JavaEETransactionManagerJTSDelegate.commitDistributedTransaction END"); } /** @@ -182,7 +183,7 @@ public void commitDistributedTransaction() throws RollbackException, HeuristicMi */ @Override public void rollbackDistributedTransaction() throws IllegalStateException, SecurityException, SystemException { - logger.log(FINE, "TM: rollback"); + logger.log(FINE, "JavaEETransactionManagerJTSDelegate.rollbackDistributedTransaction START"); validateTransactionManager(); TransactionManager transactionManager = transactionManagerLocal.get(); @@ -204,6 +205,7 @@ public void rollbackDistributedTransaction() throws IllegalStateException, Secur } finally { javaEETMS.monitorTxCompleted(obj, false); } + logger.log(FINE, "JavaEETransactionManagerJTSDelegate.rollbackDistributedTransaction END"); } @Override @@ -219,7 +221,8 @@ public int getStatus() throws SystemException { } if (logger.isLoggable(FINE)) { - logger.log(FINE, "TM: status: " + JavaEETransactionManagerSimplified.getStatusAsString(status)); + logger.log(FINE, "JavaEETransactionManagerJTSDelegate.getStatus, status=" + + JavaEETransactionManagerSimplified.getStatusAsString(status)); } return status; @@ -229,10 +232,15 @@ public int getStatus() throws SystemException { public Transaction getTransaction() throws SystemException { JavaEETransaction javaEETransaction = javaEETransactionManager.getCurrentTransaction(); if (logger.isLoggable(FINE)) { - logger.log(FINE, "TM: getTransaction: tx=" + javaEETransaction + ", tm=" + transactionManagerLocal.get()); + logger.log(FINE, "JavaEETransactionManagerJTSDelegate.getTransaction START: tx=" + javaEETransaction + + ", tm=" + transactionManagerLocal.get()); } if (javaEETransaction != null) { + if (logger.isLoggable(FINE)) { + logger.log(FINE, "JavaEETransactionManagerJTSDelegate: getTransaction END (1): tx=" + javaEETransaction + + ", tm=" + transactionManagerLocal.get()); + } return javaEETransaction; } @@ -244,13 +252,18 @@ public Transaction getTransaction() throws SystemException { } if (jtsTx == null) { + if (logger.isLoggable(FINE)) { + logger.log(FINE, "JavaEETransactionManagerJTSDelegate.getTransaction END (2): tx=" + javaEETransaction + + ", tm=" + transactionManagerLocal.get()); + } return null; } // Check if this JTS Transaction was previously active in this JVM (possible for distributed loopbacks). javaEETransaction = (JavaEETransaction) globalTransactions.get(jtsTx); if (logger.isLoggable(FINE)) { - logger.log(FINE, "TM: getTransaction: tx=" + javaEETransaction + ", jtsTx=" + jtsTx); + logger.log(FINE, "JavaEETransactionManagerJTSDelegate.getTransaction: tx=" + javaEETransaction + ", jtsTx=" + + jtsTx); } if (javaEETransaction == null) { @@ -259,6 +272,11 @@ public Transaction getTransaction() throws SystemException { } javaEETransactionManager.setCurrentTransaction(javaEETransaction); // associate tx with thread + + if (logger.isLoggable(FINE)) { + logger.log(FINE, "JavaEETransactionManagerJTSDelegate.getTransaction END (3): tx=" + javaEETransaction + + ", tm=" + transactionManagerLocal.get()); + } return javaEETransaction; } @@ -316,10 +334,12 @@ public boolean enlistLAOResource(Transaction transaction, TransactionalResource @Override public void setRollbackOnlyDistributedTransaction() throws IllegalStateException, SystemException { - logger.log(FINE, "TM: setRollbackOnly"); + logger.log(FINE, "JavaEETransactionManagerJTSDelegate.setRollbackOnlyDistributedTransaction START"); validateTransactionManager(); transactionManagerLocal.get().setRollbackOnly(); + + logger.log(FINE, "JavaEETransactionManagerJTSDelegate.setRollbackOnlyDistributedTransaction END"); } @Override @@ -342,12 +362,14 @@ public Transaction suspend(JavaEETransaction tx) throws SystemException { @Override public void resume(Transaction tx) throws InvalidTransactionException, IllegalStateException, SystemException { - logger.log(FINE, "TM: resume"); + logger.log(FINE, "JavaEETransactionManagerJTSDelegate.resume START, tx=" + tx); if (transactionManagerImpl != null) { setTransactionManager(); transactionManagerLocal.get().resume(tx); } + + logger.log(FINE, "JavaEETransactionManagerJTSDelegate.resume END, tx=" + tx); } @Override @@ -423,7 +445,7 @@ public XATerminator getXATerminator() { } private Transaction suspendXA() throws SystemException { - logger.log(FINE, "TM: suspend"); + logger.log(FINE, "JavaEETransactionManagerJTSDelegate: suspendXA"); validateTransactionManager(); return transactionManagerLocal.get().suspend(); @@ -437,7 +459,8 @@ private void validateTransactionManager() throws IllegalStateException { private void setTransactionManager() { if (logger.isLoggable(FINE)) { - logger.log(FINE, "TM: setTransactionManager: tm=" + transactionManagerLocal.get()); + logger.log(FINE, + "JavaEETransactionManagerJTSDelegate: setTransactionManager: tm=" + transactionManagerLocal.get()); } if (transactionManagerImpl == null) { @@ -501,7 +524,7 @@ public void initTransactionProperties() { if (value != null && "false".equals(value)) { setUseLAO(false); if (logger.isLoggable(FINE)) { - logger.log(FINE, "TM: LAO is disabled"); + logger.log(FINE, "JavaEETransactionManagerJTSDelegate: LAO is disabled"); } } @@ -522,7 +545,8 @@ public void initTransactionProperties() { if (Boolean.parseBoolean(transactionService.getPropertyValue("delegated-recovery"))) { // Register GMS notification callback if (logger.isLoggable(FINE)) { - logger.log(FINE, "TM: Registering for GMS notification callback"); + logger.log(FINE, + "JavaEETransactionManagerJTSDelegate: Registering for GMS notification callback"); } int waitTime = 60;