use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.
the class AtomicObject method set.
public synchronized boolean set(int value) {
boolean res = false;
CurrentImple current = OTSImpleManager.current();
try {
current.begin();
if (setlock(new Lock(LockMode.WRITE), 5) == LockResult.GRANTED) {
_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 DemoArjunaResource method registerResource.
public void registerResource(boolean registerSubtran) throws Unavailable, Inactive, NotSubtransaction, SystemException {
CurrentImple current = OTSImpleManager.current();
Control myControl = current.get_control();
Coordinator coord = myControl.get_coordinator();
if (registerSubtran)
coord.register_subtran_aware(ref);
else
coord.register_resource(ref);
System.out.println("Registered DemoArjunaResource");
}
use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.
the class ImplicitClient method main.
public static void main(String[] args) throws Exception {
ServerORB orb = new ServerORB();
ORB myORB = orb.getORB();
RootOA myOA = orb.getOA();
String refFile = args[0];
CurrentImple current = OTSImpleManager.current();
// pointer the grid object that will be used.
TranGrid TranGridVar = null;
short h = 0, w = 0, v = 0;
try {
current.begin();
Services serv = new Services(myORB);
TranGridVar = TranGridHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(refFile)));
try {
h = TranGridVar.height();
w = TranGridVar.width();
} catch (Exception e) {
TestUtility.fail("Invocation failed: " + e);
}
System.out.println("height is " + h);
System.out.println("width is " + w);
try {
System.out.println("calling set");
TranGridVar.set((short) 2, (short) 4, (short) 123);
System.out.println("calling get");
v = TranGridVar.get((short) 2, (short) 4);
} catch (Exception sysEx) {
TestUtility.fail("Grid set/get failed: " + sysEx);
sysEx.printStackTrace(System.err);
}
// no problem setting and getting the element:
System.out.println("trangrid[2,4] is " + v);
if (v != 123) {
// oops - we didn't:
current.rollback();
TestUtility.fail("Result not as expected");
} else {
current.commit(true);
}
} catch (Exception e) {
TestUtility.fail("Caught exception: " + e);
e.printStackTrace(System.err);
}
myOA.destroy();
myORB.shutdown();
System.out.println("Passed");
}
use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.
the class ImplicitArjunaClient method main.
public static void main(String[] args) throws Exception {
ServerORB orb = new ServerORB();
ORB myORB = orb.getORB();
RootOA myOA = orb.getOA();
String refFile = args[0];
CurrentImple current = OTSImpleManager.current();
// pointer the grid object that will be used.
stack stackVar = null;
try {
current.begin();
try {
Services serv = new Services(myORB);
stackVar = stackHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(refFile)));
} catch (Exception e) {
e.printStackTrace(System.err);
TestUtility.fail(e.toString());
}
System.out.println("pushing 1 onto stack");
stackVar.push(1);
System.out.println("pushing 2 onto stack");
stackVar.push(2);
} catch (Exception e) {
e.printStackTrace(System.err);
TestUtility.fail(e.toString());
}
try {
current.commit(false);
current.begin();
IntHolder val = new IntHolder(-1);
if (stackVar.pop(val) == 0) {
System.out.println("popped top of stack " + val.value);
current.begin();
stackVar.push(3);
System.out.println("pushed 3 onto stack. Aborting nested action.");
current.rollback();
stackVar.pop(val);
System.out.println("popped top of stack is " + val.value);
current.commit(false);
TestUtility.assertEquals(1, val.value);
} else {
TestUtility.fail("Error getting stack value.");
current.rollback();
}
} catch (Exception e) {
e.printStackTrace(System.err);
TestUtility.fail(e.toString());
}
myOA.destroy();
myORB.shutdown();
System.out.println("Passed");
}
use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.
the class DHThreadObject3b method run.
public void run() {
for (int i = 0; i < 1000; i++) {
CurrentImple current = OTSImpleManager.current();
System.out.println("Tripling the timeout from: " + current.get_timeout());
current.set_timeout(current.get_timeout() * 3);
DistributedHammerWorker3.randomOperation(_id, 0);
Util.highProbYield();
}
}
Aggregations