Search in sources :

Example 81 with AtomicTransaction

use of com.arjuna.ats.jts.extensions.AtomicTransaction in project narayana by jbosstm.

the class Client02 method operation.

private static boolean operation() throws Exception {
    boolean successful = false;
    try {
        AtomicTransaction atomicTransaction = new AtomicTransaction();
        try {
            atomicTransaction.begin();
            try {
                int d = Math.abs(_random.nextInt() % 10) + 1;
                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 location0Value = new IntHolder();
                IntHolder location1Value = new IntHolder();
                _matrix.get_value(x0, y0, location0Value);
                _matrix.get_value(x1, y1, location1Value);
                _matrix.set_value(x0, y0, location1Value.value + d);
                _matrix.set_value(x1, y1, location0Value.value - d);
                successful = (x0 != x1) || (y0 != y1);
            } 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("Client02.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 82 with AtomicTransaction

use of com.arjuna.ats.jts.extensions.AtomicTransaction in project narayana by jbosstm.

the class Client_ExplicitObject_TranRollback_TranCommitReadLock method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        String prefix = args[args.length - 3];
        int numberOfCalls = Integer.parseInt(args[args.length - 2]);
        String explicitObjectIOR = ServerIORStore.loadIOR(args[args.length - 1]);
        ExplicitObject explicitObject = ExplicitObjectHelper.narrow(ORBInterface.orb().string_to_object(explicitObjectIOR));
        boolean correct = true;
        Date start = new Date();
        for (int index = 0; index < numberOfCalls; index++) {
            AtomicTransaction atomicTransaction = new AtomicTransaction();
            atomicTransaction.begin();
            explicitObject.tran_commit_readlock(OTS.current().get_control());
            atomicTransaction.rollback();
        }
        Date end = new Date();
        float operationDuration = ((float) (end.getTime() - start.getTime())) / ((float) numberOfCalls);
        System.err.println("Operation duration       : " + operationDuration + "ms");
        System.err.println("Test duration            : " + (end.getTime() - start.getTime()) + "ms");
        correct = PerformanceProfileStore.checkPerformance(prefix + "_ExplicitObject_TranRollback_TranCommitReadLock", operationDuration);
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client_ExplicitObject_TranRollback_TranCommitReadLock.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client_ExplicitObject_TranRollback_TranCommitReadLock.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : AtomicTransaction(com.arjuna.ats.jts.extensions.AtomicTransaction) Date(java.util.Date)

Example 83 with AtomicTransaction

use of com.arjuna.ats.jts.extensions.AtomicTransaction in project narayana by jbosstm.

the class Client_ExplicitObject_TranRollback_TranRollbackWriteLock method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        String prefix = args[args.length - 3];
        int numberOfCalls = Integer.parseInt(args[args.length - 2]);
        String explicitObjectIOR = ServerIORStore.loadIOR(args[args.length - 1]);
        ExplicitObject explicitObject = ExplicitObjectHelper.narrow(ORBInterface.orb().string_to_object(explicitObjectIOR));
        boolean correct = true;
        Date start = new Date();
        for (int index = 0; index < numberOfCalls; index++) {
            AtomicTransaction atomicTransaction = new AtomicTransaction();
            atomicTransaction.begin();
            explicitObject.tran_rollback_writelock(OTS.current().get_control());
            atomicTransaction.rollback();
        }
        Date end = new Date();
        float operationDuration = ((float) (end.getTime() - start.getTime())) / ((float) numberOfCalls);
        System.err.println("Operation duration       : " + operationDuration + "ms");
        System.err.println("Test duration            : " + (end.getTime() - start.getTime()) + "ms");
        correct = PerformanceProfileStore.checkPerformance(prefix + "_ExplicitObject_TranRollback_TranRollbackWriteLock", operationDuration);
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client_ExplicitObject_TranRollback_TranRollbackWriteLock.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client_ExplicitObject_TranRollback_TranRollbackWriteLock.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : AtomicTransaction(com.arjuna.ats.jts.extensions.AtomicTransaction) Date(java.util.Date)

Example 84 with AtomicTransaction

use of com.arjuna.ats.jts.extensions.AtomicTransaction in project narayana by jbosstm.

the class Client_ExplicitObject_TranCommit_TranCommitWriteLock method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        String prefix = args[args.length - 3];
        int numberOfCalls = Integer.parseInt(args[args.length - 2]);
        String explicitObjectIOR = ServerIORStore.loadIOR(args[args.length - 1]);
        ExplicitObject explicitObject = ExplicitObjectHelper.narrow(ORBInterface.orb().string_to_object(explicitObjectIOR));
        boolean correct = true;
        Date start = new Date();
        for (int index = 0; index < numberOfCalls; index++) {
            AtomicTransaction atomicTransaction = new AtomicTransaction();
            atomicTransaction.begin();
            explicitObject.tran_commit_writelock(OTS.current().get_control());
            atomicTransaction.commit(true);
        }
        Date end = new Date();
        float operationDuration = ((float) (end.getTime() - start.getTime())) / ((float) numberOfCalls);
        System.err.println("Operation duration       : " + operationDuration + "ms");
        System.err.println("Test duration            : " + (end.getTime() - start.getTime()) + "ms");
        correct = PerformanceProfileStore.checkPerformance(prefix + "_ExplicitObject_TranCommit_TranCommitWriteLock", operationDuration);
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client_ExplicitObject_TranCommit_TranCommitWriteLock.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client_ExplicitObject_TranCommit_TranCommitWriteLock.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : AtomicTransaction(com.arjuna.ats.jts.extensions.AtomicTransaction) Date(java.util.Date)

Example 85 with AtomicTransaction

use of com.arjuna.ats.jts.extensions.AtomicTransaction in project narayana by jbosstm.

the class Client_ExplicitObject_TranCommit_TranRollbackReadLock method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        String prefix = args[args.length - 3];
        int numberOfCalls = Integer.parseInt(args[args.length - 2]);
        String explicitObjectIOR = ServerIORStore.loadIOR(args[args.length - 1]);
        ExplicitObject explicitObject = ExplicitObjectHelper.narrow(ORBInterface.orb().string_to_object(explicitObjectIOR));
        boolean correct = true;
        Date start = new Date();
        for (int index = 0; index < numberOfCalls; index++) {
            AtomicTransaction atomicTransaction = new AtomicTransaction();
            atomicTransaction.begin();
            explicitObject.tran_rollback_readlock(OTS.current().get_control());
            atomicTransaction.commit(true);
        }
        Date end = new Date();
        float operationDuration = ((float) (end.getTime() - start.getTime())) / ((float) numberOfCalls);
        System.err.println("Operation duration       : " + operationDuration + "ms");
        System.err.println("Test duration            : " + (end.getTime() - start.getTime()) + "ms");
        correct = PerformanceProfileStore.checkPerformance(prefix + "_ExplicitObject_TranCommit_TranRollbackReadLock", operationDuration);
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client_ExplicitObject_TranCommit_TranRollbackReadLock.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client_ExplicitObject_TranCommit_TranRollbackReadLock.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : AtomicTransaction(com.arjuna.ats.jts.extensions.AtomicTransaction) Date(java.util.Date)

Aggregations

AtomicTransaction (com.arjuna.ats.jts.extensions.AtomicTransaction)101 Lock (com.arjuna.ats.txoj.Lock)38 Date (java.util.Date)36 IntHolder (org.omg.CORBA.IntHolder)12 JVMStats (org.jboss.jbossts.qa.Utils.JVMStats)9 Test (org.junit.Test)7 IOException (java.io.IOException)6 SystemException (org.omg.CORBA.SystemException)6 DemoResource (com.hp.mwtests.ts.jts.orbspecific.resources.DemoResource)3 ExplicitInterposition (com.arjuna.ats.jts.ExplicitInterposition)2 TopLevelTransaction (com.arjuna.ats.jts.extensions.TopLevelTransaction)2 Control (org.omg.CosTransactions.Control)2 DemoSubTranResource (com.hp.mwtests.ts.jts.orbspecific.resources.DemoSubTranResource)1 com.hp.mwtests.ts.jts.orbspecific.resources.demosync (com.hp.mwtests.ts.jts.orbspecific.resources.demosync)1 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)1