Search in sources :

Example 41 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.

the class TXBasicStateRecord method increase.

/**
 * We will start a subtrancastion during the increase to see what effet this has.
 */
public void increase() {
    qautil.qadebug("start increase");
    AtomicAction a = new AtomicAction();
    try {
        a.begin();
        activate();
        modified();
        mValue++;
        a.commit();
    } catch (Exception e) {
        a.abort();
        qautil.debug("exception in increase method ", e);
    }
    qautil.qadebug("end increase");
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction)

Example 42 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction 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 43 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.

the class LogStressTest2 method test.

@Test
public void test() {
    arjPropertyManager.getCoordinatorEnvironmentBean().setCommitOnePhase(false);
    arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
    arjPropertyManager.getObjectStoreEnvironmentBean().setTxLogSize(10000);
    // hours
    int timeLimit = 4;
    System.err.println("WARNING: this test will run for " + timeLimit + " hours.");
    final long stime = System.currentTimeMillis();
    final long endTime = timeLimit * 60 * 60 * 1000;
    long ftime;
    do {
        try {
            AtomicAction A = new AtomicAction();
            A.begin();
            A.add(new BasicRecord());
            A.commit();
        } catch (final Exception ex) {
        }
        ftime = System.currentTimeMillis();
    } while ((ftime - stime) < endTime);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) LogStore(com.arjuna.ats.internal.arjuna.objectstore.LogStore) BasicRecord(com.hp.mwtests.ts.arjuna.resources.BasicRecord) Test(org.junit.Test)

Example 44 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.

the class ActionStatusServiceTest method runTest.

public void runTest(int crashType, String[] expectedStatus, boolean doAbort) {
    ActionStatusService _test_service = new ActionStatusService();
    AtomicAction _transaction_1 = new AtomicAction();
    String _test_tran_type_1 = _transaction_1.type();
    Uid _test_uid_1 = _transaction_1.getSavingUid();
    String test_uid = _test_uid_1.toString();
    String test_type = _test_tran_type_1;
    assertEquals(expectedStatus[0], ActionStatus.stringForm(_test_service.getTransactionStatus(test_type, test_uid)));
    assertEquals(expectedStatus[0], ActionStatus.stringForm(_test_service.getTransactionStatus("", test_uid)));
    _transaction_1.begin();
    CrashAbstractRecordImpl cr1 = new CrashAbstractRecordImpl(crashType);
    CrashAbstractRecordImpl cr2 = new CrashAbstractRecordImpl(crashType);
    assertEquals(AddOutcome.AR_ADDED, _transaction_1.add(cr1));
    assertEquals(AddOutcome.AR_ADDED, _transaction_1.add(cr2));
    assertEquals(expectedStatus[1], ActionStatus.stringForm(_test_service.getTransactionStatus(test_type, test_uid)));
    assertEquals(expectedStatus[1], ActionStatus.stringForm(_test_service.getTransactionStatus("", test_uid)));
    if (doAbort) {
        _transaction_1.abort();
    } else {
        _transaction_1.commit();
    }
    assertEquals(expectedStatus[2], ActionStatus.stringForm(_test_service.getTransactionStatus(test_type, test_uid)));
    assertEquals(expectedStatus[2], ActionStatus.stringForm(_test_service.getTransactionStatus("", test_uid)));
}
Also used : ActionStatusService(com.arjuna.ats.arjuna.recovery.ActionStatusService) AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Uid(com.arjuna.ats.arjuna.common.Uid)

Example 45 with AtomicAction

use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.

the class DestroyRecoverTest method test.

@Test
public void test() {
    arjPropertyManager.getCoordinatorEnvironmentBean().setAlternativeRecordOrdering(true);
    AtomicAction A = new AtomicAction();
    BasicObject bo = null;
    Uid txId = null;
    Uid objId = null;
    boolean passed = true;
    try {
        A.begin();
        bo = new BasicObject();
        objId = bo.get_uid();
        A.removeThread();
        A.commit();
    } catch (Exception ex) {
        ex.printStackTrace();
        passed = false;
    }
    if (passed) {
        try {
            A = new AtomicAction();
            txId = A.get_uid();
            A.begin();
            bo.activate();
            bo.destroy();
            A.add(new BasicCrashRecord());
            A.removeThread();
            A.commit();
        } catch (com.arjuna.ats.arjuna.exceptions.FatalError ex) {
        // ignore
        } catch (Exception ex) {
            ex.printStackTrace();
            passed = false;
        }
    }
    if (passed) {
        try {
            passed = false;
            RecoveryTransaction tx = new RecoveryTransaction(txId);
            tx.doCommit();
            /*
                 * Committing the recovered transaction should have disposed of the
                 * user object, meaning activation will fail. Which for this test
                 * is a successful outcome!
                 */
            BasicObject recoveredObject = new BasicObject(objId);
            if (recoveredObject.get() == -1)
                passed = true;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    assertTrue(passed);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Uid(com.arjuna.ats.arjuna.common.Uid) BasicObject(com.hp.mwtests.ts.arjuna.resources.BasicObject) Test(org.junit.Test)

Aggregations

AtomicAction (com.arjuna.ats.arjuna.AtomicAction)179 Test (org.junit.Test)73 Uid (com.arjuna.ats.arjuna.common.Uid)31 TestException (com.hp.mwtests.ts.txoj.common.exceptions.TestException)30 AtomicObject (com.hp.mwtests.ts.txoj.common.resources.AtomicObject)18 Lock (com.arjuna.ats.txoj.Lock)17 RecoverableContainer (org.jboss.stm.internal.RecoverableContainer)8 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)7 PrintWriter (java.io.PrintWriter)7 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)5 ExtendedObject (com.hp.mwtests.ts.arjuna.resources.ExtendedObject)5 Container (org.jboss.stm.Container)5 RecoverAtomicAction (com.arjuna.ats.arjuna.recovery.RecoverAtomicAction)4 BasicRecord (com.hp.mwtests.ts.arjuna.resources.BasicRecord)4 TopLevelAction (com.arjuna.ats.arjuna.TopLevelAction)3 AbstractRecord (com.arjuna.ats.arjuna.coordinator.AbstractRecord)3 BasicAction (com.arjuna.ats.arjuna.coordinator.BasicAction)3 RecoveryModule (com.arjuna.ats.arjuna.recovery.RecoveryModule)3 LogStore (com.arjuna.ats.internal.arjuna.objectstore.LogStore)3 EditableAtomicAction (com.arjuna.ats.internal.arjuna.tools.log.EditableAtomicAction)3