BUG-8403: fix DONE state propagation
[controller.git] / opendaylight / md-sal / cds-access-client / src / main / java / org / opendaylight / controller / cluster / access / client / ReconnectingClientConnection.java
index e15a949600f4f932c96fc83e1d77a5eb296de1c6..b59c9e324ae96b73cf28dc568a1147c3603dc3ee 100644 (file)
@@ -7,10 +7,8 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
-import akka.actor.ActorRef;
-import java.util.Map.Entry;
-import org.opendaylight.controller.cluster.access.concepts.Request;
-import org.opendaylight.controller.cluster.access.concepts.RequestEnvelope;
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.cluster.access.concepts.RequestException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -24,25 +22,29 @@ import org.slf4j.LoggerFactory;
 public final class ReconnectingClientConnection<T extends BackendInfo> extends AbstractReceivingClientConnection<T> {
     private static final Logger LOG = LoggerFactory.getLogger(ReconnectingClientConnection.class);
 
-    ReconnectingClientConnection(final ConnectedClientConnection<T> oldConnection) {
+    private RequestException cause;
+
+    ReconnectingClientConnection(final ConnectedClientConnection<T> oldConnection, final RequestException cause) {
         super(oldConnection);
+        this.cause = Preconditions.checkNotNull(cause);
     }
 
     @Override
-    ClientActorBehavior<T> reconnectConnection(final ClientActorBehavior<T> current) {
-        // Intentional no-op
+    ClientActorBehavior<T> lockedReconnect(final ClientActorBehavior<T> current, final RequestException cause) {
+        this.cause = Preconditions.checkNotNull(cause);
         LOG.debug("Skipping reconnect of already-reconnecting connection {}", this);
         return current;
     }
 
     @Override
-    Entry<ActorRef, RequestEnvelope> prepareForTransmit(final Request<?, ?> req) {
-        // This is guarded by remoteMaxMessages() == 0
-        throw new UnsupportedOperationException("Attempted to transmit on a reconnecting connection");
-    }
+    RequestException enrichPoison(final RequestException ex) {
+        if (ex.getCause() != null) {
+            ex.addSuppressed(cause);
+        } else {
+            ex.initCause(cause);
+        }
 
-    @Override
-    int remoteMaxMessages() {
-        return 0;
+        return ex;
     }
+
 }