Search in sources :

Example 86 with ORB

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);
    }
}
Also used : Properties(java.util.Properties) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 87 with ORB

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");
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) Resource01(org.jboss.jbossts.qa.CrashRecovery12Resources.Resource01) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) RootOA(com.arjuna.orbportability.RootOA) Resource02(org.jboss.jbossts.qa.CrashRecovery12Resources.Resource02) ORB(com.arjuna.orbportability.ORB)

Example 88 with ORB

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();
    }
}
Also used : OA(com.arjuna.orbportability.OA) ArrayList(java.util.ArrayList) ORB(com.arjuna.orbportability.ORB)

Example 89 with ORB

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();
    }
}
Also used : OA(com.arjuna.orbportability.OA) PerfTestInterfacePOA(org.jboss.jbossts.qa.performance.PerfTestInterfacePOA) Control(org.omg.CosTransactions.Control) SubtransactionAwareResource(org.omg.CosTransactions.SubtransactionAwareResource) DemoSubTranResource(org.jboss.jbossts.qa.performance.resources.DemoSubTranResource) PerfTestException(org.jboss.jbossts.qa.performance.PerfTestException) Coordinator(org.omg.CosTransactions.Coordinator) ORB(com.arjuna.orbportability.ORB) PerfTestException(org.jboss.jbossts.qa.performance.PerfTestException)

Example 90 with ORB

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();
    }
}
Also used : OA(com.arjuna.orbportability.OA) PerfTestInterface(org.jboss.jbossts.qa.performance.PerfTestInterface) ORB(com.arjuna.orbportability.ORB)

Aggregations

ORB (com.arjuna.orbportability.ORB)93 RootOA (com.arjuna.orbportability.RootOA)71 Test (org.junit.Test)57 OA (com.arjuna.orbportability.OA)20 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)20 Control (org.omg.CosTransactions.Control)20 Services (com.arjuna.orbportability.Services)19 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)9 PerfTestInterface (org.jboss.jbossts.qa.performance.PerfTestInterface)7 SystemException (org.omg.CORBA.SystemException)7 IntHolder (org.omg.CORBA.IntHolder)6 Coordinator (org.omg.CosTransactions.Coordinator)6 UserException (org.omg.CORBA.UserException)5 Properties (java.util.Properties)4 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)4 Terminator (org.omg.CosTransactions.Terminator)4 AtomicObject (com.hp.mwtests.ts.jts.orbspecific.resources.AtomicObject)3 Status (org.omg.CosTransactions.Status)3 TransactionFactory (org.omg.CosTransactions.TransactionFactory)3 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)2