use of com.arjuna.ats.arjuna.objectstore.ParticipantStore in project narayana by jbosstm.
the class WriteCachedTest method test.
@Test
public void test() throws ObjectStoreException {
boolean passed = true;
String cacheSize = "20480";
int threads = 10;
Thread[] t = new Thread[threads];
System.setProperty("com.arjuna.ats.internal.arjuna.objectstore.cacheStore.size", cacheSize);
ParticipantStore store = new CacheStore(new ObjectStoreEnvironmentBean());
long stime = Calendar.getInstance().getTime().getTime();
for (int i = 0; (i < threads) && passed; i++) {
try {
t[i] = new WriterThread(store);
t[i].start();
} catch (Exception ex) {
ex.printStackTrace();
passed = false;
}
}
for (int j = 0; j < threads; j++) {
try {
t[j].join();
passed = passed && ((WriterThread) t[j]).passed;
} catch (Exception ex) {
}
}
long ftime = Calendar.getInstance().getTime().getTime();
long timeTaken = ftime - stime;
System.out.println("time for " + threads + " users is " + timeTaken);
try {
store.sync();
} catch (Exception ex) {
}
assertTrue(passed);
}
use of com.arjuna.ats.arjuna.objectstore.ParticipantStore in project narayana by jbosstm.
the class TxStatsSystemErrorUnitTest method test.
@Test
public void test() throws Exception {
final int loopCnt = 100;
final int sysErrCnt = loopCnt / 10;
// first loops includes a nested transaction
final int commitCnt = loopCnt * 2 - sysErrCnt;
final int abortCnt = 100;
final int txnCnt = loopCnt * 2 + abortCnt + 1;
arjPropertyManager.getCoordinatorEnvironmentBean().setEnableStatistics(true);
ParticipantStore pstore = StoreManager.getParticipantStore();
UnreliableTestStore store = (UnreliableTestStore) pstore;
long startTime = System.nanoTime();
for (int i = 0; i < loopCnt; i++) {
if (i % 10 == 0)
store.setWriteError(true);
AtomicAction A = new AtomicAction();
AtomicAction B = new AtomicAction();
A.begin();
B.begin();
A.add(new SimpleAbstractRecord());
A.add(new SimpleAbstractRecord());
B.commit();
A.commit();
if (i % 10 == 0)
store.setWriteError(false);
}
long avgTxnTime = (System.nanoTime() - startTime) / commitCnt;
for (int i = 0; i < abortCnt; i++) {
AtomicAction A = new AtomicAction();
A.begin();
A.abort();
}
AtomicAction B = new AtomicAction();
B.begin();
assertTrue(TxStats.enabled());
assertEquals(abortCnt + sysErrCnt, TxStats.getInstance().getNumberOfAbortedTransactions());
assertEquals(abortCnt, TxStats.getInstance().getNumberOfApplicationRollbacks());
assertEquals(sysErrCnt, TxStats.getInstance().getNumberOfSystemRollbacks());
assertEquals(commitCnt, TxStats.getInstance().getNumberOfCommittedTransactions());
assertEquals(0, TxStats.getInstance().getNumberOfHeuristics());
assertEquals(1, TxStats.getInstance().getNumberOfInflightTransactions());
assertEquals(loopCnt, TxStats.getInstance().getNumberOfNestedTransactions());
assertEquals(0, TxStats.getInstance().getNumberOfResourceRollbacks());
assertEquals(0, TxStats.getInstance().getNumberOfTimedOutTransactions());
assertEquals(txnCnt, TxStats.getInstance().getNumberOfTransactions());
assertTrue(TxStats.getInstance().getAverageCommitTime() < avgTxnTime);
PrintWriter pw = new PrintWriter(new StringWriter());
TxStats.getInstance().printStatus(pw);
}
use of com.arjuna.ats.arjuna.objectstore.ParticipantStore in project narayana by jbosstm.
the class PersistenceRecordUnitTest method test.
@Test
public void test() {
ParticipantStore store = StoreManager.setupStore(null, StateType.OS_UNSHARED);
PersistenceRecord cr = new PersistenceRecord(new OutputObjectState(), store, new ExtendedObject());
arjPropertyManager.getCoordinatorEnvironmentBean().setClassicPrepare(true);
assertFalse(cr.propagateOnAbort());
assertTrue(cr.propagateOnCommit());
assertEquals(cr.typeIs(), RecordType.PERSISTENCE);
assertTrue(cr.type() != null);
assertEquals(cr.doSave(), true);
assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_ERROR);
cr = new PersistenceRecord(new OutputObjectState(), store, new ExtendedObject());
assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
cr.print(new PrintWriter(new ByteArrayOutputStream()));
OutputObjectState os = new OutputObjectState();
assertTrue(cr.save_state(os, ObjectType.ANDPERSISTENT));
assertTrue(cr.restore_state(new InputObjectState(os), ObjectType.ANDPERSISTENT));
assertEquals(cr.topLevelCleanup(), TwoPhaseOutcome.FINISH_OK);
}
use of com.arjuna.ats.arjuna.objectstore.ParticipantStore in project narayana by jbosstm.
the class BasicActionFinalizer method deactivate.
/**
* This operation deactivates a persistent object. It behaves in a similar
* manner to the activate operation, but has an extra argument which defines
* whether the object's state should be committed or written as a shadow.
*
* The root of the object store is <code>null</code>. It is assumed that
* this is being called during a transaction commit.
*
* @return <code>true</code> on success, <code>false</code> otherwise.
*/
public boolean deactivate() {
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("BasicAction::deactivate() for action-id " + get_uid());
}
boolean deactivated = false;
// Set up store
ParticipantStore aaStore = getStore();
if (aaStore == null)
return false;
try {
// Write object state
OutputObjectState oState = new OutputObjectState();
if (save_state(oState, ObjectType.ANDPERSISTENT)) {
deactivated = aaStore.write_committed(getSavingUid(), type(), oState);
oState = null;
} else {
deactivated = false;
}
/**
* If we failed to deactivate then output warning *
*/
if (!deactivated) {
tsLogger.i18NLogger.warn_coordinator_BasicAction_5a(get_uid(), type());
}
} catch (ObjectStoreException e) {
tsLogger.logger.warn(e);
deactivated = false;
}
return deactivated;
}
use of com.arjuna.ats.arjuna.objectstore.ParticipantStore in project narayana by jbosstm.
the class PersistenceTest method test.
@Test
public void test() throws Throwable {
ParticipantStore store = StoreManager.getParticipantStore();
OutputObjectState state = new OutputObjectState();
Uid u = new Uid();
assertTrue(store.write_committed(u, "/StateManager/LockManager/foo", state));
InputObjectState inputState = store.read_committed(u, "/StateManager/LockManager/foo");
assertNotNull(inputState);
store.stop();
}
Aggregations