use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class ServerTopLevelOSIActionUnitTest method testCommit.
@Test
public void testCommit() throws Exception {
ControlImple cont = new ControlImple(null, null);
Control theControl = cont.getControl();
ArjunaTransactionImple tx = cont.getImplHandle();
ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
ServerOSITopLevelAction act = new ServerOSITopLevelAction(sc, true);
assertEquals(act.prepare(), Vote.VoteReadOnly);
try {
act.commit();
fail();
} catch (final INVALID_TRANSACTION ex) {
}
assertTrue(act.getReference() != null);
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class ServerTopLevelOSIActionUnitTest method testCommitOnePhase.
@Test
public void testCommitOnePhase() throws Exception {
ControlImple cont = new ControlImple(null, null);
Control theControl = cont.getControl();
ArjunaTransactionImple tx = cont.getImplHandle();
ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
ServerOSITopLevelAction act = new ServerOSITopLevelAction(sc, true);
act.commit_one_phase();
assertTrue(act.type() != null);
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class ServerTopLevelOSIActionUnitTest method testRollback.
@Test
public void testRollback() throws Exception {
ControlImple cont = new ControlImple(null, null);
Control theControl = cont.getControl();
ArjunaTransactionImple tx = cont.getImplHandle();
ServerControl sc = new ServerControl(tx.get_uid(), theControl, tx, theControl.get_coordinator(), theControl.get_terminator());
ServerOSITopLevelAction act = new ServerOSITopLevelAction(sc, true);
assertEquals(act.prepare(), Vote.VoteReadOnly);
try {
act.rollback();
fail();
} catch (final INVALID_TRANSACTION ex) {
}
act.forget();
}
use of org.omg.CosTransactions.Control in project narayana by jbosstm.
the class DistributedHammerWorker1 method get21.
public static void get21(char 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);
if (res) {
res2 = hammerObject_1.get(value2, control);
res = res2;
Util.indent(thr, level);
System.out.println("part2 get21 : " + res2);
}
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("DistributedHammerWorker1.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.CosTransactions.Control in project narayana by jbosstm.
the class DistributedHammerWorker3 method get12.
public static void get12(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 get12");
res1 = hammerObject_1.get(value1, control);
res = res1;
Util.indent(thr, level);
System.out.println("part1 get12 : " + res1);
Util.lowProbYield();
if (res) {
res2 = hammerObject_2.get(value2, control);
res = res2;
Util.indent(thr, level);
System.out.println("part2 get12 : " + 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.get12: " + e);
res1 = res2 = res = false;
}
Util.indent(thr, level);
System.out.println(" get12 : " + res1 + " : " + res2 + " : " + res + " : " + value1.value + " : " + value2.value);
}
Aggregations