Search in sources :

Example 51 with RootOA

use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.

the class ImplicitClient 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];
    CurrentImple current = OTSImpleManager.current();
    // pointer the grid object that will be used.
    TranGrid TranGridVar = null;
    short h = 0, w = 0, v = 0;
    try {
        current.begin();
        Services serv = new Services(myORB);
        TranGridVar = TranGridHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(refFile)));
        try {
            h = TranGridVar.height();
            w = TranGridVar.width();
        } catch (Exception e) {
            TestUtility.fail("Invocation failed: " + e);
        }
        System.out.println("height is " + h);
        System.out.println("width  is " + w);
        try {
            System.out.println("calling set");
            TranGridVar.set((short) 2, (short) 4, (short) 123);
            System.out.println("calling get");
            v = TranGridVar.get((short) 2, (short) 4);
        } catch (Exception sysEx) {
            TestUtility.fail("Grid set/get failed: " + sysEx);
            sysEx.printStackTrace(System.err);
        }
        // no problem setting and getting the element:
        System.out.println("trangrid[2,4] is " + v);
        if (v != 123) {
            // oops - we didn't:
            current.rollback();
            TestUtility.fail("Result not as expected");
        } else {
            current.commit(true);
        }
    } catch (Exception e) {
        TestUtility.fail("Caught exception: " + e);
        e.printStackTrace(System.err);
    }
    myOA.destroy();
    myORB.shutdown();
    System.out.println("Passed");
}
Also used : ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) RootOA(com.arjuna.orbportability.RootOA) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB) TranGrid(com.hp.mwtests.ts.jts.TestModule.TranGrid)

Example 52 with RootOA

use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.

the class SetGetServer 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];
    setget_i impl = new setget_i();
    Services serv = new Services(myORB);
    try {
        TestUtility.registerService(refFile, myORB.orb().object_to_string(impl.getReference()));
        System.out.println("Ready");
        myOA.run();
    } catch (Exception e) {
        TestUtility.fail("SetGetServer caught exception: " + e);
    }
    myOA.shutdownObject(impl);
    System.out.println("**Object server exiting**");
}
Also used : ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) com.hp.mwtests.ts.jts.orbspecific.resources.setget_i(com.hp.mwtests.ts.jts.orbspecific.resources.setget_i) RootOA(com.arjuna.orbportability.RootOA) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 53 with RootOA

use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.

the class ImplicitArjunaClient 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];
    CurrentImple current = OTSImpleManager.current();
    // pointer the grid object that will be used.
    stack stackVar = null;
    try {
        current.begin();
        try {
            Services serv = new Services(myORB);
            stackVar = stackHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(refFile)));
        } catch (Exception e) {
            e.printStackTrace(System.err);
            TestUtility.fail(e.toString());
        }
        System.out.println("pushing 1 onto stack");
        stackVar.push(1);
        System.out.println("pushing 2 onto stack");
        stackVar.push(2);
    } catch (Exception e) {
        e.printStackTrace(System.err);
        TestUtility.fail(e.toString());
    }
    try {
        current.commit(false);
        current.begin();
        IntHolder val = new IntHolder(-1);
        if (stackVar.pop(val) == 0) {
            System.out.println("popped top of stack " + val.value);
            current.begin();
            stackVar.push(3);
            System.out.println("pushed 3 onto stack. Aborting nested action.");
            current.rollback();
            stackVar.pop(val);
            System.out.println("popped top of stack is " + val.value);
            current.commit(false);
            TestUtility.assertEquals(1, val.value);
        } else {
            TestUtility.fail("Error getting stack value.");
            current.rollback();
        }
    } catch (Exception e) {
        e.printStackTrace(System.err);
        TestUtility.fail(e.toString());
    }
    myOA.destroy();
    myORB.shutdown();
    System.out.println("Passed");
}
Also used : ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) TestModule.stack(com.hp.mwtests.ts.jts.TestModule.stack) IntHolder(org.omg.CORBA.IntHolder) RootOA(com.arjuna.orbportability.RootOA) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 54 with RootOA

use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.

the class PerfHammer method main.

public static void main(String[] args) throws Exception {
    String gridReference = args[0];
    int numberOfCalls = 1000;
    int threadCount = 10;
    int batchSize = 100;
    int warmUpCount = 0;
    ServerORB orb = new ServerORB();
    ORB myORB = orb.getORB();
    RootOA myOA = orb.getOA();
    String metricName = "JTSRemote_PerfTest_PerfHammer_" + System.getProperty("org.omg.CORBA.ORBClass", myORB.orb().getClass().getName());
    GridWorker worker = new GridWorker(myORB, gridReference);
    Measurement measurement = new Measurement.Builder(metricName).maxTestTime(0L).numberOfCalls(numberOfCalls).numberOfThreads(threadCount).batchSize(batchSize).numberOfWarmupCalls(warmUpCount).build().measure(worker, worker);
    System.out.printf("%s: %d iterations using %d threads with a batch size of %d%n", metricName, numberOfCalls, threadCount, batchSize);
    System.out.printf("%s%n", measurement.getInfo());
    System.out.printf("%s%n%s%n", measurement.getInfo(), (measurement.shouldFail() || measurement.getNumberOfErrors() != 0 ? "Failed" : "Passed"));
}
Also used : Measurement(io.narayana.perf.Measurement) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) RootOA(com.arjuna.orbportability.RootOA) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 55 with RootOA

use of com.arjuna.orbportability.RootOA in project narayana by jbosstm.

the class RCTest method test.

@Test
public void test() {
    boolean shouldCommit = true;
    boolean passed = false;
    Coordinator coord = null;
    ORB myORB = null;
    RootOA myOA = null;
    try {
        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();
        AtomicResource aImpl = new AtomicResource(shouldCommit);
        Resource atomicObject = aImpl.getReference();
        System.out.println("beginning top-level transaction.");
        current.begin();
        Control myControl = current.get_control();
        assertNotNull(myControl);
        System.out.println("getting coordinator");
        coord = myControl.get_coordinator();
        myControl = null;
        System.out.println("registering resources.");
        RecoveryCoordinator rc = null;
        try {
            rc = coord.register_resource(atomicObject);
        } catch (Exception ex) {
            fail("Failed to register resources: " + ex);
            ex.printStackTrace();
        }
        if (rc == null)
            System.out.println("No recovery coordinator reference.");
        else {
            Status s = Status.StatusUnknown;
            try {
                System.out.println("Attempting to use recovery coordinator.");
                s = rc.replay_completion(atomicObject);
            } catch (NotPrepared e) {
                s = Status.StatusActive;
            } catch (Exception ex) {
                fail("Caught: " + ex);
                ex.printStackTrace();
            }
            System.out.println("Got: " + com.arjuna.ats.jts.utils.Utility.stringStatus(s));
            if (s == Status.StatusActive)
                passed = true;
        }
        System.out.println("committing top-level transaction.");
        if (shouldCommit)
            current.commit(true);
        else
            current.rollback();
        if (rc == null)
            System.out.println("No recovery coordinator reference.");
        else {
            Status s = Status.StatusUnknown;
            try {
                System.out.println("Attempting to use recovery coordinator.");
                s = rc.replay_completion(atomicObject);
            } catch (NotPrepared e) {
                s = Status.StatusActive;
            } catch (Exception ex) {
                fail("Caught: " + ex);
            }
            System.out.println("Got: " + com.arjuna.ats.jts.utils.Utility.stringStatus(s));
            if (passed && (s == Status.StatusRolledBack))
                passed = true;
            else
                passed = false;
        }
    } catch (TRANSACTION_ROLLEDBACK e1) {
        System.out.println("\nTransaction RolledBack exception");
    } catch (HeuristicMixed e2) {
        System.out.println("\nTransaction HeuristicMixed exception");
    } catch (HeuristicHazard e3) {
        System.out.println("\nTransaction HeuristicHazard exception");
    } catch (Exception e4) {
        System.out.println("Caught unexpected exception: " + e4);
    }
    System.out.println("Trying to determing final transaction outcome.");
    org.omg.CosTransactions.Status status = Status.StatusUnknown;
    try {
        if (coord != null) {
            status = coord.get_status();
            coord = null;
        } else
            System.out.println("\nCould not determine action status.");
    } catch (SystemException ex1) {
    // assume invalid reference - tx may have been garbage collected
    } catch (Exception e5) {
        System.out.println("Caught unexpected exception:" + e5);
    }
    System.out.println("\nFinal action status: " + com.arjuna.ats.jts.utils.Utility.stringStatus(status));
    assertTrue(passed);
    myOA.destroy();
    myORB.shutdown();
}
Also used : Status(org.omg.CosTransactions.Status) AtomicResource(com.hp.mwtests.ts.jts.orbspecific.resources.AtomicResource) Resource(org.omg.CosTransactions.Resource) RootOA(com.arjuna.orbportability.RootOA) AtomicResource(com.hp.mwtests.ts.jts.orbspecific.resources.AtomicResource) RecoveryCoordinator(org.omg.CosTransactions.RecoveryCoordinator) Coordinator(org.omg.CosTransactions.Coordinator) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) SystemException(org.omg.CORBA.SystemException) NotPrepared(org.omg.CosTransactions.NotPrepared) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard) Control(org.omg.CosTransactions.Control) SystemException(org.omg.CORBA.SystemException) Status(org.omg.CosTransactions.Status) RecoveryCoordinator(org.omg.CosTransactions.RecoveryCoordinator) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Aggregations

ORB (com.arjuna.orbportability.ORB)70 RootOA (com.arjuna.orbportability.RootOA)70 Test (org.junit.Test)49 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)20 Services (com.arjuna.orbportability.Services)18 Control (org.omg.CosTransactions.Control)18 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)9 SystemException (org.omg.CORBA.SystemException)7 IntHolder (org.omg.CORBA.IntHolder)6 UserException (org.omg.CORBA.UserException)5 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)4 Terminator (org.omg.CosTransactions.Terminator)4 AtomicObject (com.hp.mwtests.ts.jts.orbspecific.resources.AtomicObject)3 Coordinator (org.omg.CosTransactions.Coordinator)3 Status (org.omg.CosTransactions.Status)3 TransactionFactory (org.omg.CosTransactions.TransactionFactory)3 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)2 TestResource (com.hp.mwtests.ts.jta.jts.common.TestResource)2 XACreator (com.hp.mwtests.ts.jta.jts.common.XACreator)2 SetGet (com.hp.mwtests.ts.jts.TestModule.SetGet)2