Search in sources :

Example 36 with AtomicAction

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

the class TXBasicLockRecord2 method getValue.

public int getValue(int retry, int wait_time) {
    int return_value = 0;
    AtomicAction a = new AtomicAction();
    a.begin();
    try {
        int locking_result = LockResult.REFUSED;
        int locking_attempt_count = 0;
        Lock lck = new Lock(LockMode.READ);
        do {
            locking_result = setlock(lck, retry, wait_time);
            if (locking_result == LockResult.GRANTED) {
                return_value = mValue;
            } else {
                locking_attempt_count++;
            }
        } while ((locking_result != LockResult.GRANTED) && (locking_attempt_count < mLimit));
        if (locking_result != LockResult.GRANTED) {
            qautil.qadebug("trying to get lock for " + mLimit + "th time");
        }
        a.commit();
    } catch (Exception e) {
        a.abort();
        qautil.debug("exception in get method ", e);
    }
    return return_value;
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Lock(com.arjuna.ats.txoj.Lock)

Example 37 with AtomicAction

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

the class Worker001 method run.

/**
 * The main method of the class that will perform the work.
 */
public void run() {
    try {
        AtomicAction a = new AtomicAction();
        // start transaction
        a.begin();
        mService.setupOper();
        mService.doWork(mMaxIteration);
        // comit transaction
        a.commit();
        mService = new Service01(mNumberOfResources);
        // start new AtomicAction
        AtomicAction b = new AtomicAction();
        b.begin();
        mService.setupOper();
        mService.doWork(mMaxIteration);
        b.abort();
    } catch (Exception e) {
        mCorrect = false;
        qautil.debug("exception in worker001: ", e);
    }
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction) Service01(org.jboss.jbossts.qa.ArjunaCore.AbstractRecord.impl.Service01)

Example 38 with AtomicAction

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

the class Worker003 method run.

/**
 * The main method of the class that will perform the work.
 */
public void run() {
    try {
        // start first loop
        for (int j = 0; j < mNumberOfResources; j++) {
            for (int i = 0; i < mMaxIteration; i++) {
                // start transaction
                AtomicAction a = new AtomicAction();
                a.begin();
                // perform increase
                mStatetRecordList[j].increase();
                if (i % 2 == 0) {
                    a.commit();
                } else {
                    a.abort();
                }
            }
        }
        // start second loop
        for (int j = 0; j < mNumberOfResources; j++) {
            for (int i = 0; i < mMaxIteration; i++) {
                // start transaction
                AtomicAction b = new AtomicAction();
                b.begin();
                // perform increase
                mStatetRecordList[j].increase();
                if (i % 2 != 0) {
                    b.commit();
                } else {
                    b.abort();
                }
            }
        }
    } catch (Exception e) {
        mCorrect = false;
        qautil.debug("exception in worker001: ", e);
    }
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction)

Example 39 with AtomicAction

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

the class BaseTestClient method startTx.

public void startTx() throws Exception {
    mAtom = new AtomicAction();
    mAtom.begin();
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction)

Example 40 with AtomicAction

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

the class Worker004 method run.

/**
 * The main method of the class that will perform the work.
 */
public void run() {
    try {
        // start first loop
        for (int j = 0; j < mNumberOfResources; j++) {
            for (int i = 0; i < mMaxIteration; i++) {
                // start transaction
                AtomicAction a = new AtomicAction();
                a.begin();
                // perform increase (this will enlist resource)
                mStatetRecordList[j].increase();
                if (i % 2 == 0) {
                    a.commit();
                } else {
                    a.abort();
                }
            }
        }
        // start second loop
        for (int j = 0; j < mNumberOfResources; j++) {
            for (int i = 0; i < mMaxIteration; i++) {
                // start transaction
                AtomicAction b = new AtomicAction();
                b.begin();
                // perform increase(this will enlist resource)
                mStatetRecordList[j].increase();
                if (i % 2 != 0) {
                    b.commit();
                } else {
                    b.abort();
                }
            }
        }
    } catch (Exception e) {
        mCorrect = false;
        qautil.debug("exception in worker001: ", e);
    }
}
Also used : AtomicAction(com.arjuna.ats.arjuna.AtomicAction)

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