use of com.arjuna.ats.jts.extensions.AtomicTransaction in project narayana by jbosstm.
the class Client_ExplicitObject_TranRollback_TranCommitWriteLock method main.
public static void main(String[] args) {
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
String prefix = args[args.length - 3];
int numberOfCalls = Integer.parseInt(args[args.length - 2]);
String explicitObjectIOR = ServerIORStore.loadIOR(args[args.length - 1]);
ExplicitObject explicitObject = ExplicitObjectHelper.narrow(ORBInterface.orb().string_to_object(explicitObjectIOR));
boolean correct = true;
Date start = new Date();
for (int index = 0; index < numberOfCalls; index++) {
AtomicTransaction atomicTransaction = new AtomicTransaction();
atomicTransaction.begin();
explicitObject.tran_commit_writelock(OTS.current().get_control());
atomicTransaction.rollback();
}
Date end = new Date();
float operationDuration = ((float) (end.getTime() - start.getTime())) / ((float) numberOfCalls);
System.err.println("Operation duration : " + operationDuration + "ms");
System.err.println("Test duration : " + (end.getTime() - start.getTime()) + "ms");
correct = PerformanceProfileStore.checkPerformance(prefix + "_ExplicitObject_TranRollback_TranCommitWriteLock", operationDuration);
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
} catch (Exception exception) {
System.out.println("Failed");
System.err.println("Client_ExplicitObject_TranRollback_TranCommitWriteLock.main: " + exception);
exception.printStackTrace(System.err);
}
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
System.err.println("Client_ExplicitObject_TranRollback_TranCommitWriteLock.main: " + exception);
exception.printStackTrace(System.err);
}
}
use of com.arjuna.ats.jts.extensions.AtomicTransaction in project narayana by jbosstm.
the class AtomicTransactionUnitTest method testCommit.
@Test
public void testCommit() throws Exception {
AtomicTransaction A = new AtomicTransaction();
A.begin();
assertTrue(A.get_txcontext() != null);
A.registerResource(new DemoResource().getResource());
AtomicTransaction B = new AtomicTransaction();
B.begin();
B.registerSubtranAware(new DemoSubTranResource().getReference());
B.commit(true);
A.commit(true);
A = new AtomicTransaction();
A.begin();
A.rollbackOnly();
try {
A.commit(true);
fail();
} catch (final TRANSACTION_ROLLEDBACK ex) {
}
}
use of com.arjuna.ats.jts.extensions.AtomicTransaction in project narayana by jbosstm.
the class AtomicTransactionUnitTest method testSuspendResume.
@Test
public void testSuspendResume() throws Exception {
AtomicTransaction A = new AtomicTransaction();
A.begin();
assertTrue(A.control() != null);
A.suspend();
assertEquals(OTSImpleManager.current().get_control(), null);
A.resume();
assertTrue(OTSImpleManager.current() != null);
A.rollback();
}
use of com.arjuna.ats.jts.extensions.AtomicTransaction in project narayana by jbosstm.
the class AtomicTransactionUnitTest method testRollback.
@Test
public void testRollback() throws Exception {
AtomicTransaction A = new AtomicTransaction();
A.begin();
A.registerSynchronization(new demosync(false).getReference());
A.rollback();
}
use of com.arjuna.ats.jts.extensions.AtomicTransaction in project narayana by jbosstm.
the class Client19 method main.
public static void main(String[] args) {
boolean correct = true;
int numberOfCalls = 10;
Counter counter = null;
System.err.println("Starting first init");
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
} catch (Exception exception) {
correct = false;
System.err.println("exception in first start: " + exception);
exception.printStackTrace(System.err);
}
System.err.println("Starting first block");
try {
String counterIOR = ServerIORStore.loadIOR(args[args.length - 1]);
counter = CounterHelper.narrow(ORBInterface.orb().string_to_object(counterIOR));
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) && correct) {
correct = true;
} else {
correct = false;
}
} catch (Exception exception) {
correct = false;
System.err.println("exception in first block" + exception);
exception.printStackTrace(System.err);
}
System.err.println("Starting first shutdown");
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
correct = false;
System.err.println("exception in first shutdown" + exception);
exception.printStackTrace(System.err);
}
System.err.println("----Starting second block -------");
try {
ORBInterface.initORB(args, null);
OAInterface.initOA();
} catch (Exception exception) {
correct = false;
System.err.println("exception in second start " + exception);
exception.printStackTrace(System.err);
}
System.err.println("init done starting second block");
try {
String counterIOR = ServerIORStore.loadIOR(args[args.length - 1]);
counter = CounterHelper.narrow(ORBInterface.orb().string_to_object(counterIOR));
AtomicTransaction atomicTransaction = new AtomicTransaction();
atomicTransaction.begin();
counter.set(0);
atomicTransaction.commit(true);
} catch (Exception exception) {
correct = false;
System.err.println("exception in set operation " + exception);
exception.printStackTrace(System.err);
}
try {
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();
}
}
} catch (Exception exception) {
correct = false;
System.err.println("exception in second loop block " + exception);
exception.printStackTrace(System.err);
}
try {
AtomicTransaction atomicTransaction = new AtomicTransaction();
atomicTransaction.begin();
IntHolder value = new IntHolder();
counter.get(value);
atomicTransaction.commit(true);
if (value.value == (numberOfCalls / 2) && correct) {
correct = true;
} else {
correct = false;
}
} catch (Exception exception) {
correct = false;
System.err.println("exception in second test " + exception);
exception.printStackTrace(System.err);
}
System.err.println("Starting second shutdown");
try {
OAInterface.shutdownOA();
ORBInterface.shutdownORB();
} catch (Exception exception) {
correct = false;
System.err.println("error in second shutdown" + exception);
exception.printStackTrace(System.err);
}
System.err.println("testing result");
if (correct) {
System.out.println("Passed");
} else {
System.out.println("Failed");
}
}
Aggregations