Search in sources :

Example 31 with State

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

the class ParticipantCompletionCoordinatorEngine method close.

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

Example 32 with State

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

the class ParticipantCompletionCoordinatorEngine method cancel.

/**
 * Handle the cancel event.
 * @return The state.
 *
 * Active -> Canceling
 * Canceling -> Canceling
 * 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-Compensating -> Failing-Compensating (invalid state)
 * NotCompleting -> NotCompleting (invalid state)
 * Exiting -> Exiting (invalid state)
 * Ended -> Ended (invalid state)
 */
public State cancel() {
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass() + ".cancel");
    }
    State current;
    synchronized (this) {
        current = state;
        if (current == State.STATE_ACTIVE) {
            changeState(State.STATE_CANCELING);
        }
    }
    if ((current == State.STATE_ACTIVE) || (current == State.STATE_CANCELING)) {
        sendCancel();
        current = waitForState(State.STATE_CANCELING, TransportTimer.getTransportTimeout());
    }
    if (WSTLogger.logger.isTraceEnabled()) {
        WSTLogger.logger.trace(getClass() + ".cancel. State: " + current);
    }
    if (current == State.STATE_ENDED && failureState != null) {
        return failureState;
    }
    return current;
}
Also used : State(com.arjuna.webservices11.wsba.State)

Example 33 with State

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

the class ParticipantEngine method rollback.

/**
 * Handle the rollback event.
 * @param rollback The rollback notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 *
 * None -> None (send aborted)
 * Active -> Aborting (execute rollback, send aborted and forget)
 * Preparing -> Aborting (execute rollback, send aborted and forget)
 * PreparedSuccess -> Aborting (execute rollback, send aborted and forget)
 * Committing -> Committing (ignore)
 * Aborting -> Aborting (send aborted and forget)
 */
public void rollback(final Notification rollback, final MAP map, final ArjunaContext arjunaContext) {
    final State current;
    synchronized (this) {
        current = state;
        if ((current == State.STATE_ACTIVE) || (current == State.STATE_PREPARING) || (current == State.STATE_PREPARED_SUCCESS)) {
            state = State.STATE_ABORTING;
        }
    }
    if ((current == State.STATE_ACTIVE) || (current == State.STATE_PREPARING) || (current == State.STATE_PREPARED_SUCCESS)) {
        if (!executeRollback()) {
            synchronized (this) {
                state = current;
            }
            return;
        }
        if (persisted && participant instanceof Durable2PCParticipant) {
            // here in the hope that we have better luck next time..
            if (!XTSATRecoveryManager.getRecoveryManager().deleteParticipantRecoveryRecord(id)) {
                // hmm, could not delete entry -- leave it so we can maybe retry later
                WSTLogger.i18NLogger.warn_wst11_messaging_engines_ParticipantEngine_rollback_1(id);
            }
        }
        sendAborted();
        forget();
    } else if (current != State.STATE_ABORTING) {
        sendAborted();
    }
}
Also used : State(com.arjuna.webservices11.wsat.State)

Example 34 with State

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

the class ParticipantEngine method commitDecision.

/**
 * Handle the commit decision event.
 *
 * Preparing -> PreparedSuccess (send Prepared)
 * Committing -> null (send committed and forget)
 */
private void commitDecision() {
    State current;
    boolean rollbackRequired = false;
    boolean deleteRequired = false;
    synchronized (this) {
        current = state;
    }
    if (current == State.STATE_PREPARING) {
        // and send aborted.
        if (participant instanceof Durable2PCParticipant) {
            // write a durable participant recovery record to the persistent store
            Durable2PCParticipant durableParticipant = (Durable2PCParticipant) participant;
            ATParticipantRecoveryRecord recoveryRecord = new ATParticipantRecoveryRecord(id, durableParticipant, coordinator);
            if (!XTSATRecoveryManager.getRecoveryManager().writeParticipantRecoveryRecord(recoveryRecord)) {
                // we need to rollback and send aborted unless some other thread
                // gets there first
                rollbackRequired = true;
            }
        }
        synchronized (this) {
            current = state;
            if (current == State.STATE_PREPARING) {
                if (rollbackRequired) {
                    // if we change state to aborting then we are responsible for
                    // calling rollback and sending aborted but we have no log record
                    // to delete
                    state = State.STATE_ABORTING;
                } else {
                    state = State.STATE_PREPARED_SUCCESS;
                    // this ensures any subsequent commit or rollback deletes the log record
                    // so we still have no log record to delete here
                    persisted = true;
                }
            } else if (!rollbackRequired) {
                // an incoming rollback or readonly changed the state to aborted or null so
                // it will already have performed a rollback if required but we need to
                // delete the log record since the rollback/readonly thread did not know
                // about it
                deleteRequired = true;
            }
        }
        if (rollbackRequired) {
            // we need to do the rollback and send aborted
            executeRollback();
            sendAborted();
            forget();
        } else if (deleteRequired) {
            if (!XTSATRecoveryManager.getRecoveryManager().deleteParticipantRecoveryRecord(id)) {
                // hmm, could not delete entry log warning
                WSTLogger.i18NLogger.warn_wst11_messaging_engines_ParticipantEngine_commitDecision_2(id);
            }
        } else {
            // whew got through -- send a prepared
            sendPrepared();
        }
    } else if (current == State.STATE_COMMITTING) {
        if (persisted && participant instanceof Durable2PCParticipant) {
            // remove any durable participant recovery record from the persistent store
            Durable2PCParticipant durableParticipant = (Durable2PCParticipant) participant;
            // here in the hope that we have better luck next time.
            if (!XTSATRecoveryManager.getRecoveryManager().deleteParticipantRecoveryRecord(id)) {
                // hmm, could not delete entry -- log a warning
                WSTLogger.i18NLogger.warn_wst11_messaging_engines_ParticipantEngine_commitDecision_3(id);
                synchronized (this) {
                    state = State.STATE_PREPARED_SUCCESS;
                }
                return;
            }
        }
        sendCommitted();
        forget();
    }
}
Also used : ATParticipantRecoveryRecord(org.jboss.jbossts.xts11.recovery.participant.at.ATParticipantRecoveryRecord) State(com.arjuna.webservices11.wsat.State)

Example 35 with State

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

the class ParticipantEngine method soapFault.

/**
 * Handle the soap fault event.
 * @param soapFault The soap fault.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public void soapFault(final SoapFault soapFault, final MAP map, final ArjunaContext arjunaContext) {
    if (WSTLogger.logger.isTraceEnabled()) {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
        final SoapFaultType soapFaultType = soapFault.getSoapFaultType();
        final QName subCode = soapFault.getSubcode();
        WSTLogger.logger.tracev("Unexpected SOAP fault for participant {0}: {1} {2}", new Object[] { instanceIdentifier, soapFaultType, subCode });
    }
    QName subcode = soapFault.getSubcode();
    if (CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_STATE_QNAME.equals(subcode) || AtomicTransactionConstants.WSAT_ERROR_CODE_INCONSISTENT_INTERNAL_STATE_QNAME.equals(subcode) || AtomicTransactionConstants.WSAT_ERROR_CODE_UNKNOWN_TRANSACTION_QNAME.equals(subcode)) {
        final SoapFaultType soapFaultType = soapFault.getSoapFaultType();
        final QName subCode = soapFault.getSubcode();
        WSTLogger.i18NLogger.error_wst11_messaging_engines_ParticipantEngine_soapFault_2(id, soapFaultType.toString(), subCode);
        // unrecoverable error -- forget this participant and delete any persistent
        // record of it
        final State current;
        synchronized (this) {
            current = state;
            state = null;
        }
        if (current == State.STATE_PREPARED_SUCCESS && AtomicTransactionConstants.WSAT_ERROR_CODE_UNKNOWN_TRANSACTION_QNAME.equals(subcode)) {
            // we need to tell this participant to roll back
            executeRollback();
        }
        if (persisted && participant instanceof Durable2PCParticipant) {
            // remove any durable participant recovery record from the persistent store
            Durable2PCParticipant durableParticipant = (Durable2PCParticipant) participant;
            // if we cannot delete the participant we record an error here
            if (!XTSATRecoveryManager.getRecoveryManager().deleteParticipantRecoveryRecord(id)) {
                // hmm, could not delete entry -- log an error
                WSTLogger.i18NLogger.error_wst11_messaging_engines_ParticipantEngine_soapFault_3(id);
            }
        }
        forget();
    }
}
Also used : SoapFaultType(com.arjuna.webservices.SoapFaultType) QName(javax.xml.namespace.QName) State(com.arjuna.webservices11.wsat.State) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier)

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