Search in sources :

Example 16 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class AtomicObject method get.

public synchronized int get() throws TestException {
    CurrentImple current = OTSImpleManager.current();
    int value = -1;
    try {
        current.begin();
        if (setlock(new Lock(LockMode.READ), 5) == LockResult.GRANTED) {
            value = _value;
            current.commit(false);
            return value;
        } else {
            current.rollback();
            throw new TestException("Could not setlock");
        }
    } catch (Exception e) {
        throw new TestException(e);
    }
}
Also used : TestException(com.hp.mwtests.ts.jts.exceptions.TestException) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) IOException(java.io.IOException) TestException(com.hp.mwtests.ts.jts.exceptions.TestException) Lock(com.arjuna.ats.txoj.Lock)

Example 17 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class AtomicObject method incr.

public synchronized boolean incr(int value) {
    boolean res = false;
    CurrentImple current = OTSImpleManager.current();
    try {
        current.begin();
        if (setlock(new Lock(LockMode.WRITE), 5) == LockResult.GRANTED) {
            _value = _value + value;
            current.commit(false);
            res = true;
        } else
            current.rollback();
    } catch (Exception e) {
        logger.info(e);
        logger.warn(e.getMessage(), e);
        ;
        res = false;
    }
    return res;
}
Also used : CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) IOException(java.io.IOException) TestException(com.hp.mwtests.ts.jts.exceptions.TestException) Lock(com.arjuna.ats.txoj.Lock)

Example 18 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class DHThreadObject3a method run.

public void run() {
    CurrentImple current = OTSImpleManager.current();
    try {
        current.begin();
        Util.indent(_threadId, 0);
        System.out.println("begin");
        DistributedHammerWorker3.randomOperation(_threadId, 0);
        DistributedHammerWorker3.randomOperation(_threadId, 0);
        if (_commit)
            current.commit(false);
        else
            current.rollback();
        Util.indent(_threadId, 0);
        if (_commit)
            System.out.println("end");
        else
            System.out.println("abort");
    } catch (Exception e) {
        System.err.println(e);
    }
}
Also used : CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple)

Example 19 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class HammerObject method get.

public boolean get(IntHolder value, Control control) throws SystemException {
    boolean res = false;
    ExplicitInterposition inter = new ExplicitInterposition();
    try {
        inter.registerTransaction(control);
    } catch (Exception e) {
        System.err.println("WARNING HammerObject.incr - could not do interposition");
        return false;
    }
    CurrentImple current = OTSImpleManager.current();
    try {
        current.begin();
        if (setlock(new Lock(LockMode.READ), 0) == LockResult.GRANTED) {
            value.value = _value;
            current.commit(true);
            res = true;
        } else
            current.rollback();
    } catch (Exception e) {
        System.err.println("HammerObject.get: " + e);
        res = false;
    }
    inter.unregisterTransaction();
    return res;
}
Also used : ExplicitInterposition(com.arjuna.ats.jts.ExplicitInterposition) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) SystemException(org.omg.CORBA.SystemException) IOException(java.io.IOException) Lock(com.arjuna.ats.txoj.Lock)

Example 20 with CurrentImple

use of com.arjuna.ats.internal.jts.orbspecific.CurrentImple in project narayana by jbosstm.

the class HammerObject method incr.

public boolean incr(int value, Control control) throws SystemException {
    boolean res = false;
    ExplicitInterposition inter = new ExplicitInterposition();
    try {
        inter.registerTransaction(control);
    } catch (Exception e) {
        System.err.println("WARNING HammerObject.incr - could not do interposition");
        return false;
    }
    CurrentImple current = OTSImpleManager.current();
    try {
        current.begin();
        if (setlock(new Lock(LockMode.WRITE), 0) == LockResult.GRANTED) {
            _value = _value + value;
            current.commit(true);
            res = true;
        } else
            current.rollback();
    } catch (Exception e) {
        System.err.println("HammerObject.incr: " + e);
        res = false;
    }
    inter.unregisterTransaction();
    return res;
}
Also used : ExplicitInterposition(com.arjuna.ats.jts.ExplicitInterposition) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) SystemException(org.omg.CORBA.SystemException) IOException(java.io.IOException) Lock(com.arjuna.ats.txoj.Lock)

Aggregations

CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)47 Control (org.omg.CosTransactions.Control)14 SystemException (org.omg.CORBA.SystemException)12 ORB (com.arjuna.orbportability.ORB)9 RootOA (com.arjuna.orbportability.RootOA)9 IOException (java.io.IOException)7 Lock (com.arjuna.ats.txoj.Lock)6 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)6 Coordinator (org.omg.CosTransactions.Coordinator)6 Services (com.arjuna.orbportability.Services)5 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)5 ExplicitInterposition (com.arjuna.ats.jts.ExplicitInterposition)4 Test (org.junit.Test)4 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)3 TestException (com.hp.mwtests.ts.jts.exceptions.TestException)3 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)3 NoTransaction (org.omg.CosTransactions.NoTransaction)3 InterpositionFailed (com.arjuna.ArjunaOTS.InterpositionFailed)2 FatalError (com.arjuna.ats.arjuna.exceptions.FatalError)2 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)2