Search in sources :

Example 1 with Participant

use of org.jboss.narayana.rest.integration.api.Participant in project narayana by jbosstm.

the class RecoveryManager method recreateParticipant.

private Participant recreateParticipant(final InputObjectState inputObjectState, final String applicationId) throws IOException {
    final ParticipantDeserializer deserializer = deserializers.get(applicationId);
    final byte[] participantBytes = inputObjectState.unpackBytes();
    Participant participant = deserializer.recreate(participantBytes);
    if (participant == null) {
        final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(participantBytes);
        final ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
        participant = deserializer.deserialize(objectInputStream);
    }
    return participant;
}
Also used : Participant(org.jboss.narayana.rest.integration.api.Participant) PersistableParticipant(org.jboss.narayana.rest.integration.api.PersistableParticipant) ByteArrayInputStream(java.io.ByteArrayInputStream) ParticipantDeserializer(org.jboss.narayana.rest.integration.api.ParticipantDeserializer) ObjectInputStream(java.io.ObjectInputStream)

Example 2 with Participant

use of org.jboss.narayana.rest.integration.api.Participant in project narayana by jbosstm.

the class RecoveryManager method recreateParticipantInformation.

private ParticipantInformation recreateParticipantInformation(final RecoveryStore recoveryStore, final Uid uid) throws ObjectStoreException, IOException {
    final InputObjectState inputObjectState = recoveryStore.read_committed(uid, PARTICIPANT_INFORMATION_RECORD_TYPE);
    final String id = inputObjectState.unpackString();
    if (ParticipantsContainer.getInstance().getParticipantInformation(id) != null) {
        // Participant is already loaded.
        return null;
    }
    final String applicationId = inputObjectState.unpackString();
    if (!deserializers.containsKey(applicationId)) {
        // There is no appropriate deserializer.
        return null;
    }
    final String status = inputObjectState.unpackString();
    final String recoveryUrl = inputObjectState.unpackString();
    final Participant participant = recreateParticipant(inputObjectState, applicationId);
    if (participant == null) {
        // Deserializer failed to recreate participant.
        return null;
    }
    final ParticipantInformation participantInformation = new ParticipantInformation(id, applicationId, recoveryUrl, participant, status);
    if (!synchronizeParticipantUrlWithCoordinator(participantInformation)) {
        try {
            participant.rollback();
            removeParticipantInformation(participantInformation);
        // TODO is it OK to leave participant not rolled back in case of Exception?
        } catch (HeuristicException e) {
            LOG.warn(e.getMessage(), e);
        } catch (ParticipantException e) {
            LOG.warn(e.getMessage(), e);
        }
        return null;
    }
    return participantInformation;
}
Also used : InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) HeuristicException(org.jboss.narayana.rest.integration.api.HeuristicException) Participant(org.jboss.narayana.rest.integration.api.Participant) PersistableParticipant(org.jboss.narayana.rest.integration.api.PersistableParticipant) ParticipantException(org.jboss.narayana.rest.integration.api.ParticipantException)

Aggregations

Participant (org.jboss.narayana.rest.integration.api.Participant)2 PersistableParticipant (org.jboss.narayana.rest.integration.api.PersistableParticipant)2 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 HeuristicException (org.jboss.narayana.rest.integration.api.HeuristicException)1 ParticipantDeserializer (org.jboss.narayana.rest.integration.api.ParticipantDeserializer)1 ParticipantException (org.jboss.narayana.rest.integration.api.ParticipantException)1