use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class DestroyTest method test.
@Test
public void test() {
for (int i = 0; i < 100; i++) {
AtomicAction A = new AtomicAction();
A.begin();
BasicObject bo = new BasicObject();
bo.set(2);
A.commit();
AtomicAction B = new AtomicAction();
AtomicAction C = new AtomicAction();
B.begin();
C.begin();
bo.destroy();
C.commit();
B.abort();
C = new AtomicAction();
C.begin();
bo.destroy();
C.commit();
}
}
use of com.arjuna.ats.arjuna.AtomicAction 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();
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class AtomicActionTestBase method testCompletionWithException.
/**
* Tests for correct behaviour of synchronisations (in the abnormal case)
* @throws Exception
*/
protected void testCompletionWithException() throws Exception {
SyncRecord[] syncs = { new SyncRecord(false, SyncRecord.FailureMode.NONE), new SyncRecord(true, SyncRecord.FailureMode.NONE) };
RuntimeException exception = new RuntimeException("testCompletionWithException");
syncs[0].setBeforeThrowable(exception);
AtomicAction a = executeTest(true, ActionStatus.ABORTED, syncs, new BasicRecord(), new BasicRecord());
/*
* since the first synch failed during the beforeCompletion callback:
* - beforeCompletion should be called on the first one
* - beforeCompletion should not be called on the second one
* - afterCompletion should be called on all synchronisations
* - the synchronization should have throw the runtime exception
* - the final status of the action should be aborted
*/
Assert.assertTrue(syncs[0].getBeforeTimeStamp() != 0);
Assert.assertTrue(syncs[1].getBeforeTimeStamp() == 0);
Assert.assertTrue(syncs[0].getAfterTimeStamp() != 0);
Assert.assertTrue(syncs[1].getAfterTimeStamp() != 0);
Assert.assertEquals(exception, a.getDeferredThrowable());
Assert.assertTrue(syncs[1].getStatus() == ActionStatus.ABORTED);
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class AtomicActionTestBase method testHeuristicNotification.
protected void testHeuristicNotification(boolean reportHeuristics) throws Exception {
AtomicAction A = new AtomicAction();
DummyHeuristic[] dha = { new DummyHeuristic(), new DummyHeuristic() };
A.begin();
A.add(new BasicRecord());
A.add(new BasicRecord());
A.add(new HeuristicRecord());
for (DummyHeuristic dh : dha) A.addSynchronization(dh);
int status = A.commit(reportHeuristics);
if (reportHeuristics)
Assert.assertEquals(ActionStatus.H_MIXED, status);
else if (!arjPropertyManager.getCoordinatorEnvironmentBean().isAsyncCommit())
Assert.assertEquals(ActionStatus.COMMITTED, status);
else
Assert.assertTrue(status == ActionStatus.COMMITTED || status == ActionStatus.COMMITTING);
// we only inform synchronisations of the outcome if report_heuristics is false
int expect = reportHeuristics ? -1 : TwoPhaseOutcome.HEURISTIC_MIXED;
for (DummyHeuristic dh : dha) Assert.assertEquals(expect, dh.getStatus());
}
use of com.arjuna.ats.arjuna.AtomicAction in project narayana by jbosstm.
the class CrashAction method test.
@Test
public void test() {
AtomicAction A = new AtomicAction();
A.begin();
A.add(new CrashRecord(CrashLocation.NoCrash, CrashType.Normal));
A.add(new CrashRecord(CrashLocation.CrashInCommit, CrashType.HeuristicHazard));
int outcome = A.commit();
System.out.println("Transaction " + A + " committed with " + ActionStatus.stringForm(outcome));
}
Aggregations