Search in sources :

Example 11 with RecoveryManager

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

the class XAResourceRecord method getNewXAResource.

/**
 * This routine finds the new XAResource for the transaction that used the
 * old resource we couldn't serialize. It does this by looking up the
 * XARecoveryModule in the recovery manager and asking it for the
 * XAResource. The recovery manager will then look through its list of
 * registered XARecoveryResource implementations for the appropriate
 * instance. If the XARecoveryModule hasn't been initialised yet then this
 * routine will fail, but on the next scan it should work.
 */
private final XAResource getNewXAResource() {
    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) {
                return ((XARecoveryModule) m).getNewXAResource(this);
            }
        }
    }
    return null;
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) Enumeration(java.util.Enumeration) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) RecoveryModule(com.arjuna.ats.arjuna.recovery.RecoveryModule) Vector(java.util.Vector) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)

Example 12 with RecoveryManager

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

the class ExpiryScannerStartupUnitTest method testExpiryBackground.

@Test
public void testExpiryBackground() throws Exception {
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryModuleClassNames(Arrays.asList(new String[] { XARecoveryModule.class.getName() }));
    recoveryPropertyManager.getRecoveryEnvironmentBean().setExpiryScanners(Arrays.asList(new ExpiryScanner[] { new ExpiryScanner() {

        @Override
        public void scan() {
            AbstractRecord.create(172);
        }

        @Override
        public boolean toBeUsed() {
            return true;
        }
    } }));
    recoveryPropertyManager.getRecoveryEnvironmentBean().setPeriodicRecoveryPeriod(1);
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1);
    RecoveryManager rm = RecoveryManager.manager();
    rm.terminate(false);
}
Also used : ExpiryScanner(com.arjuna.ats.arjuna.recovery.ExpiryScanner) RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) Test(org.junit.Test)

Example 13 with RecoveryManager

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

the class InboundBridgeService method addDeserializerAndOrphanFilter.

private void addDeserializerAndOrphanFilter() {
    final RecoveryManager recoveryManager = RecoveryManager.manager();
    for (RecoveryModule recoveryModule : recoveryManager.getModules()) {
        if (recoveryModule instanceof XARecoveryModule) {
            orphanFilter = new InboundBridgeOrphanFilter();
            ((XARecoveryModule) recoveryModule).addXAResourceOrphanFilter(orphanFilter);
            ((XARecoveryModule) recoveryModule).addSerializableXAResourceDeserializer(new InboundBridge());
        }
    }
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) InboundBridge(org.jboss.narayana.rest.bridge.inbound.InboundBridge) RecoveryModule(com.arjuna.ats.arjuna.recovery.RecoveryModule) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) InboundBridgeRecoveryModule(org.jboss.narayana.rest.bridge.inbound.InboundBridgeRecoveryModule) InboundBridgeOrphanFilter(org.jboss.narayana.rest.bridge.inbound.InboundBridgeOrphanFilter) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)

Example 14 with RecoveryManager

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

the class RecoveryLifecycleTest method test.

@Test
public void test() {
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1);
    RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
    DummyRecoveryModule module = new DummyRecoveryModule();
    manager.addModule(module);
    manager.scan();
    assertTrue(module.finished());
    manager.terminate();
    manager.initialize();
    module = new DummyRecoveryModule();
    assertFalse(module.finished());
    manager.addModule(module);
    manager.scan();
    assertTrue(module.finished());
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) Test(org.junit.Test)

Example 15 with RecoveryManager

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

the class RecoveryManagerStartStopTest method testStartStop.

@Test
public void testStartStop() throws Exception {
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryPort(4712);
    // check how many threads there are running
    ThreadGroup thg = Thread.currentThread().getThreadGroup();
    int activeCount = thg.activeCount();
    dumpThreadGroup(thg, "Before recovery manager create");
    RecoveryManager.delayRecoveryManagerThread();
    RecoveryManager manager = RecoveryManager.manager(RecoveryManager.INDIRECT_MANAGEMENT);
    dumpThreadGroup(thg, "Before recovery manager initialize");
    manager.initialize();
    dumpThreadGroup(thg, "Before recovery manager start periodic recovery thread");
    manager.startRecoveryManagerThread();
    dumpThreadGroup(thg, "Before recovery manager client create");
    // Thread.sleep(1000);
    // we need to open several connections to the recovery manager listener service and then
    // ensure they get closed down
    addRecoveryClient();
    addRecoveryClient();
    dumpThreadGroup(thg, "Before recovery manager terminate");
    manager.terminate();
    // ensure the client threads get killed
    ensureRecoveryClientsTerminated();
    dumpThreadGroup(thg, "After recovery manager terminate");
    int newActiveCount = thg.activeCount();
    assertEquals(activeCount, newActiveCount);
}
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