Search in sources :

Example 1 with ConfirmCompletedParticipant

use of com.arjuna.wst11.ConfirmCompletedParticipant in project narayana by jbosstm.

the class CoordinatorCompletionParticipantEngine method executeComplete.

/**
 * Execute the complete transition.
 */
private void executeComplete() {
    try {
        participant.complete();
    } catch (final Throwable th) {
        WSTLogger.i18NLogger.warn_messaging_engines_CoordinatorCompletionParticipantEngine_executeComplete_1(th);
        if (WSTLogger.logger.isTraceEnabled()) {
            WSTLogger.logger.tracev(th, "Unexpected exception from participant complete for WS-BA participant");
        }
        return;
    }
    State current;
    boolean failRequired = false;
    boolean deleteRequired = false;
    boolean confirm = (participant instanceof ConfirmCompletedParticipant);
    synchronized (this) {
        current = state;
    }
    if (current == State.STATE_COMPLETING) {
        // ok we need to write the participant details to disk because it has just completed
        BAParticipantRecoveryRecord recoveryRecord = new BAParticipantRecoveryRecord(id, participant, false, coordinator);
        if (!XTSBARecoveryManager.getRecoveryManager().writeParticipantRecoveryRecord(recoveryRecord)) {
            // hmm, could not write entry log warning
            WSTLogger.i18NLogger.warn_wst11_messaging_engines_CoordinatorCompletionParticipantEngine_executeComplete_2(id);
            // we need to fail this transaction
            failRequired = true;
        }
    }
    synchronized (this) {
        current = state;
        if (current == State.STATE_COMPLETING) {
            if (!failRequired) {
                changeState(State.STATE_COMPLETED);
                // record the fact that we have persisted this object so later operations will delete
                // the log record
                persisted = true;
                // sent back and we cannot allow that until after the confirm
                if (confirm) {
                    ((ConfirmCompletedParticipant) participant).confirmCompleted(true);
                }
            } else {
                // we must force a fail but we don't have a log record to delete
                changeState(State.STATE_FAILING_COMPLETING);
            }
        } else {
            // we cannot force a fail now so just delete
            failRequired = false;
            // we need to delete the log record here as the cancel would not have known it was persisted
            deleteRequired = true;
        }
    }
    if (failRequired) {
        current = fail(BusinessActivityConstants.WSBA_ELEMENT_FAIL_QNAME);
        // we can safely do this now
        if (confirm) {
            ((ConfirmCompletedParticipant) participant).confirmCompleted(false);
        }
    } else if (deleteRequired) {
        if (!XTSBARecoveryManager.getRecoveryManager().deleteParticipantRecoveryRecord(id)) {
            // hmm, could not delete entry log warning
            WSTLogger.i18NLogger.warn_wst11_messaging_engines_ParticipantCompletionParticipantEngine_completed_2(id);
        }
        if (confirm) {
            ((ConfirmCompletedParticipant) participant).confirmCompleted(false);
        }
    } else if (current == State.STATE_COMPLETING) {
        sendCompleted();
    }
}
Also used : ConfirmCompletedParticipant(com.arjuna.wst11.ConfirmCompletedParticipant) State(com.arjuna.webservices11.wsba.State) BAParticipantRecoveryRecord(org.jboss.jbossts.xts11.recovery.participant.ba.BAParticipantRecoveryRecord)

Example 2 with ConfirmCompletedParticipant

use of com.arjuna.wst11.ConfirmCompletedParticipant in project narayana by jbosstm.

the class CoordinatorCompletionParticipantEngine method completed.

/**
 * Handle the completed event.
 *
 * Active -> Active (invalid state)
 * Canceling -> Canceling (invalid state)
 * Completing -> Completed
 * Completed -> Completed
 * Closing -> Closing (invalid state)
 * Compensating -> Compensating (invalid state)
 * Failing-Active -> Failing-Active (invalid state)
 * Failing-Canceling -> Failing-Canceling (invalid state)
 * Failing-Completing -> Failing-Completing (invalid state)
 * Failing-Compensating -> Failing-Compensating (invalid state)
 * Exiting -> Exiting (invalid state)
 * NotCompleting -> NotCompleting (invalid state)
 * Ended -> Ended (invalid state)
 */
public State completed() {
    // TODO -- check. not sure this can or should ever be called for a coordinator completion participant
    State current;
    boolean failRequired = false;
    boolean deleteRequired = false;
    boolean confirm = (participant instanceof ConfirmCompletedParticipant);
    synchronized (this) {
        current = state;
    }
    if (current == State.STATE_COMPLETING) {
        // ok we need to write the participant details to disk because it has just completed
        BAParticipantRecoveryRecord recoveryRecord = new BAParticipantRecoveryRecord(id, participant, false, coordinator);
        if (!XTSBARecoveryManager.getRecoveryManager().writeParticipantRecoveryRecord(recoveryRecord)) {
            // hmm, could not write entry log warning
            WSTLogger.i18NLogger.warn_wst11_messaging_engines_ParticipantCompletionParticipantEngine_completed_1(id);
            // we need to fail this transaction
            failRequired = true;
        }
    }
    synchronized (this) {
        current = state;
        if (current == State.STATE_COMPLETING) {
            if (!failRequired) {
                changeState(State.STATE_COMPLETED);
                // record the fact that we have persisted this object so later operations will delete
                // the log record
                persisted = true;
                // sent back and we cannot allow that until after the confirm
                if (confirm) {
                    ((ConfirmCompletedParticipant) participant).confirmCompleted(true);
                }
            } else {
                // we must force a fail but we don't have a log record to delete
                changeState(State.STATE_FAILING_COMPLETING);
            }
        } else {
            // we need to delete the log record here as the cancel would not have known it was persisted
            deleteRequired = true;
        }
    }
    if (failRequired) {
        current = fail(BusinessActivityConstants.WSBA_ELEMENT_FAIL_QNAME);
        // we can safely do this now
        if (confirm) {
            ((ConfirmCompletedParticipant) participant).confirmCompleted(false);
        }
    } else if (deleteRequired) {
        if (!XTSBARecoveryManager.getRecoveryManager().deleteParticipantRecoveryRecord(id)) {
            // hmm, could not delete entry log warning
            WSTLogger.i18NLogger.warn_wst11_messaging_engines_ParticipantCompletionParticipantEngine_completed_2(id);
        }
        // we can safely do this now
        if (confirm) {
            ((ConfirmCompletedParticipant) participant).confirmCompleted(false);
        }
    } else if ((current == State.STATE_COMPLETING) || (current == State.STATE_COMPLETED)) {
        sendCompleted();
    }
    return current;
}
Also used : ConfirmCompletedParticipant(com.arjuna.wst11.ConfirmCompletedParticipant) State(com.arjuna.webservices11.wsba.State) BAParticipantRecoveryRecord(org.jboss.jbossts.xts11.recovery.participant.ba.BAParticipantRecoveryRecord)

Example 3 with ConfirmCompletedParticipant

use of com.arjuna.wst11.ConfirmCompletedParticipant in project narayana by jbosstm.

the class ParticipantCompletionParticipantEngine method completed.

/**
 * Handle the completed event.
 *
 * Active -> Completed
 * Canceling -> Canceling (invalid state)
 * Completed -> Completed
 * Closing -> Closing (invalid state)
 * Compensating -> Compensating (invalid state)
 * Failing-Active -> Failing-Active (invalid state)
 * Failing-Canceling -> Failing-Canceling (invalid state)
 * Failing-Compensating -> Failing-Compensating (invalid state)
 * NotCompleting -> NotCompleting (invalid state)
 * Exiting -> Exiting (invalid state)
 * Ended -> Ended (invalid state)
 */
public State completed() {
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass().getSimpleName() + ".completed");
    }
    State current;
    boolean failRequired = false;
    boolean deleteRequired = false;
    boolean confirm = (participant instanceof ConfirmCompletedParticipant);
    synchronized (this) {
        current = state;
        if (current == State.STATE_ACTIVE) {
            // ok we need to write the participant details to disk because it has just completed
            BAParticipantRecoveryRecord recoveryRecord = new BAParticipantRecoveryRecord(id, participant, true, coordinator);
            if (XTSBARecoveryManager.getRecoveryManager().writeParticipantRecoveryRecord(recoveryRecord)) {
                changeState(State.STATE_COMPLETED);
                persisted = true;
                // sent back and we cannot allow that until after the confirm
                if (confirm) {
                    ((ConfirmCompletedParticipant) participant).confirmCompleted(true);
                }
            } else {
                // hmm, could not write entry log warning
                WSTLogger.i18NLogger.warn_wst11_messaging_engines_ParticipantCompletionParticipantEngine_completed_1(id);
                // we need to fail this transaction
                failRequired = true;
            }
        }
    }
    if (failRequired) {
        current = fail(BusinessActivityConstants.WSBA_ELEMENT_FAIL_QNAME);
        // we can safely do this now
        if (confirm) {
            ((ConfirmCompletedParticipant) participant).confirmCompleted(false);
        }
    } else if ((current == State.STATE_ACTIVE) || (current == State.STATE_COMPLETED)) {
        sendCompleted();
    }
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass().getSimpleName() + ".completed. State: " + current);
    }
    return current;
}
Also used : ConfirmCompletedParticipant(com.arjuna.wst11.ConfirmCompletedParticipant) State(com.arjuna.webservices11.wsba.State) BAParticipantRecoveryRecord(org.jboss.jbossts.xts11.recovery.participant.ba.BAParticipantRecoveryRecord)

Aggregations

State (com.arjuna.webservices11.wsba.State)3 ConfirmCompletedParticipant (com.arjuna.wst11.ConfirmCompletedParticipant)3 BAParticipantRecoveryRecord (org.jboss.jbossts.xts11.recovery.participant.ba.BAParticipantRecoveryRecord)3