Search in sources :

Example 16 with State

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

the class ParticipantCompletionParticipantEngine 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) {
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass().getSimpleName() + ".getStatus");
    }
    final State current;
    synchronized (this) {
        current = state;
    }
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass().getSimpleName() + ".getStatus. State: " + current);
    }
    sendStatus(current);
}
Also used : State(com.arjuna.webservices11.wsba.State)

Example 17 with State

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

the class ParticipantCompletionParticipantEngine 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)
 * Completed -> Completed (invalid state)
 * Closing -> Closing (invalid state)
 * Compensating -> Compensating (invalid state)
 * Failing-Active -> Ended
 * Failing-Canceling -> 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) {
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass().getSimpleName() + ".failed");
    }
    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_COMPENSATING)) {
            deleteRequired = persisted;
        }
    }
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass().getSimpleName() + ".failed. State: " + current);
    }
    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_ParticipantCompletionParticipantEngine_failed_1(id);
        }
    }
    // now the log record has been deleted we can safely end this participant
    if ((current == State.STATE_FAILING_ACTIVE) || (current == State.STATE_FAILING_CANCELING) || (current == State.STATE_FAILING_COMPENSATING)) {
        ended();
    }
}
Also used : State(com.arjuna.webservices11.wsba.State)

Example 18 with State

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

the class BusinessAgreementWithCoordinatorCompletionStub method restoreState.

public boolean restoreState(final InputObjectState ios) {
    try {
        final String id = ios.unpackString();
        final String eprValue = ios.unpackString();
        final XMLStreamReader reader = SoapUtils.getXMLStreamReader(new StringReader(eprValue));
        StreamHelper.checkNextStartTag(reader, QNAME_BACCWS_PARTICIPANT);
        String eprefText = reader.getElementText();
        StreamSource source = new StreamSource(new StringReader(eprefText));
        final W3CEndpointReference endpointReference = new W3CEndpointReference(source);
        String ns = ios.unpackString();
        final String localPart = ios.unpackString();
        String prefix = ios.unpackString();
        if ("".equals(ns)) {
            ns = null;
        }
        if ("".equals(prefix)) {
            prefix = null;
        }
        QName statename = new QName(ns, localPart, prefix);
        State state = State.toState11(statename);
        // if we already have an engine from a previous recovery scan or because
        // we had a heuristic outcome then reuse it with luck it will have been committed
        // or aborted between the last scan and this one
        // note that whatever happens it will not have been removed from the table
        // because it is marked as recovered
        participant = (CoordinatorCompletionCoordinatorEngine) CoordinatorCompletionCoordinatorProcessor.getProcessor().getCoordinator(id);
        if (participant == null) {
            participant = new CoordinatorCompletionCoordinatorEngine(id, endpointReference, state, true);
        }
        return true;
    } catch (final Throwable th) {
        WSTLogger.i18NLogger.error_wst11_stub_BusinessAgreementWithCoordinatorCompletionStub_3(th);
        return false;
    }
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) CoordinatorCompletionCoordinatorEngine(com.arjuna.wst11.messaging.engines.CoordinatorCompletionCoordinatorEngine) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) QName(javax.xml.namespace.QName) State(com.arjuna.webservices11.wsba.State) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader)

Example 19 with State

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

the class ParticipantCompletionCoordinatorEngine method status.

/**
 * Handle the status event.
 * @param status The status.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public void status(final StatusType status, final MAP map, final ArjunaContext arjunaContext) {
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass() + ".status");
    }
    // TODO - is this correct?
    final State current;
    synchronized (this) {
        current = state;
    }
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass() + ".status. State: " + current);
    }
    sendStatus(current);
}
Also used : State(com.arjuna.webservices11.wsba.State)

Example 20 with State

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

the class ParticipantCompletionCoordinatorEngine method compensate.

/**
 * Handle the compensate event.
 * @return The state.
 *
 * Active -> Active (invalid state)
 * Canceling -> Canceling (invalid state)
 * Completed -> Compensating
 * Closing -> Closing (invalid state)
 * Compensating -> Compensating
 * 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 compensate() {
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass() + ".compensate");
    }
    State current;
    synchronized (this) {
        current = state;
        if (current == State.STATE_COMPLETED) {
            changeState(State.STATE_COMPENSATING);
        }
    }
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass() + ".compensate. State: " + current);
    }
    if ((current == State.STATE_COMPLETED) || (current == State.STATE_COMPENSATING)) {
        sendCompensate();
        waitForState(State.STATE_COMPENSATING, TransportTimer.getTransportTimeout());
    }
    synchronized (this) {
        if (state != State.STATE_COMPENSATING) {
            if (recovered) {
                ParticipantCompletionCoordinatorProcessor.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_COMPENSATING;
        }
    }
}
Also used : State(com.arjuna.webservices11.wsba.State)

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