*/
package org.opendaylight.controller.cluster.access.client;
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.cluster.access.concepts.RequestException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class ReconnectingClientConnection<T extends BackendInfo> extends AbstractReceivingClientConnection<T> {
private static final Logger LOG = LoggerFactory.getLogger(ReconnectingClientConnection.class);
- ReconnectingClientConnection(final ConnectedClientConnection<T> oldConnection) {
+ private RequestException cause;
+
+ ReconnectingClientConnection(final ConnectedClientConnection<T> oldConnection, final RequestException cause) {
super(oldConnection);
+ this.cause = Preconditions.checkNotNull(cause);
}
@Override
- ClientActorBehavior<T> lockedReconnect(final ClientActorBehavior<T> current) {
- // Intentional no-op
- LOG.debug("Skipping reconnect of already-reconnecting connection {}", this);
+ 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
+ ClientActorBehavior<T> lockedReconnect(final ClientActorBehavior<T> current, final RequestException cause) {
+ this.cause = Preconditions.checkNotNull(cause);
+ LOG.warn("Skipping reconnect of already-reconnecting connection {}", this);
return current;
}
+
+ @Override
+ RequestException enrichPoison(final RequestException ex) {
+ if (ex.getCause() != null) {
+ ex.addSuppressed(cause);
+ } else {
+ ex.initCause(cause);
+ }
+
+ return ex;
+ }
+
}