Search in sources :

Example 26 with RecoveryModule

use of com.arjuna.ats.arjuna.recovery.RecoveryModule 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)

Example 27 with RecoveryModule

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

the class ResourceManagerFailureUnitTest method test.

@Test
public void test() throws Exception {
    transactionManager.begin();
    transactionManager.getTransaction().enlistResource(new DummyXA(true));
    transactionManager.getTransaction().enlistResource(new DummyXARMFail(true));
    transactionManager.commit();
    final int uidsCountBeforeRecovery = getUidsCount();
    final RecoveryModule recoveryModule = recoveryManager.getModules().get(0);
    recoveryModule.periodicWorkFirstPass();
    recoveryModule.periodicWorkSecondPass();
    Assert.assertEquals(uidsCountBeforeRecovery - 1, getUidsCount());
}
Also used : DummyXA(com.hp.mwtests.ts.jta.jts.common.DummyXA) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.jts.XARecoveryModule) RecoveryModule(com.arjuna.ats.arjuna.recovery.RecoveryModule) Test(org.junit.Test)

Aggregations

RecoveryModule (com.arjuna.ats.arjuna.recovery.RecoveryModule)27 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)18 Enumeration (java.util.Enumeration)14 Vector (java.util.Vector)14 XAResource (javax.transaction.xa.XAResource)14 Test (org.junit.Test)12 CommitMarkableResourceRecordRecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.CommitMarkableResourceRecordRecoveryModule)11 XAResourceRecoveryHelper (com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper)11 Connection (java.sql.Connection)10 Xid (javax.transaction.xa.Xid)10 InitialContext (javax.naming.InitialContext)9 JdbcDataSource (org.h2.jdbcx.JdbcDataSource)7 ExecuteException (org.jboss.byteman.rule.exception.ExecuteException)6 Uid (com.arjuna.ats.arjuna.common.Uid)5 RecoveryManager (com.arjuna.ats.arjuna.recovery.RecoveryManager)5 XAException (javax.transaction.xa.XAException)5 TransactionImple (com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple)4 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)3 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)3 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.jts.XARecoveryModule)3