Search in sources :

Example 51 with XidImple

use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.

the class SubordinateJTAXAResourceOrphanFilter method transactionLog.

/**
 * Is there a log file for this transaction?
 *
 * @param recoveredResourceXid
 *            the transaction to check.
 *
 * @return <code>boolean</code>true if there is a log file,
 *         <code>false</code> if there isn't.
 */
private boolean transactionLog(Xid recoveredResourceXid, String recoveredResourceNodeName) {
    XidImple theXid = new XidImple(recoveredResourceXid);
    Uid u = theXid.getTransactionUid();
    if (jtaLogger.logger.isDebugEnabled()) {
        jtaLogger.logger.debug("Checking whether Xid " + theXid + " exists in ObjectStore.");
    }
    if (!u.equals(Uid.nullUid())) {
        RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
        String transactionType = SubordinateAtomicAction.getType();
        if (jtaLogger.logger.isDebugEnabled()) {
            jtaLogger.logger.debug("Looking for " + u + " and " + transactionType);
        }
        InputObjectState states = new InputObjectState();
        try {
            if (recoveryStore.allObjUids(transactionType, states) && (states.notempty())) {
                Stack values = new Stack();
                boolean finished = false;
                do {
                    Uid uid = null;
                    try {
                        uid = UidHelper.unpackFrom(states);
                    } catch (IOException ex) {
                        ex.printStackTrace();
                        finished = true;
                    }
                    if (uid.notEquals(Uid.nullUid())) {
                        SubordinateAtomicAction tx = new SubordinateAtomicAction(uid, true);
                        XidImple transactionXid = (XidImple) tx.getXid();
                        if (transactionXid != null && transactionXid.isSameTransaction(recoveredResourceXid)) {
                            if (jtaLogger.logger.isDebugEnabled()) {
                                jtaLogger.logger.debug("Found record for " + theXid);
                            }
                            return true;
                        }
                    } else
                        finished = true;
                } while (!finished);
                if (jtaLogger.logger.isDebugEnabled()) {
                    jtaLogger.logger.debug("No record found for " + theXid);
                }
            } else {
                jtaLogger.i18NLogger.info_recovery_notaxid(XAHelper.xidToString(recoveredResourceXid));
            }
        } catch (ObjectStoreException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return false;
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) IOException(java.io.IOException) SubordinateAtomicAction(com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.SubordinateAtomicAction) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore) Stack(java.util.Stack)

Example 52 with XidImple

use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.

the class TransactionImple method createXid.

protected Xid createXid(boolean branch, XAModifier theModifier, XAResource xaResource) throws IOException, ObjectStoreException {
    int eisName = 0;
    if (branch) {
        if (_xaResourceRecordWrappingPlugin != null) {
            eisName = _xaResourceRecordWrappingPlugin.getEISName(xaResource);
        }
    }
    Xid xid = new XidImple(_theTransaction.get_uid(), branch, eisName);
    if (theModifier != null) {
        try {
            xid = theModifier.createXid((XidImple) xid);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return xid;
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Xid(javax.transaction.xa.Xid) InactiveTransactionException(com.arjuna.ats.jta.exceptions.InactiveTransactionException) RollbackException(javax.transaction.RollbackException) InvalidTerminationStateException(com.arjuna.ats.jta.exceptions.InvalidTerminationStateException) IOException(java.io.IOException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) SystemException(javax.transaction.SystemException) XAException(javax.transaction.xa.XAException)

Example 53 with XidImple

use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.

the class TransactionImporterImple method convertXid.

private XidImple convertXid(Xid xid) {
    if (xid != null && xid.getFormatId() == XATxConverter.FORMAT_ID) {
        XidImple toImport = new XidImple(xid);
        XATxConverter.setSubordinateNodeName(toImport.getXID(), TxControl.getXANodeName());
        return new SubordinateXidImple(toImport);
    } else {
        return new XidImple(xid);
    }
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple)

Example 54 with XidImple

use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.

the class SubordinateAtomicAction method restore_state.

public boolean restore_state(InputObjectState os, int t) {
    _theXid = null;
    try {
        unpackHeader(os, new Header());
        boolean haveXid = os.unpackBoolean();
        if (haveXid) {
            _theXid = new XidImple();
            ((XidImple) _theXid).unpackFrom(os);
            _parentNodeName = os.unpackString();
        }
    } catch (IOException ex) {
        return false;
    }
    return super.restore_state(os, t);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Header(com.arjuna.ats.internal.arjuna.Header) IOException(java.io.IOException)

Example 55 with XidImple

use of com.arjuna.ats.jta.xa.XidImple in project narayana by jbosstm.

the class SubordinateAtomicAction method save_state.

public boolean save_state(OutputObjectState os, int t) {
    try {
        // pack the header first for the benefit of the tooling
        packHeader(os, new Header(get_uid(), Utility.getProcessUid()));
        if (_theXid != null) {
            os.packBoolean(true);
            ((XidImple) _theXid).packInto(os);
            os.packString(_parentNodeName);
        } else
            os.packBoolean(false);
    } catch (IOException ex) {
        return false;
    }
    return super.save_state(os, t);
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) Header(com.arjuna.ats.internal.arjuna.Header) IOException(java.io.IOException)

Aggregations

XidImple (com.arjuna.ats.jta.xa.XidImple)90 Uid (com.arjuna.ats.arjuna.common.Uid)71 Test (org.junit.Test)71 Xid (javax.transaction.xa.Xid)35 XAException (javax.transaction.xa.XAException)28 SubordinateTransaction (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction)27 Transaction (javax.transaction.Transaction)16 XATerminator (javax.resource.spi.XATerminator)15 TransactionImporter (com.arjuna.ats.internal.jta.transaction.arjunacore.jca.TransactionImporter)12 XATerminatorImple (com.arjuna.ats.internal.jta.transaction.jts.jca.XATerminatorImple)10 IOException (java.io.IOException)10 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)9 XAOnePhaseResource (com.arjuna.ats.internal.jta.resources.arjunacore.XAOnePhaseResource)9 XAResourceRecord (com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord)9 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)8 SampleOnePhaseResource (com.hp.mwtests.ts.jta.common.SampleOnePhaseResource)8 RollbackException (javax.transaction.RollbackException)8 SystemException (javax.transaction.SystemException)8 XAResource (javax.transaction.xa.XAResource)8 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)7