Allow AbstractClientActor generation to start from non-zero
[controller.git] / opendaylight / md-sal / cds-access-client / src / main / java / org / opendaylight / controller / cluster / access / client / ReconnectForwarder.java
index 37dc2f1c4d19142ed5fa06a0d7bee70d27633d50..8217b72861ea6f9c58f4af47ea9f229c52f902ee 100644 (file)
@@ -7,12 +7,7 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
-import com.google.common.base.Preconditions;
-import java.util.function.Consumer;
-import org.opendaylight.controller.cluster.access.concepts.Request;
-import org.opendaylight.controller.cluster.access.concepts.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static java.util.Objects.requireNonNull;
 
 /**
  * Forwarder class responsible for routing requests from the previous connection incarnation back to the originator,
@@ -21,19 +16,24 @@ import org.slf4j.LoggerFactory;
  * @author Robert Varga
  */
 public abstract class ReconnectForwarder {
-    static final Logger LOG = LoggerFactory.getLogger(ReconnectForwarder.class);
     // Visible for subclass method handle
     private final AbstractReceivingClientConnection<?> successor;
 
     protected ReconnectForwarder(final AbstractReceivingClientConnection<?> successor) {
-        this.successor = Preconditions.checkNotNull(successor);
+        this.successor = requireNonNull(successor);
     }
 
-    protected final void sendToSuccessor(final Request<?, ?> request, final Consumer<Response<?, ?>> callback) {
-        successor.sendRequest(request, callback);
+    protected final void sendToSuccessor(final ConnectionEntry entry) {
+        successor.sendRequest(entry.getRequest(), entry.getCallback());
     }
 
-    protected abstract void forwardEntry(ConnectionEntry entry);
+    protected final void replayToSuccessor(final ConnectionEntry entry) {
+        successor.enqueueRequest(entry.getRequest(), entry.getCallback(), entry.getEnqueuedTicks());
+    }
+
+    protected abstract void forwardEntry(ConnectionEntry entry, long now);
+
+    protected abstract void replayEntry(ConnectionEntry entry, long now);
 
     final AbstractReceivingClientConnection<?> successor() {
         return successor;