X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcds-access-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fclient%2FReconnectingClientConnection.java;h=e63e7253bcf9b66731e78dc5c698a9d1ab879215;hb=2be60a19ed99fe7d33a24f7db8af3510f7ea835f;hp=e15a949600f4f932c96fc83e1d77a5eb296de1c6;hpb=b604e392408dfbf46ee0a7e1ac4cd27170a83bff;p=controller.git diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ReconnectingClientConnection.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ReconnectingClientConnection.java index e15a949600..e63e7253bc 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ReconnectingClientConnection.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ReconnectingClientConnection.java @@ -7,10 +7,9 @@ */ package org.opendaylight.controller.cluster.access.client; -import akka.actor.ActorRef; -import java.util.Map.Entry; -import org.opendaylight.controller.cluster.access.concepts.Request; -import org.opendaylight.controller.cluster.access.concepts.RequestEnvelope; +import static java.util.Objects.requireNonNull; + +import org.opendaylight.controller.cluster.access.concepts.RequestException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,25 +23,36 @@ import org.slf4j.LoggerFactory; public final class ReconnectingClientConnection extends AbstractReceivingClientConnection { private static final Logger LOG = LoggerFactory.getLogger(ReconnectingClientConnection.class); - ReconnectingClientConnection(final ConnectedClientConnection oldConnection) { + private RequestException cause; + + ReconnectingClientConnection(final ConnectedClientConnection oldConnection, final RequestException cause) { super(oldConnection); + this.cause = requireNonNull(cause); } @Override - ClientActorBehavior reconnectConnection(final ClientActorBehavior current) { - // Intentional no-op - LOG.debug("Skipping reconnect of already-reconnecting connection {}", this); - return current; + long backendSilentTicks(final long now) { + // We do not want to reconnect this connection, as we need the timer to to keep running + return 0; } @Override - Entry prepareForTransmit(final Request req) { - // This is guarded by remoteMaxMessages() == 0 - throw new UnsupportedOperationException("Attempted to transmit on a reconnecting connection"); + @SuppressWarnings("checkstyle:hiddenField") + ClientActorBehavior lockedReconnect(final ClientActorBehavior current, final RequestException cause) { + this.cause = requireNonNull(cause); + LOG.warn("Skipping reconnect of already-reconnecting connection {}", this); + return current; } @Override - int remoteMaxMessages() { - return 0; + RequestException enrichPoison(final RequestException ex) { + if (ex.getCause() != null) { + ex.addSuppressed(cause); + } else { + ex.initCause(cause); + } + + return ex; } + }