Search in sources :

Example 11 with IntHolder

use of org.omg.CORBA.IntHolder in project narayana by jbosstm.

the class Client01 method operation.

private static boolean operation() throws Exception {
    boolean successful = false;
    try {
        AtomicTransaction atomicTransaction = new AtomicTransaction();
        try {
            atomicTransaction.begin();
            try {
                int x0 = Math.abs(_random.nextInt() % _matrixWidth);
                int y0 = Math.abs(_random.nextInt() % _matrixHeight);
                int x1 = Math.abs(_random.nextInt() % _matrixWidth);
                int y1 = Math.abs(_random.nextInt() % _matrixHeight);
                IntHolder srcValue = new IntHolder();
                IntHolder dstValue = new IntHolder();
                Control control = OTS.current().get_control();
                _matrix.get_value(x0, y0, srcValue, control);
                if (srcValue.value == 1) {
                    _matrix.get_value(x1, y1, dstValue, control);
                    if (dstValue.value == 0) {
                        _matrix.set_value(x0, y0, 0, control);
                        _matrix.set_value(x1, y1, 1, control);
                        successful = true;
                    }
                }
            } catch (InvocationException invocationException) {
                if (invocationException.myreason != Reason.ReasonConcurrencyControl) {
                    throw invocationException;
                }
            }
            if (successful) {
                atomicTransaction.commit(true);
            } else {
                atomicTransaction.rollback();
            }
        } catch (Exception exception) {
            if (atomicTransaction.get_status() == Status.StatusActive) {
                atomicTransaction.rollback();
            }
            throw exception;
        }
    } catch (Exception exception) {
        System.err.println("Client01.operation: " + exception);
        exception.printStackTrace(System.err);
        throw exception;
    }
    return successful;
}
Also used : Control(org.omg.CosTransactions.Control) AtomicTransaction(com.arjuna.ats.jts.extensions.AtomicTransaction) IntHolder(org.omg.CORBA.IntHolder)

Example 12 with IntHolder

use of org.omg.CORBA.IntHolder in project narayana by jbosstm.

the class Outcome01 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        int maxIndex = Integer.parseInt(args[args.length - 2]);
        String numberTableIOR = ServerIORStore.loadIOR(args[args.length - 1]);
        NumberTable numberTable = NumberTableHelper.narrow(ORBInterface.orb().string_to_object(numberTableIOR));
        boolean correct = true;
        OTS.current().begin();
        for (int index = 0; correct && (index < maxIndex); index++) {
            String name = "Name_" + index;
            IntHolder valueHolder = new IntHolder();
            numberTable.get(name, valueHolder);
            correct = correct && (valueHolder.value == maxIndex);
        }
        OTS.current().commit(true);
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Outcome01.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Outcome01.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : IntHolder(org.omg.CORBA.IntHolder)

Example 13 with IntHolder

use of org.omg.CORBA.IntHolder in project narayana by jbosstm.

the class Client11 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        String pingerIOR = ServerIORStore.loadIOR(args[args.length - 2]);
        PingPong pinger = PingPongHelper.narrow(ORBInterface.orb().string_to_object(pingerIOR));
        String pongerIOR = ServerIORStore.loadIOR(args[args.length - 1]);
        PingPong ponger = PingPongHelper.narrow(ORBInterface.orb().string_to_object(pongerIOR));
        int numberOfCalls = 10;
        for (int index0 = 0; index0 < numberOfCalls; index0++) {
            for (int index1 = 0; index1 <= index0; index1++) {
                pinger.bad_hit(index0, index1, ponger, pinger);
            }
        }
        IntHolder pingerValue = new IntHolder();
        pinger.get(pingerValue);
        IntHolder pongerValue = new IntHolder();
        ponger.get(pongerValue);
        if ((pingerValue.value == 0) && (pongerValue.value == 0)) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client11.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client11.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : IntHolder(org.omg.CORBA.IntHolder)

Example 14 with IntHolder

use of org.omg.CORBA.IntHolder in project narayana by jbosstm.

the class Client19 method main.

public static void main(String[] args) {
    boolean correct = true;
    int numberOfCalls = 10;
    Counter counter = null;
    System.err.println("Starting first init");
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
    } catch (Exception exception) {
        correct = false;
        System.err.println("exception in first start: " + exception);
        exception.printStackTrace(System.err);
    }
    System.err.println("Starting first block");
    try {
        String counterIOR = ServerIORStore.loadIOR(args[args.length - 1]);
        counter = CounterHelper.narrow(ORBInterface.orb().string_to_object(counterIOR));
        for (int index = 0; index < numberOfCalls; index++) {
            AtomicTransaction atomicTransaction = new AtomicTransaction();
            atomicTransaction.begin();
            counter.increase();
            if ((index % 2) == 0) {
                atomicTransaction.commit(true);
            } else {
                atomicTransaction.rollback();
            }
        }
        AtomicTransaction atomicTransaction = new AtomicTransaction();
        atomicTransaction.begin();
        IntHolder value = new IntHolder();
        counter.get(value);
        atomicTransaction.commit(true);
        if (value.value == (numberOfCalls / 2) && correct) {
            correct = true;
        } else {
            correct = false;
        }
    } catch (Exception exception) {
        correct = false;
        System.err.println("exception in first block" + exception);
        exception.printStackTrace(System.err);
    }
    System.err.println("Starting first shutdown");
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        correct = false;
        System.err.println("exception in first shutdown" + exception);
        exception.printStackTrace(System.err);
    }
    System.err.println("----Starting second block -------");
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
    } catch (Exception exception) {
        correct = false;
        System.err.println("exception in second start " + exception);
        exception.printStackTrace(System.err);
    }
    System.err.println("init done starting second block");
    try {
        String counterIOR = ServerIORStore.loadIOR(args[args.length - 1]);
        counter = CounterHelper.narrow(ORBInterface.orb().string_to_object(counterIOR));
        AtomicTransaction atomicTransaction = new AtomicTransaction();
        atomicTransaction.begin();
        counter.set(0);
        atomicTransaction.commit(true);
    } catch (Exception exception) {
        correct = false;
        System.err.println("exception in set operation " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        for (int index = 0; index < numberOfCalls; index++) {
            AtomicTransaction atomicTransaction = new AtomicTransaction();
            atomicTransaction.begin();
            counter.increase();
            if ((index % 2) == 0) {
                atomicTransaction.commit(true);
            } else {
                atomicTransaction.rollback();
            }
        }
    } catch (Exception exception) {
        correct = false;
        System.err.println("exception in second loop block " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        AtomicTransaction atomicTransaction = new AtomicTransaction();
        atomicTransaction.begin();
        IntHolder value = new IntHolder();
        counter.get(value);
        atomicTransaction.commit(true);
        if (value.value == (numberOfCalls / 2) && correct) {
            correct = true;
        } else {
            correct = false;
        }
    } catch (Exception exception) {
        correct = false;
        System.err.println("exception in second test " + exception);
        exception.printStackTrace(System.err);
    }
    System.err.println("Starting second shutdown");
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        correct = false;
        System.err.println("error in second shutdown" + exception);
        exception.printStackTrace(System.err);
    }
    System.err.println("testing result");
    if (correct) {
        System.out.println("Passed");
    } else {
        System.out.println("Failed");
    }
}
Also used : AtomicTransaction(com.arjuna.ats.jts.extensions.AtomicTransaction) IntHolder(org.omg.CORBA.IntHolder)

Example 15 with IntHolder

use of org.omg.CORBA.IntHolder in project narayana by jbosstm.

the class Client02 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        String counterIOR = ServerIORStore.loadIOR(args[args.length - 1]);
        Counter counter = CounterHelper.narrow(ORBInterface.orb().string_to_object(counterIOR));
        int numberOfCalls = 1000;
        for (int index = 0; index < numberOfCalls; index++) {
            AtomicTransaction atomicTransaction = new AtomicTransaction();
            atomicTransaction.begin();
            counter.increase(OTS.current().get_control());
            if ((index % 2) == 0) {
                atomicTransaction.commit(true);
            } else {
                atomicTransaction.rollback();
            }
        }
        AtomicTransaction atomicTransaction = new AtomicTransaction();
        atomicTransaction.begin();
        IntHolder value = new IntHolder();
        counter.get(value, OTS.current().get_control());
        atomicTransaction.commit(true);
        if (value.value == (numberOfCalls / 2)) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client02.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client02.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : AtomicTransaction(com.arjuna.ats.jts.extensions.AtomicTransaction) IntHolder(org.omg.CORBA.IntHolder)

Aggregations

IntHolder (org.omg.CORBA.IntHolder)72 AtomicTransaction (com.arjuna.ats.jts.extensions.AtomicTransaction)12 Control (org.omg.CosTransactions.Control)10 ORB (com.arjuna.orbportability.ORB)6 RootOA (com.arjuna.orbportability.RootOA)6 HitCountRequest (org.codice.alliance.nsili.common.GIAS.HitCountRequest)6 Services (com.arjuna.orbportability.Services)5 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)5 AcsJCORBAProblemEx (alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)4 NameAlreadyUsed (gov.sandia.NotifyMonitoringExt.NameAlreadyUsed)3 NameMapError (gov.sandia.NotifyMonitoringExt.NameMapError)3 Test (org.junit.Test)3 BAD_PARAM (org.omg.CORBA.BAD_PARAM)3 AdminLimitExceeded (org.omg.CosNotifyChannelAdmin.AdminLimitExceeded)3 AcsJNarrowFailedEx (alma.ACSErrTypeCORBA.wrappers.AcsJNarrowFailedEx)2 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)2 SubmitQueryRequest (org.codice.alliance.nsili.common.GIAS.SubmitQueryRequest)2 DAGListHolder (org.codice.alliance.nsili.common.UCO.DAGListHolder)2 InvalidInputParameter (org.codice.alliance.nsili.common.UCO.InvalidInputParameter)2 ProcessingFault (org.codice.alliance.nsili.common.UCO.ProcessingFault)2