Search in sources :

Example 6 with State

use of com.arjuna.webservices11.wsba.State 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 7 with State

use of com.arjuna.webservices11.wsba.State in project narayana by jbosstm.

the class CoordinatorCompletionParticipantEngine method failed.

/**
 * Handle the failed event.
 * @param failed The failed notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 *
 * Active -> Active (invalid state)
 * Canceling -> Canceling (invalid state)
 * Completing -> Completing (invalid state)
 * Completed -> Completed (invalid state)
 * Closing -> Closing (invalid state)
 * Compensating -> Compensating (invalid state)
 * Failing-Active -> Ended
 * Failing-Canceling -> Ended
 * Failing-Completing -> Ended
 * Failing-Compensating -> Ended
 * NotCompleting -> NotCompleting (invalid state)
 * Exiting -> Exiting (invalid state)
 * Ended -> Ended
 */
public void failed(final NotificationType failed, final MAP map, final ArjunaContext arjunaContext) {
    final State current;
    boolean deleteRequired = false;
    synchronized (this) {
        current = state;
        if ((current == State.STATE_FAILING_ACTIVE) || (current == State.STATE_FAILING_CANCELING) || (current == State.STATE_FAILING_COMPLETING) || (current == State.STATE_FAILING_COMPENSATING)) {
            deleteRequired = persisted;
        }
    }
    if (deleteRequired) {
        if (!XTSBARecoveryManager.getRecoveryManager().deleteParticipantRecoveryRecord(id)) {
            // hmm, could not delete entry -- nothing more we can do than log a message
            WSTLogger.i18NLogger.warn_wst11_messaging_engines_CoordinatorCompletionParticipantEngine_failed_1(id);
        }
    }
    // now we have removed the log record we can safely get rid of the participant
    if ((current == State.STATE_FAILING_ACTIVE) || (current == State.STATE_FAILING_CANCELING) || (current == State.STATE_FAILING_COMPLETING) || (current == State.STATE_FAILING_COMPENSATING)) {
        ended();
    }
}
Also used : State(com.arjuna.webservices11.wsba.State)

Example 8 with State

use of com.arjuna.webservices11.wsba.State in project narayana by jbosstm.

the class CoordinatorCompletionCoordinatorProcessorImpl method getStatus.

/**
 * Get Status.
 * @param getStatus The get status notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public void getStatus(final NotificationType getStatus, final MAP map, final ArjunaContext arjunaContext) {
    final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
    final CoordinatorCompletionCoordinatorInboundEvents coordinator = getCoordinator(instanceIdentifier);
    if (coordinator != null) {
        try {
            coordinator.getStatus(getStatus, map, arjunaContext);
        } catch (final Throwable th) {
            if (WSTLogger.logger.isTraceEnabled()) {
                WSTLogger.logger.tracev("Unexpected exception thrown from getStatus:", th);
            }
        }
    } else if (!areRecoveryLogEntriesAccountedFor()) {
        if (WSTLogger.logger.isTraceEnabled()) {
            WSTLogger.logger.tracev("GetStatus dropped for unknown coordinator completion participant {0} while waiting on recovery scan", new Object[] { instanceIdentifier });
        }
    } else {
        if (WSTLogger.logger.isTraceEnabled()) {
            WSTLogger.logger.tracev("GetStatus called on unknown coordinator: {0}", new Object[] { instanceIdentifier });
        }
        // send an invalid state fault
        final String messageId = MessageId.getMessageId();
        final MAP faultMAP = AddressingHelper.createFaultContext(map, messageId);
        try {
            final SoapFault11 soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_STATE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_CoordinatorCompletionCoordinatorProcessorImpl_getStatus_4());
            CoordinatorCompletionParticipantClient.getClient().sendSoapFault(soapFault, null, faultMAP, getFaultAction());
        } catch (final Throwable th) {
            WSTLogger.i18NLogger.info_wst11_messaging_CoordinatorCompletionCoordinatorProcessorImpl_getStatus_3(instanceIdentifier.toString(), th);
        }
    }
}
Also used : InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SoapFault11(com.arjuna.webservices11.SoapFault11) MAP(org.jboss.ws.api.addressing.MAP) CoordinatorCompletionCoordinatorInboundEvents(com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents)

Example 9 with State

use of com.arjuna.webservices11.wsba.State in project narayana by jbosstm.

the class ParticipantCompletionParticipantProcessorImpl method getStatus.

/**
 * Get Status.
 * @param getStatus The get status notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public void getStatus(final NotificationType getStatus, final MAP map, final ArjunaContext arjunaContext) {
    final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
    final ParticipantCompletionParticipantInboundEvents participant = getParticipant(instanceIdentifier);
    if (participant != null) {
        try {
            participant.getStatus(getStatus, map, arjunaContext);
        } catch (final Throwable th) {
            if (WSTLogger.logger.isTraceEnabled()) {
                WSTLogger.logger.tracev("Unexpected exception thrown from getStatus:", th);
            }
        }
    } else {
        if (WSTLogger.logger.isTraceEnabled()) {
            WSTLogger.logger.tracev("GetStatus called on unknown participant: {0}", new Object[] { instanceIdentifier });
        }
        // send an invalid state fault
        final String messageId = MessageId.getMessageId();
        final MAP faultMAP = AddressingHelper.createFaultContext(map, messageId);
        try {
            final SoapFault11 soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_STATE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_ParticipantCompletionParticipantProcessorImpl_getStatus_4());
            ParticipantCompletionCoordinatorClient.getClient().sendSoapFault(soapFault, null, faultMAP, getFaultAction());
        } catch (final Throwable th) {
            WSTLogger.i18NLogger.info_wst11_messaging_ParticipantCompletionParticipantProcessorImpl_getStatus_3(instanceIdentifier.toString(), th);
        }
    }
}
Also used : ParticipantCompletionParticipantInboundEvents(com.arjuna.webservices11.wsba.ParticipantCompletionParticipantInboundEvents) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SoapFault11(com.arjuna.webservices11.SoapFault11) MAP(org.jboss.ws.api.addressing.MAP)

Example 10 with State

use of com.arjuna.webservices11.wsba.State in project narayana by jbosstm.

the class CoordinatorCompletionCoordinatorEngine method sendInvalidStateFault.

/**
 * Send the invalid state fault message.
 */
private void sendInvalidStateFault() {
    final MAP map = createContext();
    try {
        final SoapFault11 soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_STATE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_engines_CoordinatorCompletionCoordinatorEngine_sendInvalidStateFault_2());
        CoordinatorCompletionParticipantClient.getClient().sendSoapFault(soapFault, participant, map, getFaultAction());
    } catch (final Throwable th) {
        if (WSTLogger.logger.isTraceEnabled()) {
            WSTLogger.logger.tracev("Unexpected exception while sending InvalidStateFault", th);
        }
    }
}
Also used : SoapFault11(com.arjuna.webservices11.SoapFault11) MAP(org.jboss.ws.api.addressing.MAP)

Aggregations

State (com.arjuna.webservices11.wsba.State)31 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)12 MAP (org.jboss.ws.api.addressing.MAP)12 State (com.arjuna.webservices11.wsat.State)11 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)10 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)6 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)6 Test (org.junit.Test)6 SoapFault11 (com.arjuna.webservices11.SoapFault11)5 QName (javax.xml.namespace.QName)5 ConfirmCompletedParticipant (com.arjuna.wst11.ConfirmCompletedParticipant)3 StringReader (java.io.StringReader)3 StringWriter (java.io.StringWriter)3 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)3 StreamSource (javax.xml.transform.stream.StreamSource)3 BAParticipantRecoveryRecord (org.jboss.jbossts.xts11.recovery.participant.ba.BAParticipantRecoveryRecord)3 FaultedException (com.arjuna.wst.FaultedException)2 CoordinatorCompletionCoordinatorDetails (com.arjuna.wst.tests.arq.TestCoordinatorCompletionCoordinatorProcessor.CoordinatorCompletionCoordinatorDetails)2 ParticipantCompletionCoordinatorDetails (com.arjuna.wst.tests.arq.TestParticipantCompletionCoordinatorProcessor.ParticipantCompletionCoordinatorDetails)2