use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.
the class ExplicitStackServer method main.
public static void main(String[] args) throws Exception {
ServerORB orb = new ServerORB();
ORB myORB = orb.getORB();
RootOA myOA = orb.getOA();
String refFile = args[0];
ExplicitStackPOATie theObject = new ExplicitStackPOATie(new ExplicitStackImple());
myOA.objectIsReady(theObject);
Services serv = new Services(myORB);
try {
TestUtility.registerService(refFile, myORB.orb().object_to_string(myOA.corbaReference(theObject)));
System.out.println("Ready");
myOA.run();
} catch (Exception e) {
e.printStackTrace();
}
myOA.shutdownObject(theObject);
System.out.println("**ExplicitStackServer exiting**");
}
use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.
the class HammerServer method main.
public static void main(String[] args) throws Exception {
ServerORB orb = new ServerORB();
ORB myORB = orb.getORB();
RootOA myOA = orb.getOA();
String refFile = args[0];
HammerPOATie theObject = new HammerPOATie(new HammerObject());
myOA.objectIsReady(theObject);
Services serv = new Services(myORB);
try {
TestUtility.registerService(refFile, myORB.orb().object_to_string(HammerHelper.narrow(myOA.corbaReference(theObject))));
System.out.println("\nIOR file: " + refFile);
System.out.println("Ready");
// assertReady();
myOA.run();
} catch (Exception e) {
// fail("HammerServer caught exception: "+e);
e.printStackTrace(System.err);
}
myOA.shutdownObject(theObject);
System.out.println("**HammerServer exiting**");
}
use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.
the class SuspendResume method test.
@Test
public void test() throws Exception {
ORB myORB = null;
RootOA myOA = null;
myORB = ORB.getInstance("test");
myOA = OA.getRootOA(myORB);
myORB.initORB(new String[] {}, null);
myOA.initOA();
ORBManager.setORB(myORB);
ORBManager.setPOA(myOA);
CurrentImple current = OTSImpleManager.current();
Control myControl = null;
System.out.println("Beginning transaction.");
try {
current.begin();
myControl = current.get_control();
assertNotNull(myControl);
} catch (Exception sysEx) {
sysEx.printStackTrace(System.err);
fail();
}
System.out.println("Committing transaction.");
try {
current.commit(true);
current.resume(myControl);
} catch (Exception e) {
fail("commit error: " + e);
e.printStackTrace(System.err);
}
myOA.destroy();
myORB.shutdown();
System.out.println("Test completed successfully.");
}
use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.
the class GridClient method test.
@Test
public void test() throws Exception {
ORB myORB = null;
RootOA myOA = null;
myORB = ORB.getInstance("test");
myOA = OA.getRootOA(myORB);
myORB.initORB(new String[] {}, null);
myOA.initOA();
ORBManager.setORB(myORB);
ORBManager.setPOA(myOA);
TransactionFactory theOTS = null;
Control myControl = null;
grid gridVar = null;
int h = -1, w = -1, v = -1;
String gridReference = "/tmp/grid.ref";
String serverName = "Grid";
if (System.getProperty("os.name").startsWith("Windows")) {
gridReference = "C:\\temp\\grid.ref";
}
Services serv = new Services(myORB);
try {
String[] params = new String[1];
params[0] = Services.otsKind;
org.omg.CORBA.Object obj = serv.getService(Services.transactionService, params);
params = null;
theOTS = TransactionFactoryHelper.narrow(obj);
} catch (Exception e) {
fail("Unexpected bind exception: " + e);
}
System.out.println("Creating transaction.");
try {
myControl = theOTS.create(0);
} catch (Exception e) {
fail("Create call failed: " + e);
e.printStackTrace();
}
try {
gridVar = gridHelper.narrow(serv.getService(gridReference, null, Services.FILE));
} catch (Exception e) {
fail("Grid bind failed: " + e);
}
try {
h = gridVar.height();
w = gridVar.width();
} catch (Exception e) {
fail("Grid invocation failed: " + e);
}
System.out.println("height is " + h);
System.out.println("width is " + w);
try {
System.out.println("calling set");
gridVar.set(2, 4, 123, myControl);
System.out.println("calling get");
v = gridVar.get(2, 4, myControl);
} catch (Exception sysEx) {
fail("Grid set/get failed: " + sysEx);
}
// no problem setting and getting the elememt:
System.out.println("grid[2,4] is " + v);
// sanity check: make sure we got the value 123 back:
if (v != 123) {
// oops - we didn't:
fail("something went seriously wrong");
try {
myControl.get_terminator().rollback();
} catch (Exception e) {
}
} else {
System.out.println("Committing transaction.");
try {
Terminator handle = myControl.get_terminator();
handle.commit(true);
} catch (Exception sysEx) {
fail("Transaction commit error: " + sysEx);
}
}
try {
OTSManager.destroyControl(myControl);
} catch (Exception e) {
fail("Caught destroy exception: " + e);
}
myOA.destroy();
myORB.shutdown();
System.out.println("Test completed successfully.");
}
use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.
the class DistributedHammer2 method main.
public static void main(String[] args) throws Exception {
ServerORB orb = new ServerORB();
ORB myORB = orb.getORB();
RootOA myOA = orb.getOA();
String server1 = args[0];
String server2 = args[1];
try {
Services serv = new Services(myORB);
DistributedHammerWorker2.hammerObject_1 = HammerHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(server1)));
DistributedHammerWorker2.hammerObject_2 = HammerHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(server2)));
TestUtility.assertTrue(DistributedHammerWorker2.hammerObject_1.set(START_VALUE_1, null));
TestUtility.assertTrue(DistributedHammerWorker2.hammerObject_2.set(START_VALUE_2, null));
DistributedHammerWorker2.get12('m', 0);
DistributedHammerWorker2.get21('m', 0);
} catch (Exception e) {
TestUtility.fail("DistributedHammer2: " + e);
e.printStackTrace(System.err);
}
TaskProgress progress1 = TaskMonitor.INSTANCE.monitorProgress("DistributedHammer2", "DistributedHammer2", 60000L);
TaskProgress progress2 = TaskMonitor.INSTANCE.monitorProgress("DistributedHammer2", "DistributedHammer2", 60000L);
DHThreadObject2 thr1 = new DHThreadObject2(progress1, '1');
DHThreadObject2 thr2 = new DHThreadObject2(progress2, '2');
thr1.start();
thr2.start();
try {
thr1.join();
thr2.join();
} catch (InterruptedException e) {
TestUtility.fail("DistributedHammer2: " + e);
e.printStackTrace(System.err);
}
DistributedHammerWorker2.get12('m', 0);
DistributedHammerWorker2.get21('m', 0);
IntHolder value1 = new IntHolder(0);
IntHolder value2 = new IntHolder(0);
boolean assert1 = DistributedHammerWorker2.get1(value1) | DistributedHammerWorker2.get2(value2);
boolean assert2 = EXPECTED_RESULT == (value1.value + value2.value);
TestUtility.assertTrue(DistributedHammerWorker2.get1(value1) | DistributedHammerWorker2.get2(value2));
TestUtility.assertEquals(EXPECTED_RESULT, (value1.value + value2.value));
myOA.destroy();
myORB.shutdown();
int res = assert1 && assert2 && progress1.isFinished() && progress2.isFinished() ? 0 : 1;
System.out.printf("%s%n", (res == 0 ? "Passed" : "Failed"));
System.exit(res);
}
Aggregations