Search in sources :

Example 6 with XAResourceOrphanFilter

use of com.arjuna.ats.jta.recovery.XAResourceOrphanFilter in project narayana by jbosstm.

the class XAResourceOrphanFilterTest method testSubordinateJTAXAResourceOrphanFilter.

@Test
public void testSubordinateJTAXAResourceOrphanFilter() throws HeuristicRollbackException, HeuristicMixedException, HeuristicCommitException, SystemException, RollbackException, XAException {
    XAResourceOrphanFilter orphanFilter = new SubordinateJTAXAResourceOrphanFilter();
    XidImple xid = (XidImple) XATxConverter.getXid(Uid.nullUid(), false, XATxConverter.FORMAT_ID);
    XATxConverter.setSubordinateNodeName(xid.getXID(), TxControl.getXANodeName());
    List<String> xaRecoveryNodes = jtaPropertyManager.getJTAEnvironmentBean().getXaRecoveryNodes();
    try {
        jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(Arrays.asList("2"));
        assertEquals(XAResourceOrphanFilter.Vote.ABSTAIN, orphanFilter.checkXid(xid));
        jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(Arrays.asList("1"));
        assertEquals(XAResourceOrphanFilter.Vote.ROLLBACK, orphanFilter.checkXid(xid));
    } finally {
        jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(xaRecoveryNodes);
    }
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) SubordinateJTAXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinateJTAXAResourceOrphanFilter) 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 7 with XAResourceOrphanFilter

use of com.arjuna.ats.jta.recovery.XAResourceOrphanFilter in project narayana by jbosstm.

the class XAResourceOrphanFilterTest method testJTATransactionLogOrphanFilter.

@Test
public void testJTATransactionLogOrphanFilter() {
    XAResourceOrphanFilter orphanFilter = new JTATransactionLogXAResourceOrphanFilter();
    Xid notJTAFormatId = XATxConverter.getXid(new Uid(), false, 0);
    assertEquals(XAResourceOrphanFilter.Vote.ABSTAIN, orphanFilter.checkXid(notJTAFormatId));
    Xid jtaFormatId = XATxConverter.getXid(new Uid(), false, XATxConverter.FORMAT_ID);
    assertEquals(XAResourceOrphanFilter.Vote.ABSTAIN, orphanFilter.checkXid(jtaFormatId));
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) Xid(javax.transaction.xa.Xid) JTATransactionLogXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter) 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 8 with XAResourceOrphanFilter

use of com.arjuna.ats.jta.recovery.XAResourceOrphanFilter in project narayana by jbosstm.

the class XAResourceOrphanFilterTest method testJTANodeNameXAResourceOrphanFilter.

@Test
public void testJTANodeNameXAResourceOrphanFilter() {
    XAResourceOrphanFilter orphanFilter = new JTANodeNameXAResourceOrphanFilter();
    Xid notJTAFormatId = XATxConverter.getXid(new Uid(), false, 0);
    assertEquals(XAResourceOrphanFilter.Vote.ABSTAIN, orphanFilter.checkXid(notJTAFormatId));
    List<String> recoveryNodes = new LinkedList<String>();
    recoveryNodes.add("1");
    jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(recoveryNodes);
    String notRecoverableNodeName = "2";
    TxControl.setXANodeName(notRecoverableNodeName);
    Xid jtaNotRecoverableNodeName = XATxConverter.getXid(new Uid(), false, XATxConverter.FORMAT_ID);
    assertEquals(XAResourceOrphanFilter.Vote.ABSTAIN, orphanFilter.checkXid(jtaNotRecoverableNodeName));
    String recoverableNodeName = "1";
    TxControl.setXANodeName(recoverableNodeName);
    Xid jtaRecoverableNodeName = XATxConverter.getXid(new Uid(), false, XATxConverter.FORMAT_ID);
    assertEquals(XAResourceOrphanFilter.Vote.ROLLBACK, orphanFilter.checkXid(jtaRecoverableNodeName));
    recoveryNodes.clear();
    recoveryNodes.add(NodeNameXAResourceOrphanFilter.RECOVER_ALL_NODES);
    jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(recoveryNodes);
    assertEquals(XAResourceOrphanFilter.Vote.ROLLBACK, orphanFilter.checkXid(jtaNotRecoverableNodeName));
    assertEquals(XAResourceOrphanFilter.Vote.ROLLBACK, orphanFilter.checkXid(jtaRecoverableNodeName));
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) Xid(javax.transaction.xa.Xid) JTANodeNameXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter) 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) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 9 with XAResourceOrphanFilter

use of com.arjuna.ats.jta.recovery.XAResourceOrphanFilter in project narayana by jbosstm.

the class TestJDBCStoreOffline method test.

@Test
public void test() throws NotSupportedException, SystemException, IllegalStateException, RollbackException, SecurityException, HeuristicMixedException, HeuristicRollbackException, NamingException {
    arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(JDBCStore.class.getName());
    arjPropertyManager.getObjectStoreEnvironmentBean().setJdbcAccess(TestJDBCAccess.class.getName());
    javax.transaction.TransactionManager tm = TransactionManager.transactionManager();
    tm.begin();
    tm.getTransaction().enlistResource(new DummyXAResource());
    tm.getTransaction().enlistResource(new DummyXAResource());
    tm.commit();
    assertTrue(commitCount == 1);
    FAULT_JDBC = true;
    jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(Arrays.asList(new String[] { "1" }));
    jtaPropertyManager.getJTAEnvironmentBean().setXaResourceOrphanFilters(Arrays.asList(new XAResourceOrphanFilter[] { new com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter(), new com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter() }));
    jtaPropertyManager.getJTAEnvironmentBean().setXaResourceRecoveries(Arrays.asList(new XAResourceRecovery[] { new DummyXAResourceRecovery() }));
    jtaPropertyManager.getJTAEnvironmentBean().setOrphanSafetyInterval(1);
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(2);
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryModules(Arrays.asList(new RecoveryModule[] { new XARecoveryModule() }));
    RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
    manager.scan();
    assertFalse(rollbackCalled);
}
Also used : XAResourceRecovery(com.arjuna.ats.jta.recovery.XAResourceRecovery) RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) JDBCStore(com.arjuna.ats.internal.arjuna.objectstore.jdbc.JDBCStore) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) RecoveryModule(com.arjuna.ats.arjuna.recovery.RecoveryModule) XAResourceOrphanFilter(com.arjuna.ats.jta.recovery.XAResourceOrphanFilter) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) Test(org.junit.Test)

Aggregations

XAResourceOrphanFilter (com.arjuna.ats.jta.recovery.XAResourceOrphanFilter)9 Test (org.junit.Test)8 JTANodeNameXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter)7 NodeNameXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.NodeNameXAResourceOrphanFilter)7 JTAActionStatusServiceXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.JTAActionStatusServiceXAResourceOrphanFilter)5 JTATransactionLogXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter)5 SubordinateJTAXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinateJTAXAResourceOrphanFilter)5 SubordinationManagerXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinationManagerXAResourceOrphanFilter)5 Xid (javax.transaction.xa.Xid)4 Uid (com.arjuna.ats.arjuna.common.Uid)3 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)3 LinkedList (java.util.LinkedList)3 XidImple (com.arjuna.ats.jta.xa.XidImple)2 TwoPhaseCoordinator (com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator)1 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)1 RecoveryManager (com.arjuna.ats.arjuna.recovery.RecoveryManager)1 RecoveryModule (com.arjuna.ats.arjuna.recovery.RecoveryModule)1 JDBCStore (com.arjuna.ats.internal.arjuna.objectstore.jdbc.JDBCStore)1 SubordinateTransaction (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction)1 XAResourceRecovery (com.arjuna.ats.jta.recovery.XAResourceRecovery)1