use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.
the class AtomicObject method get.
public synchronized int get() throws TestException {
CurrentImple current = OTSImpleManager.current();
int value = -1;
try {
current.begin();
if (setlock(new Lock(LockMode.READ), 5) == LockResult.GRANTED) {
value = _value;
current.commit(false);
return value;
} else {
current.rollback();
throw new TestException("Could not setlock");
}
} catch (Exception e) {
throw new TestException(e);
}
}
use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.
the class AtomicObject method incr.
public synchronized boolean incr(int value) {
boolean res = false;
CurrentImple current = OTSImpleManager.current();
try {
current.begin();
if (setlock(new Lock(LockMode.WRITE), 5) == LockResult.GRANTED) {
_value = _value + value;
current.commit(false);
res = true;
} else
current.rollback();
} catch (Exception e) {
logger.info(e);
logger.warn(e.getMessage(), e);
;
res = false;
}
return res;
}
use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.
the class DHThreadObject3a method run.
public void run() {
CurrentImple current = OTSImpleManager.current();
try {
current.begin();
Util.indent(_threadId, 0);
System.out.println("begin");
DistributedHammerWorker3.randomOperation(_threadId, 0);
DistributedHammerWorker3.randomOperation(_threadId, 0);
if (_commit)
current.commit(false);
else
current.rollback();
Util.indent(_threadId, 0);
if (_commit)
System.out.println("end");
else
System.out.println("abort");
} catch (Exception e) {
System.err.println(e);
}
}
use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.
the class HammerObject method get.
public boolean get(IntHolder value, Control control) throws SystemException {
boolean res = false;
ExplicitInterposition inter = new ExplicitInterposition();
try {
inter.registerTransaction(control);
} catch (Exception e) {
System.err.println("WARNING HammerObject.incr - could not do interposition");
return false;
}
CurrentImple current = OTSImpleManager.current();
try {
current.begin();
if (setlock(new Lock(LockMode.READ), 0) == LockResult.GRANTED) {
value.value = _value;
current.commit(true);
res = true;
} else
current.rollback();
} catch (Exception e) {
System.err.println("HammerObject.get: " + e);
res = false;
}
inter.unregisterTransaction();
return res;
}
use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.
the class HammerObject method incr.
public boolean incr(int value, Control control) throws SystemException {
boolean res = false;
ExplicitInterposition inter = new ExplicitInterposition();
try {
inter.registerTransaction(control);
} catch (Exception e) {
System.err.println("WARNING HammerObject.incr - could not do interposition");
return false;
}
CurrentImple current = OTSImpleManager.current();
try {
current.begin();
if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED) {
_value = _value + value;
current.commit(true);
res = true;
} else
current.rollback();
} catch (Exception e) {
System.err.println("HammerObject.incr: " + e);
res = false;
}
inter.unregisterTransaction();
return res;
}
Aggregations