Search in sources :

Example 1 with RecoveryManager

use of com.arjuna.ats.arjuna.recovery.RecoveryManager in project wildfly by wildfly.

the class InboundBridgeService method removeRecoveryModule.

private void removeRecoveryModule() {
    if (recoveryModule == null) {
        return;
    }
    final RecoveryManager recoveryManager = RecoveryManager.manager();
    recoveryManager.removeModule(recoveryModule, false);
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager)

Example 2 with RecoveryManager

use of com.arjuna.ats.arjuna.recovery.RecoveryManager in project wildfly by wildfly.

the class InboundBridgeService method addRecoveryModule.

private void addRecoveryModule() {
    final RecoveryManager recoveryManager = RecoveryManager.manager();
    recoveryModule = new InboundBridgeRecoveryModule();
    recoveryManager.addModule(recoveryModule);
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) InboundBridgeRecoveryModule(org.jboss.narayana.rest.bridge.inbound.InboundBridgeRecoveryModule)

Example 3 with RecoveryManager

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

the class CrashRecovery2 method testRmFailXAResourceSerializable.

/**
 * Test of top-down recovery with serializable XAResource.
 */
@Test
public void testRmFailXAResourceSerializable() throws Exception {
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1);
    TestXAResource firstResource = new TestXAResourceRmFail().clearCounters();
    TestXAResource secondResource = new TestXAResource();
    javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
    tm.begin();
    javax.transaction.Transaction theTransaction = tm.getTransaction();
    theTransaction.enlistResource(firstResource);
    theTransaction.enlistResource(secondResource);
    tm.commit();
    assertEquals("first resource failed with rmfail, no commit expected", 0, firstResource.commitCount());
    assertEquals("second resource should be committed", 1, secondResource.commitCount());
    assertEquals("first resource: no rollback expected on rmfail", 0, firstResource.rollbackCount());
    assertEquals("second resource: expected to be committed", 0, secondResource.rollbackCount());
    RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
    manager.initialize();
    manager.scan();
    assertEquals("no rollback expecte on first resource", 0, firstResource.rollbackCount());
    assertEquals("no rollback expecte on second resource", 0, secondResource.rollbackCount());
    assertEquals("serializable first resource should be committed on recovery", 1, firstResource.commitCount());
    assertEquals("second resource should be already committed even without recovery", 1, secondResource.commitCount());
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) Test(org.junit.Test)

Example 4 with RecoveryManager

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

the class LogStoreRecoveryTest2 method test.

@Test
public void test() {
    int threads = 10;
    int work = 100;
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1);
    arjPropertyManager.getCoordinatorEnvironmentBean().setCommitOnePhase(false);
    arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
    arjPropertyManager.getObjectStoreEnvironmentBean().setSynchronousRemoval(false);
    // the byteman script will enforce this
    // System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "1000000");  // essentially infinite
    TestWorker[] workers = new TestWorker[threads];
    for (int i = 0; i < threads; i++) {
        workers[i] = new TestWorker(work);
        workers[i].start();
    }
    for (int j = 0; j < threads; j++) {
        try {
            workers[j].join();
            System.err.println("**terminated " + j);
        } catch (final Exception ex) {
        }
    }
    /*
           * Now have a log that hasn't been deleted. Run recovery and see
           * what happens!
           */
    RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
    manager.scan();
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) LogStore(com.arjuna.ats.internal.arjuna.objectstore.LogStore) Test(org.junit.Test)

Example 5 with RecoveryManager

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

the class CallbackRecoveryTest method test.

@Test
public void test() {
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1);
    RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
    DummyRecoveryModule module = new DummyRecoveryModule();
    RecoveryScanImple rs = new RecoveryScanImple();
    // make sure no other modules registered for this test
    manager.removeAllModules(false);
    manager.addModule(module);
    manager.scan(rs);
    /*
         * the 30 second wait timeout here is just in case something is not working. the scan should
         * finish almost straight away
         */
    rs.waitForCompleted(30 * 1000);
    assertTrue(module.finished());
    assertTrue(rs.passed);
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) Test(org.junit.Test)

Aggregations

RecoveryManager (com.arjuna.ats.arjuna.recovery.RecoveryManager)23 Test (org.junit.Test)15 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)6 RecoveryModule (com.arjuna.ats.arjuna.recovery.RecoveryModule)5 Enumeration (java.util.Enumeration)3 Properties (java.util.Properties)3 Vector (java.util.Vector)3 AtomicActionRecoveryModule (com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule)2 TransactionalDriver (com.arjuna.ats.jdbc.TransactionalDriver)2 XAResourceRecoveryHelper (com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper)2 XAResource (javax.transaction.xa.XAResource)2 Driver (org.h2.Driver)2 BMRule (org.jboss.byteman.contrib.bmunit.BMRule)2 InboundBridgeRecoveryModule (org.jboss.narayana.rest.bridge.inbound.InboundBridgeRecoveryModule)2 ExpiryScanner (com.arjuna.ats.arjuna.recovery.ExpiryScanner)1 RecoveryDriver (com.arjuna.ats.arjuna.recovery.RecoveryDriver)1 LogStore (com.arjuna.ats.internal.arjuna.objectstore.LogStore)1 JDBCStore (com.arjuna.ats.internal.arjuna.objectstore.jdbc.JDBCStore)1 PropertyFileDynamicClass (com.arjuna.ats.internal.jdbc.drivers.PropertyFileDynamicClass)1 CommitMarkableResourceRecordRecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.CommitMarkableResourceRecordRecoveryModule)1