use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class StackServer 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];
stackPOATie theStack = new stackPOATie(new StackImple());
myOA.objectIsReady(theStack);
Services serv = new Services(myORB);
try {
TestUtility.registerService(refFile, myORB.orb().object_to_string(stackHelper.narrow(myOA.corbaReference(theStack))));
System.out.println("Ready");
myOA.run();
} catch (Exception e) {
TestUtility.fail("StackServer caught exception: " + e);
}
myOA.shutdownObject(theStack);
System.out.println("**StackServer exiting**");
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class TimeoutClient method main.
public static void main(String[] args) throws Exception {
ORB myORB = null;
RootOA myOA = null;
try {
ServerORB orb = new ServerORB();
myORB = orb.getORB();
myOA = orb.getOA();
CurrentImple current = OTSImpleManager.current();
Control theControl = null;
String objectReference = args[0];
SetGet SetGetVar = null;
System.out.println("Setting transaction timeout to " + timeout * mfactor + " seconds.");
current.set_timeout(timeout * mfactor);
current.begin();
current.begin();
long startTime = System.currentTimeMillis();
try {
Services serv = new Services(myORB);
SetGetVar = SetGetHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(objectReference)));
} catch (Exception e) {
TestUtility.fail("Bind to object failed: " + e);
e.printStackTrace(System.err);
}
try {
theControl = current.get_control();
SetGetVar.set((short) 2, theControl);
theControl = null;
System.out.println("Set value.");
} catch (Exception e) {
TestUtility.fail("Call to set or get failed: " + e);
e.printStackTrace(System.err);
}
try {
long timeNow = System.currentTimeMillis();
long setTime = (timeNow - startTime);
long timeoutTime = (timeout * 1000 * mfactor);
long sleepTime = timeoutTime - setTime;
if (sleepTime > 0) {
System.out.println("Now sleeping for " + sleepTime * mfactor + " milliseconds.");
Thread.sleep(sleepTime * mfactor);
}
} catch (Exception e) {
}
System.out.println("\ncommitting nested action.");
try {
current.commit(true);
TestUtility.fail("commit worked");
} catch (TRANSACTION_ROLLEDBACK e1) {
System.out.println("Caught TransactionRolledBack");
} catch (INVALID_TRANSACTION e1) /* For JacORB */
{
System.out.println("Caught InvalidTransaction");
}
System.out.println("\ncommitting top-level action");
try {
current.commit(true);
TestUtility.fail("commit worked");
} catch (TRANSACTION_ROLLEDBACK e2) {
System.out.println("Caught TransactionRolledBack");
} catch (INVALID_TRANSACTION e3) {
System.out.println("Caught InvalidTransaction");
} catch (Exception e) {
TestUtility.fail("Caught other exception: " + e);
}
} catch (Exception e) {
e.printStackTrace(System.err);
TestUtility.fail(e.toString());
}
myOA.destroy();
myORB.shutdown();
System.out.println("Passed");
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class TMTest method test.
@Test
public void test() throws Exception {
ServerORB orb = new ServerORB();
ORB myORB = orb.getORB();
RootOA myOA = orb.getOA();
TransactionFactory theOTS = null;
Control topLevelControl = null;
Services serv = new Services(myORB);
int resolver = Services.getResolver();
try {
String[] params = new String[1];
params[0] = Services.otsKind;
org.omg.CORBA.Object obj = serv.getService(Services.transactionService, params, resolver);
params = null;
theOTS = TransactionFactoryHelper.narrow(obj);
} catch (Exception e) {
fail("Unexpected bind exception: " + e);
e.printStackTrace(System.err);
}
System.out.println("Creating transaction.");
try {
topLevelControl = theOTS.create(0);
} catch (Exception e) {
fail("Create call failed: " + e);
e.printStackTrace(System.err);
}
myOA.destroy();
myORB.shutdown();
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class TranGridServer method test.
@Test
public void test() throws Exception {
ServerORB orb = new ServerORB();
ORB myORB = orb.getORB();
RootOA myOA = orb.getOA();
String serverName = "TranGrid";
String refFile = "/tmp/trangrid.ref";
if (System.getProperty("os.name").startsWith("Windows")) {
refFile = "C:\\temp\\trangrid.ref";
}
trangrid_i gridI = new trangrid_i((short) 100, (short) 100);
Services serv = new Services(myORB);
try {
TestUtility.registerService(refFile, myORB.orb().object_to_string(gridI.getReference()));
System.out.println("**TranGrid server started**");
// assertReady();
myOA.run();
} catch (Exception e) {
fail("TranGrid server caught exception: " + e);
}
myOA.shutdownObject(gridI);
System.out.println("**TranGrid server exiting**");
}
use of com.arjuna.orbportability.ORB in project narayana by jbosstm.
the class TMClient 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 topLevelControl = null;
Control nestedControl = null;
String server = "/tmp/hammer1.ref";
boolean slave = false;
if (System.getProperty("os.name").startsWith("Windows")) {
server = "C:\\temp\\hammer1.ref";
}
Services serv = new Services(myORB);
int resolver = Services.getResolver();
try {
String[] params = new String[1];
params[0] = Services.otsKind;
org.omg.CORBA.Object obj = serv.getService(Services.transactionService, params, resolver);
params = null;
theOTS = TransactionFactoryHelper.narrow(obj);
} catch (Exception e) {
fail("Unexpected bind exception: " + e);
e.printStackTrace(System.err);
}
System.out.println("Creating transaction.");
try {
topLevelControl = theOTS.create(0);
} catch (Exception e) {
fail("Create call failed: " + e);
e.printStackTrace(System.err);
}
System.out.println("Creating subtransaction.");
try {
nestedControl = topLevelControl.get_coordinator().create_subtransaction();
} catch (Exception e) {
System.err.println("Subtransaction create call failed: " + e);
try {
topLevelControl.get_terminator().rollback();
} catch (Exception ex) {
}
e.printStackTrace(System.err);
fail();
}
try {
DistributedHammerWorker1.hammerObject_1 = HammerHelper.narrow(serv.getService(server, null, Services.FILE));
if (!DistributedHammerWorker1.hammerObject_1.incr(1, nestedControl))
System.out.println("Could not increment!");
else
System.out.println("incremented.");
System.out.println("sleeping.");
Thread.sleep(20000);
nestedControl.get_terminator().rollback();
if (!slave) {
System.out.println("master sleeping again.");
Thread.sleep(20000);
}
IntHolder value = new IntHolder(0);
org.omg.CosTransactions.PropagationContext ctx = topLevelControl.get_coordinator().get_txcontext();
assertTrue(DistributedHammerWorker1.hammerObject_1.get(value, topLevelControl));
topLevelControl.get_terminator().rollback();
} catch (Exception e) {
fail("TMClient: " + e);
e.printStackTrace(System.err);
}
myOA.destroy();
myORB.shutdown();
}
Aggregations