Search in sources :

Example 81 with AtomicAction

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

the class RecoverableTest method test.

@Test
public void test() {
    RecoverableObject foo = new RecoverableObject();
    AtomicAction A = new AtomicAction();
    A.begin();
    foo.set(2);
    assertEquals(2, foo.get());
    A.abort();
    assertEquals(0, foo.get());
    AtomicAction B = new AtomicAction();
    B.begin();
    foo.set(4);
    assertEquals(4, foo.get());
    B.commit();
    assertEquals(4, foo.get());
}
Also used : RecoverableObject(com.hp.mwtests.ts.txoj.common.resources.RecoverableObject) AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Test(org.junit.Test)

Example 82 with AtomicAction

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

the class BasicThreadedObject method run.

public void run() {
    if (startAction) {
        BasicThreadedObject.A = new AtomicAction();
        System.out.println("BasicThreadedObject " + uid + " created action " + BasicThreadedObject.A.get_uid());
        BasicThreadedObject.A.begin();
        Thread.yield();
    } else {
        System.out.println("BasicThreadedObject " + uid + " adding to existing action");
        if (A != null)
            BasicThreadedObject.A.addThread();
        Thread.yield();
    }
    BasicAction act = BasicAction.Current();
    if (act != null)
        System.out.println("BasicThreadedObject " + uid + " current action " + act.get_uid());
    else
        System.out.println("BasicThreadedObject " + uid + " current action null");
    try {
        BasicThreadedObject.O.incr(4);
        Thread.yield();
    } catch (Exception e) {
    }
    if (startAction) {
        System.out.println("\nBasicThreadedObject " + uid + " committing action " + act.get_uid());
        BasicThreadedObject.A.commit();
        System.out.println("BasicThreadedObject " + uid + " action " + act.get_uid() + " committed\n");
    } else {
        System.out.println("\nBasicThreadedObject " + uid + " aborting action " + act.get_uid());
        BasicThreadedObject.A.abort();
        System.out.println("BasicThreadedObject " + uid + " action " + act.get_uid() + " aborted\n");
    }
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction)

Example 83 with AtomicAction

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

the class BasicTest method test.

@Test
public void test() throws Exception {
    AtomicAction A = new AtomicAction();
    BasicObject bo = new BasicObject();
    A.begin();
    bo.set(2);
    A.commit();
    assertTrue(bo.getStore() != null);
    assertTrue(bo.getStoreRoot() != null);
    assertEquals(bo.getObjectModel(), ObjectModel.SINGLE);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) BasicObject(com.hp.mwtests.ts.arjuna.resources.BasicObject) Test(org.junit.Test)

Example 84 with AtomicAction

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

the class TxLogStateManagerUnitTest method test.

@Test
public void test() throws Exception {
    AtomicAction A = new AtomicAction();
    TxStateManager tm = new TxStateManager();
    arjPropertyManager.getCoordinatorEnvironmentBean().setClassicPrepare(true);
    A.begin();
    assertTrue(tm.modified());
    assertTrue(tm.writeOptimisation());
    A.commit();
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Test(org.junit.Test)

Example 85 with AtomicAction

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

the class CadaverUnitTest method testAbort.

@Test
public void testAbort() throws Exception {
    AtomicAction A = new AtomicAction();
    AtomicObject B = new AtomicObject(ObjectModel.MULTIPLE);
    Uid u = B.get_uid();
    A.begin();
    B.set(1234);
    A.commit();
    A = new AtomicAction();
    B = new AtomicObject(u, ObjectModel.MULTIPLE);
    A.begin();
    AtomicAction C = new AtomicAction();
    C.begin();
    assertEquals(B.get(), 1234);
    B.set(5678);
    B.terminate();
    C.commit();
    assertEquals(A.abort(), ActionStatus.ABORTED);
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Uid(com.arjuna.ats.arjuna.common.Uid) AtomicObject(com.hp.mwtests.ts.txoj.common.resources.AtomicObject) 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