Search in sources :

Example 6 with RecoveryManager

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

the class EmbeddedRecoveryTest method test.

@Test
public void test() {
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1);
    RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
    DummyRecoveryModule module = new DummyRecoveryModule();
    // make sure no other modules registered for this test
    manager.removeAllModules(false);
    manager.addModule(module);
    manager.scan();
    assertTrue(module.finished());
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) Test(org.junit.Test)

Example 7 with RecoveryManager

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

the class RecoveryDriverUnitTest method testValid.

@Test
public void testValid() throws Exception {
    recoveryPropertyManager.getRecoveryEnvironmentBean().setPeriodicRecoveryPeriod(1);
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1);
    RecoveryManager rm = RecoveryManager.manager();
    rm.scan(null);
    RecoveryDriver rd = new RecoveryDriver(RecoveryManager.getRecoveryManagerPort(), recoveryPropertyManager.getRecoveryEnvironmentBean().getRecoveryAddress(), 100000);
    assertTrue(rd.asynchronousScan());
    assertTrue(rd.synchronousScan());
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) RecoveryDriver(com.arjuna.ats.arjuna.recovery.RecoveryDriver) Test(org.junit.Test)

Example 8 with RecoveryManager

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

the class RecoveryManagerUnitTest method testSuspendResume.

@Test
public void testSuspendResume() throws Exception {
    recoveryPropertyManager.getRecoveryEnvironmentBean().setPeriodicRecoveryPeriod(1);
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1);
    RecoveryManager rm = RecoveryManager.manager();
    rm.scan(null);
    rm.suspend(false);
    rm.resume();
    assertTrue(rm.getModules() != null);
    rm.removeModule(null, true);
    rm.removeAllModules(true);
    rm.terminate(false);
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) Test(org.junit.Test)

Example 9 with RecoveryManager

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

the class RecoveryTest method directRecoverableConnection.

@Test
@BMRule(name = "throw rmfail xaexception", targetClass = "org.h2.jdbcx.JdbcXAConnection", targetMethod = "commit", action = "throw new javax.transaction.xa.XAException(javax.transaction.xa.XAException.XAER_RMFAIL)", targetLocation = "AT ENTRY")
public void directRecoverableConnection() throws Exception {
    // jdbc:arjuna: <path to properties file>, path starting at System.getProperty("user.dir")
    String url = TransactionalDriver.arjunaDriver + "ds-direct.properties";
    Properties dbProperties = new Properties();
    dbProperties.put(TransactionalDriver.dynamicClass, PropertyFileDynamicClass.class.getName());
    dbProperties.put(TransactionalDriver.userName, "");
    dbProperties.put(TransactionalDriver.password, "");
    Properties p = System.getProperties();
    p.put("jdbc.drivers", Driver.class.getName());
    System.setProperties(p);
    transactionalDriver = new TransactionalDriver();
    DriverManager.registerDriver(transactionalDriver);
    step0_setupTables(url, dbProperties);
    // rmfail means the db connection was left to be recovered
    step1_leaveXidsInDbTable(url, dbProperties);
    step2_checkDbIsNotCommitted(url, dbProperties);
    // 3. Perform recovery - checking only top down XARecoveryModule functionality
    {
        XARecoveryModule xarm = new XARecoveryModule();
        RecoveryManager manager = RecoveryManager.manager();
        manager.removeAllModules(true);
        manager.addModule(xarm);
        AtomicActionRecoveryModule aarm = new AtomicActionRecoveryModule();
        aarm.periodicWorkFirstPass();
        Transformer.disableTriggers(true);
        aarm.periodicWorkSecondPass();
        Transformer.enableTriggers(true);
    }
    step4_finalDbCommitCheck(url, dbProperties);
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) AtomicActionRecoveryModule(com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule) TransactionalDriver(com.arjuna.ats.jdbc.TransactionalDriver) Driver(org.h2.Driver) PropertyFileDynamicClass(com.arjuna.ats.internal.jdbc.drivers.PropertyFileDynamicClass) Properties(java.util.Properties) TransactionalDriver(com.arjuna.ats.jdbc.TransactionalDriver) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) BMRule(org.jboss.byteman.contrib.bmunit.BMRule) Test(org.junit.Test)

Example 10 with RecoveryManager

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

the class XARecoveryModule method getRegisteredXARecoveryModule.

public static XARecoveryModule getRegisteredXARecoveryModule() {
    if (registeredXARecoveryModule == null) {
        RecoveryManager recMan = RecoveryManager.manager();
        Vector recoveryModules = recMan.getModules();
        if (recoveryModules != null) {
            Enumeration modules = recoveryModules.elements();
            while (modules.hasMoreElements()) {
                RecoveryModule m = (RecoveryModule) modules.nextElement();
                if (m instanceof XARecoveryModule) {
                    registeredXARecoveryModule = (XARecoveryModule) m;
                    break;
                }
            }
        }
    }
    return registeredXARecoveryModule;
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) Enumeration(java.util.Enumeration) RecoveryModule(com.arjuna.ats.arjuna.recovery.RecoveryModule) Vector(java.util.Vector)

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