Search in sources :

Example 31 with IntHolder

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

the class DistributedHammerWorker3 method get21.

public static void get21(int thr, int level) {
    boolean res = false;
    boolean res1 = false;
    boolean res2 = false;
    IntHolder value1 = new IntHolder(0);
    IntHolder value2 = new IntHolder(0);
    try {
        OTSImpleManager.current().begin();
        Control control = OTSImpleManager.current().get_control();
        Util.indent(thr, level);
        System.out.println("begin   get21");
        res1 = hammerObject_2.get(value1, control);
        res = res1;
        Util.indent(thr, level);
        System.out.println("part1   get21  : " + res1);
        Util.lowProbYield();
        if (res) {
            res2 = hammerObject_1.get(value2, control);
            res = res2;
            Util.indent(thr, level);
            System.out.println("part2   get21  : " + res2);
        }
        Util.lowProbYield();
        control = null;
        Util.indent(thr, level);
        if (res) {
            System.out.print("end ");
            OTSImpleManager.current().commit(true);
        } else {
            System.out.print("abort  ");
            OTSImpleManager.current().rollback();
        }
    } catch (Exception e) {
        System.err.println("DistributedHammerWorker3.get21: " + e);
        res1 = res2 = res = false;
    }
    Util.indent(thr, level);
    System.out.println(" get21  : " + res1 + " : " + res2 + " : " + res + " : " + value1.value + " : " + value2.value);
}
Also used : Control(org.omg.CosTransactions.Control) IntHolder(org.omg.CORBA.IntHolder)

Example 32 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();
            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)) {
            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)

Example 33 with IntHolder

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

the class Client14 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        String counterIOR = ServerIORStore.loadIOR(args[args.length - 3]);
        Counter counter = CounterHelper.narrow(ORBInterface.orb().string_to_object(counterIOR));
        int numberOfWorkers = Integer.parseInt(args[args.length - 2]);
        int numberOfCalls = Integer.parseInt(args[args.length - 1]);
        Worker[] workers = new Worker[numberOfWorkers];
        for (int index = 0; index < workers.length; index++) {
            workers[index] = new Worker(numberOfCalls, counter);
        }
        for (int index = 0; index < workers.length; index++) {
            workers[index].start();
        }
        boolean correct = true;
        for (int index = 0; index < workers.length; index++) {
            workers[index].join();
            correct = correct && workers[index].isCorrect();
        }
        IntHolder value = new IntHolder();
        counter.get(value);
        correct = correct && (value.value == (numberOfWorkers * numberOfCalls));
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client14.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client14.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : IntHolder(org.omg.CORBA.IntHolder)

Example 34 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();
                _matrix.get_value(x0, y0, srcValue);
                if (srcValue.value == 1) {
                    _matrix.get_value(x1, y1, dstValue);
                    if (dstValue.value == 0) {
                        _matrix.set_value(x0, y0, 0);
                        _matrix.set_value(x1, y1, 1);
                        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 : AtomicTransaction(com.arjuna.ats.jts.extensions.AtomicTransaction) IntHolder(org.omg.CORBA.IntHolder)

Example 35 with IntHolder

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

the class Client02a method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        String serviceIOR = ServerIORStore.loadIOR(args[args.length - 1]);
        Service service = ServiceHelper.narrow(ORBInterface.orb().string_to_object(serviceIOR));
        CrashRecoveryDelays.awaitRecoveryCR10();
        boolean correct = true;
        OTS.current().begin();
        IntHolder valueHolder = new IntHolder();
        service.get(OTS.current().get_control(), valueHolder);
        correct = correct && (valueHolder.value == 0);
        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("Client02a.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client02a.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : 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