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;
}
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);
}
}
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);
}
}
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();
}
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);
}
}
Aggregations