Search in sources :

Example 61 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class DistributedHammerWorker2 method incr12.

public static void incr12(char thr, int level) {
    boolean res = false;
    boolean res1 = false;
    boolean res2 = false;
    int ran = 0;
    try {
        OTSImpleManager.current().begin();
        Control control = OTSImpleManager.current().get_control();
        Util.indent(thr, level);
        System.out.println("begin   incr12");
        ran = Util.rand.nextInt() % 16;
        res1 = hammerObject_1.incr(ran, control);
        res = res1;
        Util.indent(thr, level);
        System.out.println("part1   incr12 : " + res1);
        Util.lowProbYield();
        if (res) {
            res2 = hammerObject_2.incr(-ran, control);
            res = res2;
            Util.indent(thr, level);
            System.out.println("part2   incr12 : " + 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("DistributedHammerWorker2.incr12: " + e);
        res1 = res2 = res = false;
    }
    Util.indent(thr, level);
    System.out.println(" incr12 : " + res1 + " : " + res2 + " : " + res + " : " + ran);
}
Also used : Control(org.omg.CosTransactions.Control)

Example 62 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class DistributedHammerWorker2 method incr21.

public static void incr21(char thr, int level) {
    boolean res = false;
    boolean res1 = false;
    boolean res2 = false;
    int ran = 0;
    try {
        OTSImpleManager.current().begin();
        Control control = OTSImpleManager.current().get_control();
        Util.indent(thr, level);
        System.out.println("begin   incr21");
        ran = Util.rand.nextInt() % 16;
        res1 = hammerObject_2.incr(ran, control);
        res = res1;
        Util.indent(thr, level);
        System.out.println("part1   incr21 : " + res1);
        Util.lowProbYield();
        if (res) {
            res2 = hammerObject_1.incr(-ran, control);
            res = res2;
            Util.indent(thr, level);
            System.out.println("part2   incr21 : " + 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("DistributedHammerWorker2.incr21: " + e);
        res1 = res2 = res = false;
    }
    Util.indent(thr, level);
    System.out.println(" incr21 : " + res1 + " : " + res2 + " : " + res + " : " + ran);
}
Also used : Control(org.omg.CosTransactions.Control)

Example 63 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class DistributedHammerWorker2 method get1.

public static boolean get1(IntHolder value) {
    boolean res = false;
    try {
        OTSImpleManager.current().begin();
        Control control = OTSImpleManager.current().get_control();
        res = hammerObject_1.get(value, control);
        control = null;
        if (res) {
            OTSImpleManager.current().commit(true);
        } else {
            OTSImpleManager.current().rollback();
        }
    } catch (Exception e) {
        System.err.println("DistributedHammerWorker1.get1: " + e);
        res = false;
    }
    return (res);
}
Also used : Control(org.omg.CosTransactions.Control)

Example 64 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class DistributedHammerWorker2 method get2.

public static boolean get2(IntHolder value) {
    boolean res = false;
    try {
        OTSImpleManager.current().begin();
        Control control = OTSImpleManager.current().get_control();
        res = hammerObject_2.get(value, control);
        control = null;
        if (res) {
            OTSImpleManager.current().commit(true);
        } else {
            OTSImpleManager.current().rollback();
        }
    } catch (Exception e) {
        System.err.println("DistributedHammerWorker1.get2: " + e);
        res = false;
    }
    return (res);
}
Also used : Control(org.omg.CosTransactions.Control)

Example 65 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class setget_i method set.

public void set(short n, Control control) throws SystemException {
    System.out.println("setget_i.set " + n);
    try {
        if (control != null) {
            ExplicitInterposition manager = new ExplicitInterposition();
            manager.registerTransaction(control);
            System.out.println("setget_i.set - managed to set up interposition hierarchy");
            CurrentImple current = OTSImpleManager.current();
            Control cont = current.get_control();
            if (cont == null)
                System.err.println("setget_i.set error - current returned no control!");
            else {
                System.out.println("setget_i.set - current returned a control!");
                cont = null;
            }
            System.out.println("setget_i.set - beginning nested action");
            current.begin();
            cont = current.get_control();
            if (cont != null) {
                Coordinator coord = cont.get_coordinator();
                System.out.println("setget_i.set - registering self");
                coord.register_resource(ref);
                coord = null;
                cont = null;
            } else
                System.err.println("setget_i.set - current did not return control after begin!");
            value = n;
            System.out.println("setget_i.set - committing nested action");
            current.commit(true);
            manager.unregisterTransaction();
            manager = null;
        } else
            System.err.println("setget_i::set error - no control!");
    } catch (InterpositionFailed ex) {
        System.err.println("setget_i.set - error in setting up hierarchy");
        throw new UNKNOWN();
    } catch (Throwable e) {
        System.err.println("setget_i::set - caught exception: " + e);
    }
    System.out.println("setget_i.set - finished");
}
Also used : Control(org.omg.CosTransactions.Control) InterpositionFailed(com.arjuna.ArjunaOTS.InterpositionFailed) ExplicitInterposition(com.arjuna.ats.jts.ExplicitInterposition) UNKNOWN(org.omg.CORBA.UNKNOWN) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) Coordinator(org.omg.CosTransactions.Coordinator)

Aggregations

Control (org.omg.CosTransactions.Control)103 Test (org.junit.Test)40 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)24 ArjunaTransactionImple (com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple)20 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)20 ORB (com.arjuna.orbportability.ORB)20 RootOA (com.arjuna.orbportability.RootOA)18 TransactionFactory (org.omg.CosTransactions.TransactionFactory)16 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)14 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)13 Coordinator (org.omg.CosTransactions.Coordinator)13 SystemException (org.omg.CORBA.SystemException)11 IntHolder (org.omg.CORBA.IntHolder)10 Current (org.omg.CosTransactions.Current)9 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)6 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)6 Services (com.arjuna.orbportability.Services)6 PropagationContext (org.omg.CosTransactions.PropagationContext)6 ActionControl (com.arjuna.ArjunaOTS.ActionControl)5 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)5