Search in sources :

Example 71 with AtomicAction

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

the class ExtendedLinkedListUnitTest method testLinkedList.

public void testLinkedList() throws Exception {
    NodeImple ni1 = new NodeImple("one");
    NodeImple ni2 = new NodeImple("two");
    NodeImple ni3 = new NodeImple("three");
    AtomicAction A = new AtomicAction();
    Node h1 = theContainer.enlist(ni1);
    Node h2 = theContainer.enlist(ni2);
    Node h3 = theContainer.enlist(ni3);
    h1.setNext(h2);
    h2.setPrev(h1);
    assertEquals(h1.getPrev(), null);
    assertEquals(h2.getPrev().nodeName(), h1.nodeName());
    A.begin();
    h1.setNext(h3);
    h2.setPrev(null);
    h3.setPrev(h1);
    A.abort();
    assertEquals(h1.getNext().nodeName(), h2.nodeName());
    assertEquals(h1.getPrev(), null);
    assertEquals(h2.getPrev().nodeName(), h1.nodeName());
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction)

Example 72 with AtomicAction

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

the class LockFreeUnitTest method test.

public void test() {
    Container<Sample> theContainer = new Container<Sample>();
    Sample obj = theContainer.create(new SampleLockable(10));
    assertTrue(obj != null);
    AtomicAction act = new AtomicAction();
    System.err.println("Started transaction: " + act);
    act.begin();
    boolean result = obj.increment();
    assertTrue(result);
    result = obj.decrement();
    assertTrue(result);
    act.commit();
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction)

Example 73 with AtomicAction

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

the class AtomicLinkedListUnitTest method testLinkedList.

public void testLinkedList() throws Exception {
    ExtendedAtomicLinkedList ni1 = new LinkedListEntry("one");
    ExtendedAtomicLinkedList ni2 = new LinkedListEntry("two");
    ExtendedAtomicLinkedList ni3 = new LinkedListEntry("three");
    AtomicAction A = new AtomicAction();
    ExtendedAtomicLinkedList h1 = theContainer.enlist(ni1);
    ExtendedAtomicLinkedList h2 = theContainer.enlist(ni2);
    ExtendedAtomicLinkedList h3 = theContainer.enlist(ni3);
    h1.setNext(h2);
    h2.setPrev(h1);
    assertEquals(h1.getPrev(), null);
    assertEquals(((ExtendedAtomicLinkedList) h2.getPrev()).nodeName(), h1.nodeName());
    A.begin();
    h1.setNext(h3);
    h2.setPrev(null);
    h3.setPrev(h1);
    A.abort();
    assertEquals(((ExtendedAtomicLinkedList) h1.getNext()).nodeName(), h2.nodeName());
    assertEquals(h1.getPrev(), null);
    assertEquals(((ExtendedAtomicLinkedList) h2.getPrev()).nodeName(), h1.nodeName());
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction)

Example 74 with AtomicAction

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

the class Service01 method setupOper.

/**
 * passing in true to this operation will force the records to be enlisted into a new transaction
 * nesting the new transaction within any other running transaction.
 */
public void setupOper(boolean nest) {
    // create abstract records
    mTransaction = (AtomicAction) AtomicAction.Current();
    if (nest || mTransaction == null) {
        mTransaction = new AtomicAction();
        mTransaction.begin();
    }
    qautil.qadebug("createing abstract records and enlisting them");
    mAbstractRecordList = new BasicAbstractRecord[mNumberOfResources];
    // set up abstract records
    for (int i = 0; i < mNumberOfResources; i++) {
        mAbstractRecordList[i] = new BasicAbstractRecord();
        if (mTransaction.add(mAbstractRecordList[i]) != AddOutcome.AR_ADDED) {
            qautil.debug("Error when adding: " + i + " to atomic action");
            mCorrect = false;
        }
    }
    mNest = nest;
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction)

Example 75 with AtomicAction

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

the class ThreadActionTest method testOthers.

@Test
public void testOthers() {
    DummySetup ds = new DummySetup();
    ThreadActionData.addSetup(ds);
    AtomicAction A = new AtomicAction();
    AtomicAction B = new AtomicAction();
    A.begin();
    B.begin();
    assertTrue(ThreadActionData.currentAction() != null);
    ThreadActionData.restoreActions(B);
    assertEquals(ThreadActionData.popAction(), B);
    ThreadActionData.purgeActions(Thread.currentThread());
    assertTrue(ds.called());
    ThreadActionData.removeSetup(ds);
    ThreadActionData.popAction(Thread.currentThread().getName());
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) 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