Search in sources :

Example 1 with RetiredGenerationException

use of org.opendaylight.controller.cluster.access.concepts.RetiredGenerationException in project controller by opendaylight.

the class ClientActorBehavior method internalOnRequestFailure.

private ClientActorBehavior<T> internalOnRequestFailure(final FailureEnvelope command) {
    final AbstractClientConnection<T> conn = getConnection(command);
    if (conn != null) {
        /*
             * We are talking to multiple actors, which may be lagging behind our state significantly. This has
             * the effect that we may be receiving responses from a previous connection after we have created a new
             * one to a different actor.
             *
             * Since we are already replaying requests to the new actor, we want to ignore errors reported on the old
             * connection -- for example NotLeaderException, which must not cause a new reconnect. Check the envelope's
             * sessionId and if it does not match our current connection just ignore it.
             */
        final Optional<T> optBackend = conn.getBackendInfo();
        if (optBackend.isPresent() && optBackend.get().getSessionId() != command.getSessionId()) {
            LOG.debug("{}: Mismatched current connection {} and envelope {}, ignoring response", persistenceId(), conn, command);
            return this;
        }
    }
    final RequestFailure<?, ?> failure = command.getMessage();
    final RequestException cause = failure.getCause();
    if (cause instanceof RetiredGenerationException) {
        LOG.error("{}: current generation {} has been superseded", persistenceId(), getIdentifier(), cause);
        haltClient(cause);
        poison(cause);
        return null;
    }
    if (cause instanceof NotLeaderException) {
        if (conn instanceof ReconnectingClientConnection) {
            // Already reconnecting, do not churn the logs
            return this;
        } else if (conn != null) {
            LOG.info("{}: connection {} indicated no leadership, reconnecting it", persistenceId(), conn, cause);
            return conn.reconnect(this, cause);
        }
    }
    if (cause instanceof OutOfSequenceEnvelopeException) {
        if (conn instanceof ReconnectingClientConnection) {
            // Already reconnecting, do not churn the logs
            return this;
        } else if (conn != null) {
            LOG.info("{}: connection {} indicated sequencing mismatch on {} sequence {} ({}), reconnecting it", persistenceId(), conn, failure.getTarget(), failure.getSequence(), command.getTxSequence(), cause);
            return conn.reconnect(this, cause);
        }
    }
    return onRequestFailure(command);
}
Also used : NotLeaderException(org.opendaylight.controller.cluster.access.commands.NotLeaderException) OutOfSequenceEnvelopeException(org.opendaylight.controller.cluster.access.commands.OutOfSequenceEnvelopeException) RuntimeRequestException(org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException) RequestException(org.opendaylight.controller.cluster.access.concepts.RequestException) RetiredGenerationException(org.opendaylight.controller.cluster.access.concepts.RetiredGenerationException)

Aggregations

NotLeaderException (org.opendaylight.controller.cluster.access.commands.NotLeaderException)1 OutOfSequenceEnvelopeException (org.opendaylight.controller.cluster.access.commands.OutOfSequenceEnvelopeException)1 RequestException (org.opendaylight.controller.cluster.access.concepts.RequestException)1 RetiredGenerationException (org.opendaylight.controller.cluster.access.concepts.RetiredGenerationException)1 RuntimeRequestException (org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException)1