Search in sources :

Example 1 with SubordinateTransaction

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();
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) XAException(javax.transaction.xa.XAException) SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction)

Example 2 with SubordinateTransaction

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);
    }
}
Also used : ArrayList(java.util.ArrayList) SubordinationManagerXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinationManagerXAResourceOrphanFilter) LinkedList(java.util.LinkedList) Xid(javax.transaction.xa.Xid) SimpleXAResource(com.hp.mwtests.ts.jta.commitmarkable.SimpleXAResource) XAResource(javax.transaction.xa.XAResource) SimpleXAResource(com.hp.mwtests.ts.jta.commitmarkable.SimpleXAResource) SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) JTANodeNameXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter) SubordinateJTAXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinateJTAXAResourceOrphanFilter) SubordinationManagerXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinationManagerXAResourceOrphanFilter) JTAActionStatusServiceXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.JTAActionStatusServiceXAResourceOrphanFilter) XAResourceOrphanFilter(com.arjuna.ats.jta.recovery.XAResourceOrphanFilter) NodeNameXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.NodeNameXAResourceOrphanFilter) JTATransactionLogXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter) Test(org.junit.Test)

Example 3 with SubordinateTransaction

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());
}
Also used : SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Example 4 with SubordinateTransaction

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);
}
Also used : SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Example 5 with SubordinateTransaction

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());
}
Also used : SubordinateTransaction(com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction) Test(org.junit.Test)

Aggregations

SubordinateTransaction (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction)42 Test (org.junit.Test)35 XAException (javax.transaction.xa.XAException)18 Uid (com.arjuna.ats.arjuna.common.Uid)16 Xid (javax.transaction.xa.Xid)13 XidImple (com.arjuna.ats.jta.xa.XidImple)12 TransactionImporter (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.TransactionImporter)7 XATerminatorImple (com.arjuna.ats.internal.jta.transaction.jts.jca.XATerminatorImple)6 RollbackException (javax.transaction.RollbackException)6 SystemException (javax.transaction.SystemException)6 XAResource (javax.transaction.xa.XAResource)6 XATerminatorImple (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple)4 ArrayList (java.util.ArrayList)4 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)3 SubordinateXidImple (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateXidImple)3 UnexpectedConditionException (com.arjuna.ats.jta.exceptions.UnexpectedConditionException)3 XAResourceRecoveryHelper (com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper)3 TestXAResource (com.hp.mwtests.ts.jta.jts.TestXAResource)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 HeuristicMixedException (javax.transaction.HeuristicMixedException)3