Search in sources :

Example 1 with RecoveryStore

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

the class BaseTest method readObjectStoreRecord.

protected static OSRecordHolder readObjectStoreRecord(String type) {
    try {
        RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
        InputObjectState states = new InputObjectState();
        if (recoveryStore.allObjUids(type, states) && states.notempty()) {
            Uid uid = UidHelper.unpackFrom(states);
            if (uid.notEquals(Uid.nullUid())) {
                InputObjectState ios = recoveryStore.read_committed(uid, type);
                return new OSRecordHolder(uid, type, ios);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) Uid(com.arjuna.ats.arjuna.common.Uid) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore) WebApplicationException(javax.ws.rs.WebApplicationException) IOException(java.io.IOException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) HttpResponseException(org.jboss.jbossts.star.provider.HttpResponseException)

Example 2 with RecoveryStore

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

the class BaseTest method clearObjectStore.

private static void clearObjectStore(String type) {
    try {
        RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
        InputObjectState states = new InputObjectState();
        if (recoveryStore.allObjUids(type, states) && states.notempty()) {
            boolean finished = false;
            do {
                Uid uid = UidHelper.unpackFrom(states);
                if (uid.notEquals(Uid.nullUid())) {
                    recoveryStore.remove_committed(uid, type);
                } else {
                    finished = true;
                }
            } while (!finished);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) Uid(com.arjuna.ats.arjuna.common.Uid) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore) WebApplicationException(javax.ws.rs.WebApplicationException) IOException(java.io.IOException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) HttpResponseException(org.jboss.jbossts.star.provider.HttpResponseException)

Example 3 with RecoveryStore

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

the class RecoveryManager method recoverParticipants.

private void recoverParticipants() {
    if (ParticipantsManagerFactory.getInstance().getBaseUrl() != null) {
        final RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
        final InputObjectState states = new InputObjectState();
        try {
            if (recoveryStore.allObjUids(PARTICIPANT_INFORMATION_RECORD_TYPE, states)) {
                Uid uid;
                while ((uid = UidHelper.unpackFrom(states)).notEquals(Uid.nullUid())) {
                    final ParticipantInformation participantInformation = recreateParticipantInformation(recoveryStore, uid);
                    if (participantInformation != null) {
                        ParticipantsContainer.getInstance().addParticipantInformation(participantInformation.getId(), participantInformation);
                    }
                }
            }
        } catch (ObjectStoreException e) {
            LOG.warn(e.getMessage(), e);
        } catch (IOException e) {
            LOG.warn(e.getMessage(), e);
        }
    } else {
        LOG.warn("Participants cannot be loaded from the object store, because base URL was not set.");
    }
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) Uid(com.arjuna.ats.arjuna.common.Uid) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException) IOException(java.io.IOException) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore)

Example 4 with RecoveryStore

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

the class RecoveryManager method persistParticipantInformation.

public void persistParticipantInformation(final ParticipantInformation participantInformation) {
    if (LOG.isTraceEnabled()) {
        LOG.trace("RecoveryManager.persistParticipantInformation: participantInformation=" + participantInformation);
    }
    if (!isRecoverableParticipant(participantInformation.getParticipant())) {
        if (LOG.isTraceEnabled()) {
            LOG.trace("RecoveryManager.persistParticipantInformation: participant is not recoverable");
        }
        return;
    }
    try {
        final RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
        final OutputObjectState state = getParticipantInformationOutputState(participantInformation);
        final Uid uid = new Uid(participantInformation.getId());
        recoveryStore.write_committed(uid, PARTICIPANT_INFORMATION_RECORD_TYPE, state);
    } catch (Exception e) {
        LOG.warn("Failure while persisting participant information.", e);
    }
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore) ParticipantException(org.jboss.narayana.rest.integration.api.ParticipantException) HeuristicException(org.jboss.narayana.rest.integration.api.HeuristicException) IOException(java.io.IOException) ObjectStoreException(com.arjuna.ats.arjuna.exceptions.ObjectStoreException)

Example 5 with RecoveryStore

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

the class InboundBridgeRecoveryModule method getUidsToRecover.

/**
 * Returns UIDs of JTA subordinate transactions with format id specified in inbound bridge class which were found in
 * transaction log.
 *
 * @return Set<Uid>
 */
private Set<Uid> getUidsToRecover() {
    if (LOG.isTraceEnabled()) {
        LOG.trace("InboundBridgeRecoveryModule.getUidsToRecover");
    }
    final Set<Uid> uids = new HashSet<Uid>();
    try {
        final RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
        final InputObjectState states = new InputObjectState();
        // Only look in the JCA section of the object store
        if (recoveryStore.allObjUids(SubordinateAtomicAction.getType(), states) && states.notempty()) {
            boolean finished = false;
            do {
                final Uid uid = UidHelper.unpackFrom(states);
                if (uid.notEquals(Uid.nullUid())) {
                    final SubordinateAtomicAction saa = new SubordinateAtomicAction(uid, true);
                    if (saa.getXid().getFormatId() == InboundBridge.XARESOURCE_FORMAT_ID) {
                        uids.add(uid);
                    }
                } else {
                    finished = true;
                }
            } while (!finished);
        }
    } catch (Exception e) {
        LOG.warn(e.getMessage(), e);
    }
    return uids;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) SubordinateAtomicAction(com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.SubordinateAtomicAction) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore) XAException(javax.transaction.xa.XAException) HashSet(java.util.HashSet)

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