Search in sources :

Example 1 with SubordinationManagerXAResourceOrphanFilter

use of com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinationManagerXAResourceOrphanFilter 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)

Aggregations

JTAActionStatusServiceXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.JTAActionStatusServiceXAResourceOrphanFilter)1 JTANodeNameXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter)1 JTATransactionLogXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter)1 NodeNameXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.NodeNameXAResourceOrphanFilter)1 SubordinateJTAXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinateJTAXAResourceOrphanFilter)1 SubordinationManagerXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinationManagerXAResourceOrphanFilter)1 SubordinateTransaction (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction)1 XAResourceOrphanFilter (com.arjuna.ats.jta.recovery.XAResourceOrphanFilter)1 SimpleXAResource (com.hp.mwtests.ts.jta.commitmarkable.SimpleXAResource)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 XAResource (javax.transaction.xa.XAResource)1 Xid (javax.transaction.xa.Xid)1 Test (org.junit.Test)1