Search in sources :

Example 71 with ObjectStoreException

use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException 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 72 with ObjectStoreException

use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException 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 73 with ObjectStoreException

use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.

the class JCAServerTransactionRecoveryModule method periodicWorkFirstPass.

@Override
public void periodicWorkFirstPass() {
    try {
        RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
        InputObjectState states = new InputObjectState();
        if (recoveryStore.allObjUids(ServerTransaction.getType(), states) && (states.notempty())) {
            boolean finished = false;
            do {
                Uid uid = UidHelper.unpackFrom(states);
                if (uid.notEquals(Uid.nullUid())) {
                    SubordinationManager.getTransactionImporter().recoverTransaction(uid);
                } else {
                    finished = true;
                }
            } while (!finished);
        }
    } catch (ObjectStoreException | XAException | IOException e) {
        e.printStackTrace();
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) Uid(com.arjuna.ats.arjuna.common.Uid) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) XAException(javax.transaction.xa.XAException) IOException(java.io.IOException) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore)

Example 74 with ObjectStoreException

use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.

the class GenericRecoveryCoordinator method replay_completion.

/**
 * Respond to a replay_completion request for the RecoveryCoordinator
 * identified by parameter id.
 */
protected static Status replay_completion(RecoveryCoordinatorId id, Resource res) throws SystemException, NotPrepared {
    if (jtsLogger.logger.isDebugEnabled()) {
        jtsLogger.logger.debug("GenericRecoveryCoordinator(" + id._RCUid + ").replay_completion(" + (res != null ? "resource supplied)" : "null resource)"));
    }
    Status currentStatus = Status.StatusUnknown;
    /* 
	 * First check to see if the transaction is active by asking the 
	 * per-process contact.
	 * If alive, return the status reported by the
	 * transaction.  If not alive then try and recover the
	 * transaction from the intentions list.  
	 */
    boolean transactionActive = true;
    try {
        currentStatus = get_status(id._actionUid, id._originalProcessUid);
    } catch (Inactive e) {
        // original process is dead.
        transactionActive = false;
    }
    if (currentStatus == Status.StatusNoTransaction) {
        /*
	     * There is no intentions list, so the transaction either
	     * committed or rolled back. However, this routine is only
	     * ever called by replay_completion, which means that there
	     * is a resource (hopefully one which was participating in
	     * the transaction) that is in doubt as to the
	     * transaction's outcome. If the transaction had committed,
	     * then this resource would know of the outcome. Therefore,
	     * it must have rolled back!
	     */
        /*
	     * Unfortunately the last statement is wrong. There is a timing
	     * issue here: the resource recovery may be doing an upcall while
	     * the downcall (from coordinator recovery) is going on and
	     * removing the log. What can then happen is that a resource may
	     * see a commit folled by a rollback.
	     */
        currentStatus = Status.StatusRolledBack;
    }
    if (!transactionActive) {
        // original process is dead, so reasonable for us to try to
        // recover
        /*
	     * The RecoveredTransactionReplayer is a threaded object
	     * so we can get the status and return it while the
	     * replayer does the phase 2 commit in a new thread.  
	     */
        String tranType = ((id._isServerTransaction) ? ServerTransaction.typeName() : ArjunaTransactionImple.typeName());
        try {
            if (id._isServerTransaction && (StoreManager.getRecoveryStore().currentState(id._actionUid, ServerTransaction.typeName() + "/JCA") != StateStatus.OS_UNKNOWN)) {
                tranType = tranType + "/JCA";
            }
        } catch (ObjectStoreException e) {
        // Can't read store
        }
        com.arjuna.ats.internal.jts.recovery.transactions.RecoveredTransactionReplayer replayer = new com.arjuna.ats.internal.jts.recovery.transactions.RecoveredTransactionReplayer(id._actionUid, tranType);
        // this will cause the activatation attempt
        currentStatus = replayer.getStatus();
        if ((replayer.getRecoveryStatus() != com.arjuna.ats.internal.jts.recovery.transactions.RecoveryStatus.ACTIVATE_FAILED) && (res != null)) {
            if (jtsLogger.logger.isDebugEnabled()) {
                jtsLogger.logger.debug("GenericRecoveryCoordinator - swapping Resource for RC " + id._RCUid);
            }
            replayer.swapResource(id._RCUid, res);
        }
        if (replayer.getRecoveryStatus() != com.arjuna.ats.internal.jts.recovery.transactions.RecoveryStatus.ACTIVATE_FAILED) {
            replayer.replayPhase2();
        } else {
            replayer.tidyup();
            /*
		 * The transaction didn't activate so we have a
		 * rollback situation but we can't rollback the
		 * resource that we have been given through the
		 * intentions list but we can issue rollback
		 * directly. This is configurable through the System
		 * properties.
		 */
            currentStatus = Status.StatusRolledBack;
        }
    }
    if (currentStatus == Status.StatusRolledBack) {
        if (_issueRecoveryRollback) {
            ResourceCompletor resourceCompletor = new ResourceCompletor(res, ResourceCompletor.ROLLBACK);
            resourceCompletor.start();
        }
    }
    if (currentStatus == Status.StatusActive)
        throw new NotPrepared();
    return currentStatus;
}
Also used : StateStatus(com.arjuna.ats.arjuna.objectstore.StateStatus) Status(org.omg.CosTransactions.Status) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) ResourceCompletor(com.arjuna.ats.internal.jts.recovery.recoverycoordinators.ResourceCompletor) NotPrepared(org.omg.CosTransactions.NotPrepared) Inactive(org.omg.CosTransactions.Inactive)

Example 75 with ObjectStoreException

use of com.arjuna.ats.arjuna.exceptions.ObjectStoreException in project narayana by jbosstm.

the class FactoryContactItem method restoreMe.

private boolean restoreMe() {
    try {
        InputObjectState objstate = getStore().read_committed(_uid, _pseudoTypeName);
        if (// not in object store any more
        objstate == null)
            return false;
        if (restore_state(objstate)) {
            return true;
        }
        jtsLogger.i18NLogger.warn_recovery_contact_FactoryContactItem_5();
    } catch (ObjectStoreException exo) {
        // this shouldn't happen, because we shouldn't be looking for a factory
        // that was never recorded
        jtsLogger.i18NLogger.warn_recovery_contact_FactoryContactItem_6();
    }
    return false;
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Aggregations

ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)87 IOException (java.io.IOException)44 Uid (com.arjuna.ats.arjuna.common.Uid)35 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)34 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)23 File (java.io.File)11 Connection (java.sql.Connection)9 PreparedStatement (java.sql.PreparedStatement)9 SQLException (java.sql.SQLException)9 NamingException (javax.naming.NamingException)9 Enumeration (java.util.Enumeration)8 RecoveryStore (com.arjuna.ats.arjuna.objectstore.RecoveryStore)6 FileNotFoundException (java.io.FileNotFoundException)5 ResultSet (java.sql.ResultSet)5 ArrayList (java.util.ArrayList)5 ParticipantStore (com.arjuna.ats.arjuna.objectstore.ParticipantStore)4 XidImple (com.arjuna.ats.jta.xa.XidImple)4 RandomAccessFile (java.io.RandomAccessFile)3 SyncFailedException (java.io.SyncFailedException)3 Statement (java.sql.Statement)3