2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.access.client;
10 import static java.util.Objects.requireNonNull;
12 import org.opendaylight.controller.cluster.access.concepts.RequestException;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
17 * An {@link AbstractClientConnection} which is being reconnected after having timed out.
19 * @author Robert Varga
21 * @param <T> {@link BackendInfo} type
23 public final class ReconnectingClientConnection<T extends BackendInfo> extends AbstractReceivingClientConnection<T> {
24 private static final Logger LOG = LoggerFactory.getLogger(ReconnectingClientConnection.class);
26 private RequestException cause;
28 ReconnectingClientConnection(final ConnectedClientConnection<T> oldConnection, final RequestException cause) {
30 this.cause = requireNonNull(cause);
34 long backendSilentTicks(final long now) {
35 // We do not want to reconnect this connection, as we need the timer to to keep running
40 @SuppressWarnings("checkstyle:hiddenField")
41 ClientActorBehavior<T> lockedReconnect(final ClientActorBehavior<T> current, final RequestException cause) {
42 this.cause = requireNonNull(cause);
43 LOG.warn("Skipping reconnect of already-reconnecting connection {}", this);
48 RequestException enrichPoison(final RequestException ex) {
49 if (ex.getCause() != null) {
50 ex.addSuppressed(cause);