Search in sources :

Example 1 with ParticipantStore

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);
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) CacheStore(com.arjuna.ats.internal.arjuna.objectstore.CacheStore) ParticipantStore(com.arjuna.ats.arjuna.objectstore.ParticipantStore) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) Test(org.junit.Test)

Example 2 with ParticipantStore

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);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) StringWriter(java.io.StringWriter) ParticipantStore(com.arjuna.ats.arjuna.objectstore.ParticipantStore) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 3 with ParticipantStore

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);
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ExtendedObject(com.hp.mwtests.ts.arjuna.resources.ExtendedObject) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) PersistenceRecord(com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ParticipantStore(com.arjuna.ats.arjuna.objectstore.ParticipantStore) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 4 with ParticipantStore

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;
}
Also used : ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) ParticipantStore(com.arjuna.ats.arjuna.objectstore.ParticipantStore)

Example 5 with ParticipantStore

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();
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) ParticipantStore(com.arjuna.ats.arjuna.objectstore.ParticipantStore) Test(org.junit.Test)

Aggregations

ParticipantStore (com.arjuna.ats.arjuna.objectstore.ParticipantStore)14 Test (org.junit.Test)9 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)7 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)7 Uid (com.arjuna.ats.arjuna.common.Uid)6 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)4 PersistenceRecord (com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord)4 ExtendedObject (com.hp.mwtests.ts.arjuna.resources.ExtendedObject)4 ObjectStoreEnvironmentBean (com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean)3 CacheStore (com.arjuna.ats.internal.arjuna.objectstore.CacheStore)3 PrintWriter (java.io.PrintWriter)3 SystemException (org.omg.CORBA.SystemException)3 DisposeRecord (com.arjuna.ats.internal.arjuna.abstractrecords.DisposeRecord)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)1 CadaverActivationRecord (com.arjuna.ats.internal.arjuna.abstractrecords.CadaverActivationRecord)1 CadaverRecord (com.arjuna.ats.internal.arjuna.abstractrecords.CadaverRecord)1 ShadowingStore (com.arjuna.ats.internal.arjuna.objectstore.ShadowingStore)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1