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 akka.actor.ActorRef;
11 import com.google.common.annotations.Beta;
12 import java.util.AbstractMap.SimpleImmutableEntry;
13 import java.util.Map.Entry;
14 import javax.annotation.concurrent.NotThreadSafe;
15 import org.opendaylight.controller.cluster.access.concepts.Request;
16 import org.opendaylight.controller.cluster.access.concepts.RequestEnvelope;
20 public final class ConnectedClientConnection<T extends BackendInfo> extends AbstractReceivingClientConnection<T> {
21 public ConnectedClientConnection(final ClientActorContext context, final Long cookie, final T backend) {
22 super(context, cookie, backend);
26 ClientActorBehavior<T> reconnectConnection(final ClientActorBehavior<T> current) {
27 final ReconnectingClientConnection<T> next = new ReconnectingClientConnection<>(this);
28 setForwarder(new SimpleReconnectForwarder(next));
29 current.reconnectConnection(this, next);
34 int remoteMaxMessages() {
35 return backend().getMaxMessages();
39 Entry<ActorRef, RequestEnvelope> prepareForTransmit(final Request<?, ?> req) {
40 return new SimpleImmutableEntry<>(backend().getActor(), new RequestEnvelope(
41 req.toVersion(backend().getVersion()), backend().getSessionId(), nextTxSequence()));