Search in sources :

Example 1 with TestException

use of com.hp.mwtests.ts.jts.exceptions.TestException 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 2 with TestException

use of com.hp.mwtests.ts.jts.exceptions.TestException in project narayana by jbosstm.

the class AtomicWorker1 method get1.

public static int get1() throws Exception {
    boolean res = false;
    int returnValue = -1;
    try {
        current.begin();
        try {
            returnValue = atomicObject_1.get();
            res = true;
        } catch (TestException e) {
        }
        if (res)
            current.commit(false);
        else
            current.rollback();
    } catch (Exception e) {
        System.err.println(e);
        throw e;
    }
    if (!res)
        throw new Exception("Get1: Failed to retrieve value");
    return (returnValue);
}
Also used : TestException(com.hp.mwtests.ts.jts.exceptions.TestException) TestException(com.hp.mwtests.ts.jts.exceptions.TestException)

Example 3 with TestException

use of com.hp.mwtests.ts.jts.exceptions.TestException in project narayana by jbosstm.

the class AtomicWorker1 method get2.

public static int get2() throws Exception {
    boolean res = false;
    int returnValue = -1;
    try {
        current.begin();
        try {
            returnValue = atomicObject_2.get();
            res = true;
        } catch (TestException e) {
        }
        if (res)
            current.commit(false);
        else
            current.rollback();
    } catch (Exception e) {
        System.err.println(e);
        throw e;
    }
    if (!res)
        throw new Exception("Get2: Failed to retrieve value");
    return (returnValue);
}
Also used : TestException(com.hp.mwtests.ts.jts.exceptions.TestException) TestException(com.hp.mwtests.ts.jts.exceptions.TestException)

Example 4 with TestException

use of com.hp.mwtests.ts.jts.exceptions.TestException in project narayana by jbosstm.

the class AtomicWorker2 method get2.

public static int get2() throws Exception {
    boolean res = false;
    int returnValue = -1;
    try {
        current.begin();
        try {
            returnValue = atomicObject_2.get();
            res = true;
        } catch (TestException e) {
        }
        if (res)
            current.commit(false);
        else
            current.rollback();
    } catch (Exception e) {
        System.err.println(e);
        throw e;
    }
    if (!res)
        throw new Exception("Get2: Failed to retrieve value");
    return (returnValue);
}
Also used : TestException(com.hp.mwtests.ts.jts.exceptions.TestException) TestException(com.hp.mwtests.ts.jts.exceptions.TestException)

Example 5 with TestException

use of com.hp.mwtests.ts.jts.exceptions.TestException in project narayana by jbosstm.

the class AtomicWorker2 method get1.

public static int get1() throws Exception {
    boolean res = false;
    int returnValue = -1;
    try {
        current.begin();
        try {
            returnValue = atomicObject_1.get();
            res = true;
        } catch (TestException e) {
        }
        if (res)
            current.commit(false);
        else
            current.rollback();
    } catch (Exception e) {
        System.err.println(e);
        throw e;
    }
    if (!res)
        throw new Exception("Get1: Failed to retrieve value");
    return (returnValue);
}
Also used : TestException(com.hp.mwtests.ts.jts.exceptions.TestException) TestException(com.hp.mwtests.ts.jts.exceptions.TestException)

Aggregations

TestException (com.hp.mwtests.ts.jts.exceptions.TestException)5 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)1 Lock (com.arjuna.ats.txoj.Lock)1 IOException (java.io.IOException)1