use of org.omg.CORBA.IntHolder in project narayana by jbosstm.
the class DistributedHammerWorker3 method get21.
public static void get21(int thr, int level) {
boolean res = false;
boolean res1 = false;
boolean res2 = false;
IntHolder value1 = new IntHolder(0);
IntHolder value2 = new IntHolder(0);
try {
OTSImpleManager.current().begin();
Control control = OTSImpleManager.current().get_control();
Util.indent(thr, level);
System.out.println("begin get21");
res1 = hammerObject_2.get(value1, control);
res = res1;
Util.indent(thr, level);
System.out.println("part1 get21 : " + res1);
Util.lowProbYield();
if (res) {
res2 = hammerObject_1.get(value2, control);
res = res2;
Util.indent(thr, level);
System.out.println("part2 get21 : " + res2);
}
Util.lowProbYield();
control = null;
Util.indent(thr, level);
if (res) {
System.out.print("end ");
OTSImpleManager.current().commit(true);
} else {
System.out.print("abort ");
OTSImpleManager.current().rollback();
}
} catch (Exception e) {
System.err.println("DistributedHammerWorker3.get21: " + e);
res1 = res2 = res = false;
}
Util.indent(thr, level);
System.out.println(" get21 : " + res1 + " : " + res2 + " : " + res + " : " + value1.value + " : " + value2.value);
}
use of org.omg.CORBA.IntHolder in project narayana by jbosstm.
the class Client02 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
String counterIOR = ServerIORStore.loadIOR(args[args.length - 1]);
Counter counter = CounterHelper.narrow(ORBInterface.orb().string_to_object(counterIOR));
int numberOfCalls = 1000;
for (int index = 0; index < numberOfCalls; index++) {
AtomicTransaction atomicTransaction = new AtomicTransaction();
atomicTransaction.begin();
counter.increase();
if ((index % 2) == 0) {
atomicTransaction.commit(true);
} else {
atomicTransaction.rollback();
}
}
AtomicTransaction atomicTransaction = new AtomicTransaction();
atomicTransaction.begin();
IntHolder value = new IntHolder();
counter.get(value);
atomicTransaction.commit(true);
if (value.value == (numberOfCalls / 2)) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Client02.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Client02.main: " + exception);
exception.printStackTrace(System.err);
}
}
use of org.omg.CORBA.IntHolder in project narayana by jbosstm.
the class Client14 method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
String counterIOR = ServerIORStore.loadIOR(args[args.length - 3]);
Counter counter = CounterHelper.narrow(ORBInterface.orb().string_to_object(counterIOR));
int numberOfWorkers = Integer.parseInt(args[args.length - 2]);
int numberOfCalls = Integer.parseInt(args[args.length - 1]);
Worker[] workers = new Worker[numberOfWorkers];
for (int index = 0; index < workers.length; index++) {
workers[index] = new Worker(numberOfCalls, counter);
}
for (int index = 0; index < workers.length; index++) {
workers[index].start();
}
boolean correct = true;
for (int index = 0; index < workers.length; index++) {
workers[index].join();
correct = correct && workers[index].isCorrect();
}
IntHolder value = new IntHolder();
counter.get(value);
correct = correct && (value.value == (numberOfWorkers * numberOfCalls));
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Client14.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Client14.main: " + exception);
exception.printStackTrace(System.err);
}
}
use of org.omg.CORBA.IntHolder in project narayana by jbosstm.
the class Client01 method operation.
private static boolean operation() throws Exception {
boolean successful = false;
try {
AtomicTransaction atomicTransaction = new AtomicTransaction();
try {
atomicTransaction.begin();
try {
int x0 = Math.abs(_random.nextInt() % _matrixWidth);
int y0 = Math.abs(_random.nextInt() % _matrixHeight);
int x1 = Math.abs(_random.nextInt() % _matrixWidth);
int y1 = Math.abs(_random.nextInt() % _matrixHeight);
IntHolder srcValue = new IntHolder();
IntHolder dstValue = new IntHolder();
_matrix.get_value(x0, y0, srcValue);
if (srcValue.value == 1) {
_matrix.get_value(x1, y1, dstValue);
if (dstValue.value == 0) {
_matrix.set_value(x0, y0, 0);
_matrix.set_value(x1, y1, 1);
successful = true;
}
}
} catch (InvocationException invocationException) {
if (invocationException.myreason != Reason.ReasonConcurrencyControl) {
throw invocationException;
}
}
if (successful) {
atomicTransaction.commit(true);
} else {
atomicTransaction.rollback();
}
} catch (Exception exception) {
if (atomicTransaction.get_status() == Status.StatusActive) {
atomicTransaction.rollback();
}
throw exception;
}
} catch (Exception exception) {
System.err.println("Client01.operation: " + exception);
exception.printStackTrace(System.err);
throw exception;
}
return successful;
}
use of org.omg.CORBA.IntHolder in project narayana by jbosstm.
the class Client02a method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
String serviceIOR = ServerIORStore.loadIOR(args[args.length - 1]);
Service service = ServiceHelper.narrow(ORBInterface.orb().string_to_object(serviceIOR));
CrashRecoveryDelays.awaitRecoveryCR10();
boolean correct = true;
OTS.current().begin();
IntHolder valueHolder = new IntHolder();
service.get(OTS.current().get_control(), valueHolder);
correct = correct && (valueHolder.value == 0);
OTS.current().commit(true);
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Client02a.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Client02a.main: " + exception);
exception.printStackTrace(System.err);
}
}
Aggregations