Fixup Sonar issues
[controller.git] / opendaylight / md-sal / cds-access-client / src / main / java / org / opendaylight / controller / cluster / access / client / ReconnectForwarder.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 static java.util.Objects.requireNonNull;
11
12 /**
13  * Forwarder class responsible for routing requests from the previous connection incarnation back to the originator,
14  * which can then convert them as appropriate.
15  *
16  * @author Robert Varga
17  */
18 public abstract class ReconnectForwarder {
19     // Visible for subclass method handle
20     private final AbstractReceivingClientConnection<?> successor;
21
22     protected ReconnectForwarder(final AbstractReceivingClientConnection<?> successor) {
23         this.successor = requireNonNull(successor);
24     }
25
26     protected final void sendToSuccessor(final ConnectionEntry entry) {
27         successor.sendRequest(entry.getRequest(), entry.getCallback());
28     }
29
30     protected final void replayToSuccessor(final ConnectionEntry entry) {
31         successor.enqueueRequest(entry.getRequest(), entry.getCallback(), entry.getEnqueuedTicks());
32     }
33
34     protected abstract void forwardEntry(ConnectionEntry entry, long now);
35
36     protected abstract void replayEntry(ConnectionEntry entry, long now);
37
38     final AbstractReceivingClientConnection<?> successor() {
39         return successor;
40     }
41 }