use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class PropertyInitTest3 method test.
@Test
public void test() {
Properties testProps = new Properties();
testProps.setProperty(PreInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb"), "com.hp.mwtests.orbportability.initialisation.preinit.AllPreInitialisation");
testProps.setProperty(PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb"), "com.hp.mwtests.orbportability.initialisation.postinit.AllPostInitialisation");
testProps.setProperty(PreInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME), "com.hp.mwtests.orbportability.initialisation.preinit.PreInitialisation");
testProps.setProperty(PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME), "com.hp.mwtests.orbportability.initialisation.postinit.PostInitialisation");
testProps.setProperty(PreInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME_2), "com.hp.mwtests.orbportability.initialisation.preinit.PreInitialisation2");
testProps.setProperty(PostInitLoader.generateORBPropertyName("com.arjuna.orbportability.orb", ORB_INSTANCE_NAME_2), "com.hp.mwtests.orbportability.initialisation.postinit.PostInitialisation2");
ORB orb = ORB.getInstance(ORB_INSTANCE_NAME);
System.out.println("Initialising First ORB Instance");
orb.initORB(new String[] {}, testProps);
assertTrue(PreInitialisation._called);
assertTrue(PostInitialisation._called);
assertTrue(PreInitialisation2._called);
assertTrue(PostInitialisation2._called);
assertTrue(AllPreInitialisation._called);
assertTrue(AllPostInitialisation._called);
try {
/**
* Reset called flags on All ORB instance pre-initialisation
*/
AllPreInitialisation._called = false;
AllPostInitialisation._called = false;
orb = ORB.getInstance(ORB_INSTANCE_NAME_2);
System.out.println("Initialising Second ORB Instance");
orb.initORB(new String[] {}, testProps);
} catch (Exception e) {
fail("ERROR - " + e);
}
assertTrue(PreInitialisation2._called);
assertTrue(PostInitialisation2._called);
assertTrue(AllPreInitialisation._called);
assertTrue(AllPostInitialisation._called);
try {
orb.destroy();
} catch (Exception e) {
fail("ERROR - " + e);
}
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class Client01 method main.
public static void main(String[] args) {
int crashIn = Resource01.NOCRASH;
;
if (args.length >= 1) {
if (args[0].startsWith("p") || args[0].startsWith("P")) {
crashIn = Resource01.PREPARE;
}
if (args[0].startsWith("c") || args[0].startsWith("C")) {
crashIn = Resource01.COMMIT;
}
if (args[0].startsWith("r") || args[0].startsWith("R")) {
crashIn = Resource01.ROLLBACK;
}
}
if (args.length >= 2) {
resultsFile = args[1];
}
try {
ORB myORB = ORB.getInstance("Client01");
RootOA myOA = OA.getRootOA(myORB);
myORB.initORB(args, null);
myOA.initOA();
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Failed");
}
System.out.println("Ready");
try {
UserTransaction ut = com.arjuna.ats.jta.UserTransaction.userTransaction();
ut.begin();
TransactionImple txImple = (TransactionImple) TransactionManager.transactionManager().getTransaction();
txImple.enlistResource(new Resource01(crashIn, resultsFile));
txImple.enlistResource(new Resource02());
ut.commit();
System.out.println("Passed");
} catch (javax.transaction.RollbackException rbx) {
System.out.println("Passed");
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Failed");
}
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class PerformanceTestWrapper method main.
/**
* The main test method which must assert either a pass or a fail.
*/
public static void main(String[] args) {
String classname = null;
int minNumberOfThreads = DEFAULT_NUMBER_OF_THREADS;
int maxNumberOfThreads = DEFAULT_NUMBER_OF_THREADS;
int numberOfIterations = DEFAULT_NUMBER_OF_ITERATIONS;
boolean displayGraph = false;
int xData = -1;
int yData = -1;
String csvFilename = null;
ArrayList configList = new ArrayList();
boolean disableOrb = false;
try {
if (args.length > 0) {
for (int count = 0; count < args.length; count++) {
if (args[count].equals(CLASSNAME_PARAMETER)) {
classname = args[count + 1];
}
if (args[count].equals(CSV_FILENAME_PARAMETER)) {
csvFilename = args[count + 1];
}
if (args[count].equals(DISPLAY_GRAPH_PARAMETER)) {
displayGraph = true;
}
if (args[count].equals(NUMBER_OF_THREADS_PARAMETER)) {
maxNumberOfThreads = minNumberOfThreads = Integer.parseInt(args[count + 1]);
}
if (args[count].equals(NUMBER_OF_THREADS_MIN_PARAMETER)) {
minNumberOfThreads = Integer.parseInt(args[count + 1]);
}
if (args[count].equals(NUMBER_OF_THREADS_MAX_PARAMETER)) {
maxNumberOfThreads = Integer.parseInt(args[count + 1]);
}
if (args[count].equals(NUMBER_OF_ITERATIONS_PARAMETER)) {
numberOfIterations = Integer.parseInt(args[count + 1]);
}
if (args[count].equals(DISABLE_ORB_PARAMETER)) {
disableOrb = true;
}
if (args[count].equals(XDATA_PARAMETER)) {
xData = PerformanceFramework.parseDataType(args[count + 1]);
if (xData == -1) {
System.err.println("Error - specified x-data parameter is invalid");
assertFailure();
} else {
System.out.println("X-Data set to '" + args[count + 1] + "'");
}
}
if (args[count].equals(YDATA_PARAMETER)) {
yData = PerformanceFramework.parseDataType(args[count + 1]);
if (yData == -1) {
System.err.println("Error - specified y-data parameter is invalid");
assertFailure();
} else {
System.out.println("Y-Data set to '" + args[count + 1] + "'");
}
}
if (args[count].equals(ADD_SERVICE_NAME)) {
System.out.println("Added Service config: '" + args[count + 1] + "'");
configList.add(ServerIORStore.loadIOR(args[count + 1]));
}
}
if (classname != null) {
System.out.println(" Classname: " + classname);
System.out.println("Min Number of Threads: " + minNumberOfThreads);
System.out.println("Max Number of Threads: " + maxNumberOfThreads);
System.out.println(" Number of Iterations: " + numberOfIterations);
if (!disableOrb) {
try {
/**
* Retrieve ORB and OA references, intialise them
* and then set the OTSManager ORB and OA properties
*/
ORB orb = ORB.getInstance(PerformanceFramework.ORB_INSTANCE_NAME);
OA oa = OA.getRootOA(orb);
orb.initORB(args, null);
oa.initOA(args);
} catch (Exception e) {
e.printStackTrace(System.err);
assertFailure();
}
}
PerformanceFramework pf = new PerformanceFramework(args);
pf.setDisplayGraph(displayGraph);
pf.setCSVFilename(csvFilename);
if (xData != -1) {
pf.setXData(xData);
}
if (yData != -1) {
pf.setYData(yData);
}
pf.setNumberOfIterations(numberOfIterations);
pf.setMinimumNumberOfThreads(minNumberOfThreads);
pf.setMaximumNumberOfThreads(maxNumberOfThreads);
String[] configs = new String[configList.size()];
configList.toArray(configs);
if (!pf.performTest(classname, configs)) {
// assertSuccess();
} else {
assertFailure();
}
} else {
System.out.println("Parameter '" + CLASSNAME_PARAMETER + "' not specified");
assertFailure();
}
} else {
System.out.println("No parameters passed");
assertFailure();
}
} catch (Exception e) {
e.printStackTrace(System.err);
assertFailure();
}
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class SingleSubtranAwareResourceRegistration method work.
public void work() throws PerfTestException {
try {
/**
* Retrieve ORB and OA references
*/
ORB orb = ORB.getInstance(PerformanceFramework.ORB_INSTANCE_NAME);
OA oa = OA.getRootOA(orb);
Control control = OTSManager.get_current().get_control();
Coordinator coordinator = control.get_coordinator();
DemoSubTranResource resource = new DemoSubTranResource();
oa.objectIsReady(resource);
SubtransactionAwareResource res = SubtransactionAwareResourceHelper.narrow(oa.corbaReference(resource));
coordinator.register_resource(res);
} catch (Exception e) {
throw new PerfTestException();
}
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class NestedOnePhaseTrx method work.
protected void work() throws Exception {
ORB orb = ORB.getInstance(PerformanceFramework.ORB_INSTANCE_NAME);
OA oa = OA.getRootOA(orb);
String ref1 = getServiceConfig(0);
String ref2 = getServiceConfig(1);
org.omg.CORBA.Object obj1 = orb.orb().string_to_object(ref1);
PerfTestInterface d1 = (PerfTestInterface) PerfTestInterfaceHelper.narrow(obj1);
OTSManager.get_current().begin();
d1.work();
org.omg.CORBA.Object obj2 = orb.orb().string_to_object(ref2);
PerfTestInterface d2 = (PerfTestInterface) PerfTestInterfaceHelper.narrow(obj2);
OTSManager.get_current().begin();
d2.work();
// nested commit
OTSManager.get_current().commit(true);
if (true) {
// top level commit
OTSManager.get_current().commit(true);
} else {
// top level rollback
OTSManager.get_current().rollback();
}
}
Aggregations