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 com.google.common.base.Preconditions;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
15 * Forwarder class responsible for routing requests from the previous connection incarnation back to the originator,
16 * which can then convert them as appropriate.
18 * @author Robert Varga
20 public abstract class ReconnectForwarder {
21 static final Logger LOG = LoggerFactory.getLogger(ReconnectForwarder.class);
22 // Visible for subclass method handle
23 private final AbstractReceivingClientConnection<?> successor;
25 protected ReconnectForwarder(final AbstractReceivingClientConnection<?> successor) {
26 this.successor = Preconditions.checkNotNull(successor);
29 protected final void sendToSuccessor(final ConnectionEntry entry) {
30 successor.sendRequest(entry.getRequest(), entry.getCallback());
33 protected final void replayToSuccessor(final ConnectionEntry entry) {
34 successor.enqueueRequest(entry.getRequest(), entry.getCallback(), entry.getEnqueuedTicks());
37 protected abstract void forwardEntry(ConnectionEntry entry, long now);
39 protected abstract void replayEntry(ConnectionEntry entry, long now);
41 final AbstractReceivingClientConnection<?> successor() {