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");
}
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();
}
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);
}
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)));
}
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);
}
Aggregations