Search in sources :

Example 11 with State

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

the class CoordinatorCompletionCoordinatorEngine method close.

/**
 * Handle the close event.
 * @return The state.
 *
 * Active -> Active (invalid state)
 * Canceling-Active -> Canceling-Active (invalid state)
 * Canceling-Completing -> Canceling-Completing (invalid state)
 * Completing -> Completing (invalid state)
 * Completed -> Closing
 * Closing -> Closing
 * 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)
 * NotCompleting -> NotCompleting (invalid state)
 * Exiting -> Exiting (invalid state)
 * Ended -> Ended (invalid state)
 */
public State close() {
    State current;
    synchronized (this) {
        current = state;
        if (current == State.STATE_COMPLETED) {
            changeState(State.STATE_CLOSING);
        }
    }
    if (current == State.STATE_COMPLETED) {
        sendClose();
        waitForState(State.STATE_CLOSING, TransportTimer.getTransportTimeout());
    }
    synchronized (this) {
        if (state != State.STATE_CLOSING) {
            if (recovered) {
                CoordinatorCompletionCoordinatorProcessor.getProcessor().deactivateCoordinator(this);
            }
            if (state == State.STATE_ENDED && failureState != null) {
                return failureState;
            }
            return state;
        } else {
            // timeout -- leave participant in place as this TX will get retried later
            return State.STATE_CLOSING;
        }
    }
}
Also used : State(com.arjuna.webservices11.wsba.State)

Example 12 with State

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

the class CoordinatorCompletionCoordinatorEngine method getStatus.

/**
 * Handle the getStatus event.
 * @param getStatus The getStatus notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public void getStatus(final NotificationType getStatus, final MAP map, final ArjunaContext arjunaContext) {
    final State current;
    synchronized (this) {
        current = state;
    }
    sendStatus(current);
}
Also used : State(com.arjuna.webservices11.wsba.State)

Example 13 with State

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

the class CoordinatorCompletionCoordinatorEngine method complete.

/**
 * Handle the complete event.
 * @return The state.
 *
 * Active -> Completing
 * Canceling-Active -> Canceling-Active (invalid state)
 * Canceling-Completing -> Canceling-Completing (invalid state)
 * Completing -> Completing
 * Completed -> Completed (invalid state)
 * 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)
 * NotCompleting -> NotCompleting (invalid state)
 * Exiting -> Exiting (invalid state)
 * Ended -> Ended (invalid state)
 */
public State complete() {
    final State current;
    synchronized (this) {
        current = state;
        if (current == State.STATE_ACTIVE) {
            changeState(State.STATE_COMPLETING);
        }
    }
    if (current == State.STATE_ACTIVE) {
        sendComplete();
        waitForState(State.STATE_COMPLETING, TransportTimer.getTransportTimeout());
    }
    synchronized (this) {
        if (state == State.STATE_ENDED && failureState != null) {
            return failureState;
        }
        return state;
    }
}
Also used : State(com.arjuna.webservices11.wsba.State)

Example 14 with State

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

the class ParticipantCompletionCoordinatorProcessorImpl 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 ParticipantCompletionCoordinatorInboundEvents 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_ParticipantCompletionCoordinatorProcessorImpl_getStatus_4());
            AddressingHelper.installNoneReplyTo(faultMAP);
            ParticipantCompletionParticipantClient.getClient().sendSoapFault(soapFault, null, faultMAP, getFaultAction());
        } catch (final Throwable th) {
            WSTLogger.i18NLogger.info_wst11_messaging_ParticipantCompletionCoordinatorProcessorImpl_getStatus_3(instanceIdentifier.toString(), th);
        }
    }
}
Also used : ParticipantCompletionCoordinatorInboundEvents(com.arjuna.webservices11.wsba.ParticipantCompletionCoordinatorInboundEvents) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SoapFault11(com.arjuna.webservices11.SoapFault11) MAP(org.jboss.ws.api.addressing.MAP)

Example 15 with State

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

the class ParticipantCompletionParticipantEngine method executeCompensate.

/**
 * Execute the compensate transition.
 */
private void executeCompensate() {
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass().getSimpleName() + ".executeCompensate. Participant: " + participant);
    }
    try {
        participant.compensate();
    } catch (final FaultedException fe) {
        WSTLogger.i18NLogger.warn_messaging_engines_ParticipantCompletionParticipantEngine_executeCompensate_1(fe);
        if (WSTLogger.logger.isTraceEnabled()) {
            WSTLogger.logger.tracev(fe, "Faulted exception from participant compensate for WS-BA participant");
        }
        // fail here because the participant doesn't want to retry the compensate
        fail(BusinessActivityConstants.WSBA_ELEMENT_FAIL_QNAME);
        return;
    } catch (final Throwable th) {
        final State current;
        synchronized (this) {
            current = state;
            if (current == State.STATE_COMPENSATING) {
                changeState(State.STATE_COMPLETED);
            }
        }
        if (current == State.STATE_COMPENSATING) {
            initiateTimer();
        }
        WSTLogger.i18NLogger.warn_messaging_engines_ParticipantCompletionParticipantEngine_executeCompensate_2(th);
        if (WSTLogger.logger.isTraceEnabled()) {
            WSTLogger.logger.tracev(th, "Unexpected exception from participant compensate for WS-BA participant");
        }
        return;
    }
    final State current;
    boolean failRequired = false;
    synchronized (this) {
        current = state;
        if (current == State.STATE_COMPENSATING) {
            if (persisted) {
                if (!XTSBARecoveryManager.getRecoveryManager().deleteParticipantRecoveryRecord(id)) {
                    // we have to fail since we don't want to run the compensate method again
                    WSTLogger.i18NLogger.warn_wst11_messaging_engines_ParticipantCompletionParticipantEngine_executeCompensate_3(id);
                    failRequired = true;
                    changeState(State.STATE_FAILING_COMPENSATING);
                }
            }
            // we will send the compensate after we exit the synchronized block
            if (!failRequired) {
                ended();
            }
        }
    }
    if (failRequired) {
        fail(BusinessActivityConstants.WSBA_ELEMENT_FAIL_QNAME);
    } else if (current == State.STATE_COMPENSATING) {
        sendCompensated();
    }
}
Also used : State(com.arjuna.webservices11.wsba.State) FaultedException(com.arjuna.wst.FaultedException)

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