Search in sources :

Example 1 with ControlImpl

use of com.sun.jts.CosTransactions.ControlImpl in project Payara by payara.

the class TransactionState method computeXid.

private Xid computeXid(XAResource res, Control control) throws Inactive, Unavailable, XAException {
    // one branch id per RM
    int size = factories.size();
    for (int i = 0; i < size; i++) {
        XAResource fac = (XAResource) factories.get(i);
        if (res.isSameRM(fac)) {
            // use same branch
            Xid xid = (Xid) resourceList.get(fac);
            return xid;
        }
    }
    // use a different branch
    // XXX ideally should call JTS layer to get the branch id
    XID xid;
    if (Configuration.isLocalFactory()) {
        xid = Utility.getXID(((ControlImpl) control).get_localCoordinator());
    } else {
        xid = Utility.getXID(control.get_coordinator());
    }
    factories.add(res);
    byte[] branchid = parseSize(size);
    byte[] sname = Configuration.getServerNameByteArray();
    byte[] branch = new byte[sname.length + 1 + branchid.length];
    System.arraycopy(sname, 0, branch, 0, sname.length);
    branch[sname.length] = (byte) ',';
    System.arraycopy(branchid, 0, branch, sname.length + 1, branchid.length);
    xid.setBranchQualifier(branch);
    return xid;
}
Also used : NativeXAResource(com.sun.jts.jta.NativeXAResource) XID(com.sun.jts.jtsxa.XID) ControlImpl(com.sun.jts.CosTransactions.ControlImpl)

Example 2 with ControlImpl

use of com.sun.jts.CosTransactions.ControlImpl in project Payara by payara.

the class FailureInducer method getGlobalTID.

private static GlobalTID getGlobalTID() {
    GlobalTID gtid = null;
    Coordinator coord = Utility.getCoordinator(Utility.getControl());
    JCoordinator jcoord = JCoordinatorHelper.narrow(coord);
    if (jcoord != null) {
        gtid = new GlobalTID(jcoord.getGlobalTID());
    } else {
        ControlImpl control = CurrentTransaction.getCurrent();
        if (control != null) {
            gtid = control.getGlobalTID();
        }
    }
    return gtid;
}
Also used : JCoordinator(com.sun.jts.codegen.otsidl.JCoordinator) ControlImpl(com.sun.jts.CosTransactions.ControlImpl) JCoordinator(com.sun.jts.codegen.otsidl.JCoordinator) Coordinator(org.omg.CosTransactions.Coordinator) GlobalTID(com.sun.jts.CosTransactions.GlobalTID)

Aggregations

ControlImpl (com.sun.jts.CosTransactions.ControlImpl)2 GlobalTID (com.sun.jts.CosTransactions.GlobalTID)1 JCoordinator (com.sun.jts.codegen.otsidl.JCoordinator)1 NativeXAResource (com.sun.jts.jta.NativeXAResource)1 XID (com.sun.jts.jtsxa.XID)1 Coordinator (org.omg.CosTransactions.Coordinator)1