BUG-5280: refactor AbstractClientConnection
[controller.git] / opendaylight / md-sal / cds-access-client / src / main / java / org / opendaylight / controller / cluster / access / client / ReconnectingClientConnection.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.cluster.access.client;
9
10 import akka.actor.ActorRef;
11 import java.util.Map.Entry;
12 import org.opendaylight.controller.cluster.access.concepts.Request;
13 import org.opendaylight.controller.cluster.access.concepts.RequestEnvelope;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 /**
18  * An {@link AbstractClientConnection} which is being reconnected after having timed out.
19  *
20  * @author Robert Varga
21  *
22  * @param <T> {@link BackendInfo} type
23  */
24 public final class ReconnectingClientConnection<T extends BackendInfo> extends AbstractReceivingClientConnection<T> {
25     private static final Logger LOG = LoggerFactory.getLogger(ReconnectingClientConnection.class);
26
27     ReconnectingClientConnection(final ConnectedClientConnection<T> oldConnection) {
28         super(oldConnection);
29     }
30
31     @Override
32     ClientActorBehavior<T> reconnectConnection(final ClientActorBehavior<T> current) {
33         // Intentional no-op
34         LOG.debug("Skipping reconnect of already-reconnecting connection {}", this);
35         return current;
36     }
37
38     @Override
39     Entry<ActorRef, RequestEnvelope> prepareForTransmit(final Request<?, ?> req) {
40         // This is guarded by remoteMaxMessages() == 0
41         throw new UnsupportedOperationException("Attempted to transmit on a reconnecting connection");
42     }
43
44     @Override
45     int remoteMaxMessages() {
46         return 0;
47     }
48 }