use of com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction in project narayana by jbosstm.
the class InboundBridgeRecoveryModule method periodicWorkSecondPass.
/**
* Called by the RecoveryManager RECOVERY_BACKOFF_PERIOD seconds after the completion of the first pass
*/
@Override
public void periodicWorkSecondPass() {
if (LOG.isTraceEnabled()) {
LOG.trace("InboundBridgeRecoveryModule.periodicWorkSecondPass");
}
recoveredBridges.clear();
final Set<Uid> uids = getUidsToRecover();
uids.retainAll(firstPassUids);
for (Uid uid : uids) {
try {
final SubordinateTransaction st = SubordinationManager.getTransactionImporter().recoverTransaction(uid);
} catch (XAException e) {
LOG.warn(e.getMessage(), e);
}
}
addBridgesToMapping();
}
use of com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction in project narayana by jbosstm.
the class XAResourceOrphanFilterTest method testJTAActionStatusServiceXAResourceOrphanFilterSubordinate.
@Test
public void testJTAActionStatusServiceXAResourceOrphanFilterSubordinate() throws HeuristicRollbackException, HeuristicMixedException, HeuristicCommitException, SystemException, RollbackException, XAException {
XAResourceOrphanFilter orphanFilter = new SubordinationManagerXAResourceOrphanFilter();
List<String> xaRecoveryNodes = jtaPropertyManager.getJTAEnvironmentBean().getXaRecoveryNodes();
List<String> recoveryNodes = new LinkedList<String>();
recoveryNodes.add("1");
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(recoveryNodes);
final List<String> recoveryExtensions = new ArrayList<String>();
recoveryExtensions.add(com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinateAtomicActionRecoveryModule.class.getName());
recoveryExtensions.add(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.class.getName());
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryModuleClassNames(recoveryExtensions);
int recoveryBackoffPeriod = recoveryPropertyManager.getRecoveryEnvironmentBean().getRecoveryBackoffPeriod();
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1);
RecoveryManager.manager().scan();
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(recoveryBackoffPeriod);
try {
Xid xid = XATxConverter.getXid(Uid.nullUid(), false, XATxConverter.FORMAT_ID);
assertEquals(XAResourceOrphanFilter.Vote.ABSTAIN, orphanFilter.checkXid(xid));
SubordinateTransaction subordinateTransaction = SubordinationManager.getTransactionImporter().importTransaction(xid);
final List<Xid> xids = new ArrayList<Xid>();
XAResource xar = new SimpleXAResource() {
@Override
public void start(Xid xid, int flags) throws XAException {
super.start(xid, flags);
xids.add(xid);
}
};
subordinateTransaction.enlistResource(xar);
try {
assertEquals(XAResourceOrphanFilter.Vote.LEAVE_ALONE, orphanFilter.checkXid(xids.get(0)));
} finally {
subordinateTransaction.doRollback();
}
assertEquals(XAResourceOrphanFilter.Vote.LEAVE_ALONE, orphanFilter.checkXid(xids.get(0)));
SubordinationManager.getTransactionImporter().removeImportedTransaction(xid);
assertEquals(XAResourceOrphanFilter.Vote.ROLLBACK, orphanFilter.checkXid(xids.get(0)));
} finally {
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(xaRecoveryNodes);
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryModuleClassNames(null);
}
}
use of com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction in project narayana by jbosstm.
the class SubordinateTestCase method testTwoPhaseCommitSync.
@Test
public void testTwoPhaseCommitSync() throws Exception {
final SubordinateTransaction tm = createTransaction();
final TestSynchronization sync = new TestSynchronization();
tm.registerSynchronization(sync);
assertEquals(TwoPhaseOutcome.PREPARE_READONLY, tm.doPrepare());
// don't call commit for read only case
assertTrue(sync.isBeforeCompletionDone());
assertTrue(sync.isAfterCompletionDone());
assertEquals(javax.transaction.Status.STATUS_COMMITTED, tm.getStatus());
}
use of com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction in project narayana by jbosstm.
the class SubordinateTestCase method testCleanupRollback.
@Test
public void testCleanupRollback() throws Exception {
for (int i = 0; i < 1000; i++) {
final SubordinateTransaction tm = createTransaction();
tm.doRollback();
}
assertEquals(ActionManager.manager().getNumberOfInflightTransactions(), 0);
}
use of com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction in project narayana by jbosstm.
the class SubordinateTestCase method testRollbackSync.
@Test
public void testRollbackSync() throws Exception {
final SubordinateTransaction tm = createTransaction();
final TestSynchronization sync = new TestSynchronization();
tm.registerSynchronization(sync);
tm.doRollback();
assertFalse(sync.isBeforeCompletionDone());
assertTrue(sync.isAfterCompletionDone());
assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, tm.getStatus());
}
Aggregations