use of org.apache.geode.internal.jta.TransactionManagerImpl in project geode by apache.
the class FacetsJCAConnectionManagerImpl method connectionErrorOccurred.
/**
* CallBack for Connection Error.
*
* @param event ConnectionEvent
*/
public void connectionErrorOccurred(ConnectionEvent event) {
if (isActive) {
// If its an XAConnection
ManagedConnection conn = (ManagedConnection) event.getSource();
// XAResource xar = (XAResource) xaResourcesMap.get(conn);
((List) xalistThreadLocal.get()).remove(conn);
TransactionManagerImpl transManager = TransactionManagerImpl.getTransactionManager();
try {
Transaction txn = transManager.getTransaction();
if (txn == null) {
mannPoolCache.returnPooledConnectionToPool(conn);
} else {
// do nothing.
}
} catch (Exception se) {
se.printStackTrace();
}
try {
mannPoolCache.expirePooledConnection(conn);
// mannPoolCache.destroyPooledConnection(conn);
} catch (Exception ex) {
String exception = "FacetsJCAConnectionManagerImpl::connectionErrorOccurred: Exception occurred due to " + ex.getMessage();
if (logger.isDebugEnabled()) {
logger.debug(exception, ex);
}
}
}
}
use of org.apache.geode.internal.jta.TransactionManagerImpl in project geode by apache.
the class ClientServerTransactionDUnitTest method doJTATx2.
private void doJTATx2(String regionName, CountDownLatch latch1, CountDownLatch latch2) {
try {
TransactionManagerImpl tm = TransactionManagerImpl.getTransactionManager();
UserTransaction utx = new UserTransactionImpl();
Region r = getClientRegion(regionName);
utx.begin();
r.put(key1, "value3");
TransactionImpl txn = (TransactionImpl) tm.getTransaction();
Synchronization sync = new SyncImpl();
txn.registerSynchronization(sync);
txn.notifyBeforeCompletionForTest();
latch1.countDown();
latch2.await();
utx.rollback();
} catch (Exception e) {
latch1.countDown();
Assert.fail("Unexpected exception while doing JTA Transaction2 ", e);
}
}
use of org.apache.geode.internal.jta.TransactionManagerImpl in project geode by apache.
the class JCAConnectionManagerImpl method connectionErrorOccurred.
/**
* CallBack for Connection Error.
*
* @param event ConnectionEvent
*/
public void connectionErrorOccurred(ConnectionEvent event) {
if (isActive) {
// If its an XAConnection
ManagedConnection conn = (ManagedConnection) event.getSource();
XAResource xar = (XAResource) xaResourcesMap.get(conn);
xaResourcesMap.remove(conn);
TransactionManagerImpl transManager = TransactionManagerImpl.getTransactionManager();
try {
Transaction txn = transManager.getTransaction();
if (txn != null && xar != null)
txn.delistResource(xar, XAResource.TMSUCCESS);
} catch (SystemException se) {
se.printStackTrace();
}
try {
mannPoolCache.expirePooledConnection(conn);
// mannPoolCache.destroyPooledConnection(conn);
} catch (Exception ex) {
String exception = "JCAConnectionManagerImpl::connectionErrorOccurred: Exception occurred due to " + ex;
if (logger.isDebugEnabled()) {
logger.debug(exception, ex);
}
}
}
}
use of org.apache.geode.internal.jta.TransactionManagerImpl in project geode by apache.
the class FacetsJCAConnectionManagerImpl method connectionClosed.
/**
* Callback for Connection Closed.
*
* @param event ConnectionEvent Object.
*/
public void connectionClosed(ConnectionEvent event) {
if (isActive) {
ManagedConnection conn = (ManagedConnection) event.getSource();
TransactionManagerImpl transManager = TransactionManagerImpl.getTransactionManager();
try {
Transaction txn = transManager.getTransaction();
if (txn == null) {
mannPoolCache.returnPooledConnectionToPool(conn);
}
} catch (Exception se) {
String exception = "FacetsJCAConnectionManagerImpl::connectionClosed: Exception occurred due to " + se.getMessage();
if (logger.isDebugEnabled()) {
logger.debug(exception, se);
}
}
}
}
use of org.apache.geode.internal.jta.TransactionManagerImpl in project geode by apache.
the class ClientServerTransactionDUnitTest method doJTATx1.
private void doJTATx1(String regionName, CountDownLatch latch1, CountDownLatch latch2) {
TransactionManagerImpl tm = TransactionManagerImpl.getTransactionManager();
Region r = getClientRegion(regionName);
try {
UserTransaction utx = new UserTransactionImpl();
utx.begin();
latch1.await();
r.put(key1, "value2");
utx.commit();
fail("Do not get expected RollbackException");
} catch (Exception e) {
if (e instanceof RollbackException) {
// expected exception.
} else {
Assert.fail("Unexpected exception while doing JTA Transaction1 ", e);
}
} finally {
latch2.countDown();
}
}
Aggregations