Search in sources :

Example 1 with IncrementTransactionSequenceSuccess

use of org.opendaylight.controller.cluster.access.commands.IncrementTransactionSequenceSuccess in project controller by opendaylight.

the class FrontendTransaction method handleRequest.

// Request order has already been checked by caller and replaySequence()
@SuppressWarnings("checkstyle:IllegalCatch")
@Nullable
final TransactionSuccess<?> handleRequest(final TransactionRequest<?> request, final RequestEnvelope envelope, final long now) throws RequestException {
    if (request instanceof IncrementTransactionSequenceRequest) {
        final IncrementTransactionSequenceRequest incr = (IncrementTransactionSequenceRequest) request;
        expectedSequence += incr.getIncrement();
        return recordSuccess(incr.getSequence(), new IncrementTransactionSequenceSuccess(incr.getTarget(), incr.getSequence()));
    }
    if (previousFailure != null) {
        LOG.debug("{}: Rejecting request {} due to previous failure", persistenceId(), request, previousFailure);
        throw previousFailure;
    }
    try {
        return doHandleRequest(request, envelope, now);
    } catch (RuntimeException e) {
        /*
             * The request failed to process, we should not attempt to ever
             * apply it again. Furthermore we cannot accept any further requests
             * from this connection, simply because the transaction state is
             * undefined.
             */
        LOG.debug("{}: Request {} failed to process", persistenceId(), request, e);
        previousFailure = new RuntimeRequestException("Request " + request + " failed to process", e);
        throw previousFailure;
    }
}
Also used : IncrementTransactionSequenceSuccess(org.opendaylight.controller.cluster.access.commands.IncrementTransactionSequenceSuccess) IncrementTransactionSequenceRequest(org.opendaylight.controller.cluster.access.commands.IncrementTransactionSequenceRequest) RuntimeRequestException(org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException) Nullable(javax.annotation.Nullable)

Aggregations

Nullable (javax.annotation.Nullable)1 IncrementTransactionSequenceRequest (org.opendaylight.controller.cluster.access.commands.IncrementTransactionSequenceRequest)1 IncrementTransactionSequenceSuccess (org.opendaylight.controller.cluster.access.commands.IncrementTransactionSequenceSuccess)1 RuntimeRequestException (org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException)1