use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class DistributedHammerWorker1 method incr21.
public static void incr21(char thr, int level) {
boolean res = false;
boolean res1 = false;
boolean res2 = false;
int ran = 0;
try {
OTSImpleManager.current().begin();
Control control = OTSImpleManager.current().get_control();
Util.indent(thr, level);
System.out.println("begin incr21");
ran = Util.rand.nextInt() % 16;
res1 = hammerObject_2.incr(ran, control);
res = res1;
Util.indent(thr, level);
System.out.println("part1 incr21 : " + res1);
if (res) {
res2 = hammerObject_1.incr(-ran, control);
res = res2;
Util.indent(thr, level);
System.out.println("part2 incr21 : " + res2);
}
control = null;
Util.indent(thr, level);
if (res) {
System.out.print("end ");
OTSImpleManager.current().commit(true);
res = true;
} else {
System.out.print("abort ");
OTSImpleManager.current().rollback();
}
} catch (Exception e) {
System.err.println("DistributedHammerWorker1.incr21: " + e);
res1 = res2 = res = false;
}
Util.indent(thr, level);
System.out.println(" incr21 : " + res1 + " : " + res2 + " : " + res + " : " + ran);
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class DistributedHammerWorker1 method incr12.
public static void incr12(char thr, int level) {
boolean res = false;
boolean res1 = false;
boolean res2 = false;
int ran = 0;
try {
OTSImpleManager.current().begin();
Control control = OTSImpleManager.current().get_control();
Util.indent(thr, level);
System.out.println("begin incr12");
ran = Util.rand.nextInt() % 16;
res1 = hammerObject_1.incr(ran, control);
res = res1;
Util.indent(thr, level);
System.out.println("part1 incr12 : " + res1);
if (res) {
res2 = hammerObject_2.incr(-ran, control);
res = res2;
Util.indent(thr, level);
System.out.println("part2 incr12 : " + res2);
}
Util.indent(thr, level);
control = null;
if (res) {
System.out.print("end ");
OTSImpleManager.current().commit(true);
res = true;
} else {
System.out.print("abort ");
OTSImpleManager.current().rollback();
}
} catch (Exception e) {
System.err.println("DistributedHammerWorker1.incr12: " + e);
res1 = res2 = res = false;
}
Util.indent(thr, level);
System.out.println(" incr12 : " + res1 + " : " + res2 + " : " + res + " : " + ran);
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class DistributedHammerWorker3 method incr12.
public static void incr12(int thr, int level) {
boolean res = false;
boolean res1 = false;
boolean res2 = false;
int ran = 0;
try {
OTSImpleManager.current().begin();
Control control = OTSImpleManager.current().get_control();
Util.indent(thr, level);
System.out.println("begin incr12");
ran = Util.rand.nextInt() % 16;
res1 = hammerObject_1.incr(ran, control);
res = res1;
Util.indent(thr, level);
System.out.println("part1 incr12 : " + res1);
Util.lowProbYield();
if (res) {
res2 = hammerObject_2.incr(-ran, control);
res = res2;
Util.indent(thr, level);
System.out.println("part2 incr12 : " + 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.incr12: " + e);
res1 = res2 = res = false;
}
Util.indent(thr, level);
System.out.println(" incr12 : " + res1 + " : " + res2 + " : " + res + " : " + ran);
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class DistributedHammerWorker3 method get2.
public static boolean get2(IntHolder value) {
boolean res = false;
try {
OTSImpleManager.current().begin();
Control control = OTSImpleManager.current().get_control();
res = hammerObject_2.get(value, control);
control = null;
if (res) {
OTSImpleManager.current().commit(true);
} else {
OTSImpleManager.current().rollback();
}
} catch (Exception e) {
System.err.println("DistributedHammerWorker1.get2: " + e);
res = false;
}
return (res);
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class DistributedHammerWorker3 method incr21.
public static void incr21(int thr, int level) {
boolean res = false;
boolean res1 = false;
boolean res2 = false;
int ran = 0;
try {
OTSImpleManager.current().begin();
Control control = OTSImpleManager.current().get_control();
Util.indent(thr, level);
System.out.println("begin incr21");
ran = Util.rand.nextInt() % 16;
res1 = hammerObject_2.incr(ran, control);
res = res1;
Util.indent(thr, level);
System.out.println("part1 incr21 : " + res1);
Util.lowProbYield();
if (res) {
res2 = hammerObject_1.incr(-ran, control);
res = res2;
Util.indent(thr, level);
System.out.println("part2 incr21 : " + 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.incr21: " + e);
res1 = res2 = res = false;
}
Util.indent(thr, level);
System.out.println(" incr21 : " + res1 + " : " + res2 + " : " + res + " : " + ran);
}
Aggregations