Search in sources :

Example 1 with RecoverAtomicAction

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

the class LogStoreReactivationTest2 method test.

@Test
public void test() {
    arjPropertyManager.getCoordinatorEnvironmentBean().setCommitOnePhase(false);
    arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
    arjPropertyManager.getObjectStoreEnvironmentBean().setSynchronousRemoval(true);
    // the byteman script will enforce this
    // System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "1000000");  // essentially infinite
    AtomicAction A = new AtomicAction();
    Uid txId = A.get_uid();
    System.err.println("IMPORTANT: if there are warnings about USER_DEF_FIRST0 then the test has failed!");
    A.begin();
    A.add(new BasicRecord());
    A.commit();
    RecoverAtomicAction rAA = new RecoverAtomicAction(txId, ActionStatus.COMMITTED);
    rAA.replayPhase2();
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) RecoverAtomicAction(com.arjuna.ats.arjuna.recovery.RecoverAtomicAction) Uid(com.arjuna.ats.arjuna.common.Uid) LogStore(com.arjuna.ats.internal.arjuna.objectstore.LogStore) BasicRecord(com.hp.mwtests.ts.arjuna.resources.BasicRecord) RecoverAtomicAction(com.arjuna.ats.arjuna.recovery.RecoverAtomicAction) Test(org.junit.Test)

Example 2 with RecoverAtomicAction

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

the class AtomicActionRecoveryModule method doRecoverTransaction.

private void doRecoverTransaction(Uid recoverUid) {
    boolean commitThisTransaction = true;
    // Retrieve the transaction status from its original process.
    int theStatus = _transactionStatusConnectionMgr.getTransactionStatus(_transactionType, recoverUid);
    boolean inFlight = isTransactionInMidFlight(theStatus);
    String Status = ActionStatus.stringForm(theStatus);
    if (tsLogger.logger.isDebugEnabled()) {
        tsLogger.logger.debug("transaction type is " + _transactionType + " uid is " + recoverUid.toString() + "\n ActionStatus is " + Status + " in flight is " + inFlight);
    }
    if (!inFlight) {
        try {
            RecoverAtomicAction rcvAtomicAction = new RecoverAtomicAction(recoverUid, theStatus);
            rcvAtomicAction.replayPhase2();
        } catch (Exception ex) {
            tsLogger.i18NLogger.warn_recovery_AtomicActionRecoveryModule_2(recoverUid, ex);
        }
    }
}
Also used : RecoverAtomicAction(com.arjuna.ats.arjuna.recovery.RecoverAtomicAction) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Example 3 with RecoverAtomicAction

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

the class LogStoreReactivationTest method test.

@Test
public void test() {
    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
    AtomicAction A = new AtomicAction();
    Uid txId = A.get_uid();
    System.err.println("IMPORTANT: ignore warnings about USER_DEF_FIRST0 as they are expected due to BasicRecord usage!");
    A.begin();
    A.add(new BasicRecord());
    A.commit();
    RecoverAtomicAction rAA = new RecoverAtomicAction(txId, ActionStatus.COMMITTED);
    rAA.replayPhase2();
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) RecoverAtomicAction(com.arjuna.ats.arjuna.recovery.RecoverAtomicAction) Uid(com.arjuna.ats.arjuna.common.Uid) LogStore(com.arjuna.ats.internal.arjuna.objectstore.LogStore) BasicRecord(com.hp.mwtests.ts.arjuna.resources.BasicRecord) RecoverAtomicAction(com.arjuna.ats.arjuna.recovery.RecoverAtomicAction) Test(org.junit.Test)

Example 4 with RecoverAtomicAction

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

the class RecoverAtomicActionTest method test.

@Test
public void test() {
    RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
    OutputObjectState fluff = new OutputObjectState();
    Uid kungfuTx = new Uid();
    boolean passed = false;
    final String tn = new AtomicAction().type();
    try {
        UidHelper.packInto(kungfuTx, fluff);
        System.err.println("Creating dummy log");
        recoveryStore.write_committed(kungfuTx, tn, fluff);
        if (recoveryStore.currentState(kungfuTx, tn) == StateStatus.OS_COMMITTED) {
            System.err.println("Wrote dummy transaction " + kungfuTx);
            RecoverAtomicAction rAA = new RecoverAtomicAction(kungfuTx, ActionStatus.COMMITTED);
            if (!rAA.activate()) {
                rAA.replayPhase2();
                if (recoveryStore.currentState(kungfuTx, tn) == StateStatus.OS_UNKNOWN)
                    passed = true;
            }
        } else
            System.err.println("State is not committed!");
    } catch (final Exception ex) {
        ex.printStackTrace();
    }
    assertTrue(passed);
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) AtomicAction(com.arjuna.ats.arjuna.AtomicAction) RecoverAtomicAction(com.arjuna.ats.arjuna.recovery.RecoverAtomicAction) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) RecoverAtomicAction(com.arjuna.ats.arjuna.recovery.RecoverAtomicAction) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore) Test(org.junit.Test)

Example 5 with RecoverAtomicAction

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

the class XARecoveryModuleUnitTest method testRecoverFromMultipleXAResourceRecovery.

@Test
public void testRecoverFromMultipleXAResourceRecovery() throws Exception {
    // Make sure the file doesn't exist
    assertFalse(new File("XARR.txt").exists());
    ArrayList<String> r = new ArrayList<String>();
    AtomicAction aa = new AtomicAction();
    aa.begin();
    assertEquals(AddOutcome.AR_ADDED, aa.add(new XAResourceRecord(null, new XARRTestResource(), new XidImple(aa), null)));
    Class c = BasicAction.class;
    Method method = c.getDeclaredMethod("prepare", boolean.class);
    method.setAccessible(true);
    int result = (Integer) method.invoke(aa, new Object[] { true });
    assertEquals(result, TwoPhaseOutcome.PREPARE_OK);
    // Make sure the file exists
    assertTrue(new File("XARR.txt").exists());
    // AtomicActionRecoveryModule aaRecoveryModule = new AtomicActionRecoveryModule();
    // aaRecoveryModule.periodicWorkFirstPass();
    // aaRecoveryModule.periodicWorkSecondPass();
    RecordTypeManager.manager().add(new RecordTypeMap() {

        @SuppressWarnings("unchecked")
        public Class getRecordClass() {
            return XAResourceRecord.class;
        }

        public int getType() {
            return RecordType.JTA_RECORD;
        }
    });
    List<String> xarn = new ArrayList<String>();
    xarn.add(NodeNameXAResourceOrphanFilter.RECOVER_ALL_NODES);
    jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(xarn);
    XARecoveryModule xaRecoveryModule = new XARecoveryModule();
    Field safetyIntervalMillis = RecoveryXids.class.getDeclaredField("safetyIntervalMillis");
    safetyIntervalMillis.setAccessible(true);
    safetyIntervalMillis.set(null, 0);
    xaRecoveryModule.addXAResourceRecoveryHelper(new XARROne());
    xaRecoveryModule.addXAResourceRecoveryHelper(new XARRTwo());
    xaRecoveryModule.addXAResourceOrphanFilter(new com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter());
    xaRecoveryModule.addXAResourceOrphanFilter(new com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter());
    RecoveryManager.manager().addModule(xaRecoveryModule);
    // This is done rather than using the AtomicActionRecoveryModule as the transaction is inflight
    RecoverAtomicAction rcvAtomicAction = new RecoverAtomicAction(aa.get_uid(), ActionStatus.COMMITTED);
    rcvAtomicAction.replayPhase2();
    // The XARM would execute next
    xaRecoveryModule.periodicWorkFirstPass();
    xaRecoveryModule.periodicWorkSecondPass();
    // Make sure the file doesn't exist
    assertFalse(new File("XARR.txt").exists());
    aa.abort();
}
Also used : JTANodeNameXAResourceOrphanFilter(com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter) ArrayList(java.util.ArrayList) AtomicAction(com.arjuna.ats.internal.jta.transaction.arjunacore.AtomicAction) RecoverAtomicAction(com.arjuna.ats.arjuna.recovery.RecoverAtomicAction) Field(java.lang.reflect.Field) RecoverAtomicAction(com.arjuna.ats.arjuna.recovery.RecoverAtomicAction) XidImple(com.arjuna.ats.jta.xa.XidImple) XAResourceRecord(com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) Method(java.lang.reflect.Method) RecordTypeMap(com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeMap) File(java.io.File) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) Test(org.junit.Test)

Aggregations

RecoverAtomicAction (com.arjuna.ats.arjuna.recovery.RecoverAtomicAction)6 Test (org.junit.Test)5 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)4 Uid (com.arjuna.ats.arjuna.common.Uid)4 LogStore (com.arjuna.ats.internal.arjuna.objectstore.LogStore)2 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)2 BasicRecord (com.hp.mwtests.ts.arjuna.resources.BasicRecord)2 Field (java.lang.reflect.Field)2 ArrayList (java.util.ArrayList)2 RecoveryEnvironmentBean (com.arjuna.ats.arjuna.common.RecoveryEnvironmentBean)1 BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)1 RecordList (com.arjuna.ats.arjuna.coordinator.RecordList)1 RecordTypeMap (com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeMap)1 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)1 RecoveryStore (com.arjuna.ats.arjuna.objectstore.RecoveryStore)1 ActionStatusService (com.arjuna.ats.arjuna.recovery.ActionStatusService)1 RecoveryModule (com.arjuna.ats.arjuna.recovery.RecoveryModule)1 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)1 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)1 JTANodeNameXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter)1