Search in sources :

Example 21 with RecoveryStore

use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.

the class RecoverAtomicActionTest method test.

@Test
public void test() {
    RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
    OutputObjectState fluff = new OutputObjectState();
    Uid kungfuTx = new Uid();
    boolean passed = false;
    final String tn = new AtomicAction().type();
    try {
        UidHelper.packInto(kungfuTx, fluff);
        System.err.println("Creating dummy log");
        recoveryStore.write_committed(kungfuTx, tn, fluff);
        if (recoveryStore.currentState(kungfuTx, tn) == StateStatus.OS_COMMITTED) {
            System.err.println("Wrote dummy transaction " + kungfuTx);
            RecoverAtomicAction rAA = new RecoverAtomicAction(kungfuTx, ActionStatus.COMMITTED);
            if (!rAA.activate()) {
                rAA.replayPhase2();
                if (recoveryStore.currentState(kungfuTx, tn) == StateStatus.OS_UNKNOWN)
                    passed = true;
            }
        } else
            System.err.println("State is not committed!");
    } catch (final Exception ex) {
        ex.printStackTrace();
    }
    assertTrue(passed);
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) AtomicAction(com.arjuna.ats.arjuna.AtomicAction) RecoverAtomicAction(com.arjuna.ats.arjuna.recovery.RecoverAtomicAction) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) RecoverAtomicAction(com.arjuna.ats.arjuna.recovery.RecoverAtomicAction) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore) Test(org.junit.Test)

Example 22 with RecoveryStore

use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.

the class JTATransactionLogXAResourceOrphanFilter method transactionLog.

/**
 * Is there a log file for this transaction?
 *
 * @param xid the transaction to check.
 *
 * @return <code>boolean</code>true if there is a log file,
 *         <code>false</code> if there isn't.
 * @throws ObjectStoreException If there is a problem accessing the object store
 * @throws IOException In case the data from the object store is corrupted
 */
private boolean transactionLog(Xid xid) throws ObjectStoreException, IOException {
    RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
    String transactionType = new AtomicAction().type();
    XidImple theXid = new XidImple(xid);
    Uid u = theXid.getTransactionUid();
    if (jtaLogger.logger.isDebugEnabled()) {
        jtaLogger.logger.debug("Checking whether Xid " + theXid + " exists in ObjectStore.");
    }
    if (!u.equals(Uid.nullUid())) {
        if (jtaLogger.logger.isDebugEnabled()) {
            jtaLogger.logger.debug("Looking for " + u + " and " + transactionType);
        }
        if (containsCommitMarkableResourceRecord(u) || recoveryStore.currentState(u, transactionType) != StateStatus.OS_UNKNOWN) {
            if (jtaLogger.logger.isDebugEnabled()) {
                jtaLogger.logger.debug("Found record for " + theXid);
            }
            return true;
        } else {
            if (jtaLogger.logger.isDebugEnabled()) {
                jtaLogger.logger.debug("No record found for " + theXid);
            }
        }
    } else {
        jtaLogger.i18NLogger.info_recovery_notaxid(XAHelper.xidToString(xid));
    }
    return false;
}
Also used : XidImple(com.arjuna.ats.jta.xa.XidImple) AtomicAction(com.arjuna.ats.internal.jta.transaction.arjunacore.AtomicAction) Uid(com.arjuna.ats.arjuna.common.Uid) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore)

Example 23 with RecoveryStore

use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.

the class SubordinateAtomicActionRecoveryModule method periodicWorkFirstPass.

@Override
public void periodicWorkFirstPass() {
    /*
         * Requires going through the objectstore for the states of imported
         * transactions - this is just to make sure the server control are loaded into memory.
         *
         * The EIS will call XATerminator::recover() for actual crash recovery
         */
    RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
    InputObjectState states = new InputObjectState();
    // only look in the JCA section of the object store
    Uid uid = null;
    try {
        if (recoveryStore.allObjUids(SubordinateAtomicAction.getType(), states) && (states.notempty())) {
            while (true) {
                uid = UidHelper.unpackFrom(states);
                if (uid.notEquals(Uid.nullUid())) {
                    SubordinationManager.getTransactionImporter().recoverTransaction(uid);
                } else {
                    break;
                }
            }
        }
        recoveryScanCompletedWithoutError = true;
    } catch (ObjectStoreException | XAException | IOException e) {
        jtaLogger.i18NLogger.warn_could_not_recover_subordinate(uid, e);
        recoveryScanCompletedWithoutError = false;
    }
    if (!validatePosition()) {
        recoveryScanCompletedWithoutError = false;
    }
}
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 24 with RecoveryStore

use of com.arjuna.ats.arjuna.objectstore.RecoveryStore in project narayana by jbosstm.

the class CommitMarkableResourceRecordRecoveryModule method moveRecord.

private void moveRecord(Uid uid, String from, String to) throws ObjectStoreException {
    RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
    InputObjectState state = recoveryStore.read_committed(uid, from);
    if (state != null) {
        if (!recoveryStore.write_committed(uid, to, new OutputObjectState(state))) {
            tsLogger.logger.error("Could not move an: " + to + " uid: " + uid);
        } else if (!recoveryStore.remove_committed(uid, from)) {
            tsLogger.logger.error("Could not remove a: " + from + " uid: " + uid);
        }
    } else {
        tsLogger.logger.error("Could not read an: " + from + " uid: " + uid);
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore)

Example 25 with RecoveryStore

use of com.arjuna.ats.arjuna.objectstore.RecoveryStore 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)

Aggregations

RecoveryStore (com.arjuna.ats.arjuna.objectstore.RecoveryStore)29 Uid (com.arjuna.ats.arjuna.common.Uid)27 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)23 IOException (java.io.IOException)10 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)9 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)8 Test (org.junit.Test)7 XAException (javax.transaction.xa.XAException)5 SubordinateAtomicAction (com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.SubordinateAtomicAction)4 XidImple (com.arjuna.ats.jta.xa.XidImple)3 Stack (java.util.Stack)3 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)2 LogStore (com.arjuna.ats.internal.arjuna.objectstore.LogStore)2 UnexpectedConditionException (com.arjuna.ats.jta.exceptions.UnexpectedConditionException)2 UnknownHostException (java.net.UnknownHostException)2 HashSet (java.util.HashSet)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)2 HeuristicCommitException (javax.transaction.HeuristicCommitException)2 HeuristicMixedException (javax.transaction.HeuristicMixedException)2