Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / cds-access-client / src / main / java / org / opendaylight / controller / cluster / access / client / ReconnectingClientConnection.java
index 0aac7f46637fc49716ca094ce46bc42baca1a4b0..e63e7253bcf9b66731e78dc5c698a9d1ab879215 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
+import static java.util.Objects.requireNonNull;
+
+import org.opendaylight.controller.cluster.access.concepts.RequestException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -20,14 +23,36 @@ 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 = requireNonNull(cause);
+    }
+
+    @Override
+    long backendSilentTicks(final long now) {
+        // We do not want to reconnect this connection, as we need the timer to to keep running
+        return 0;
     }
 
     @Override
-    ClientActorBehavior<T> lockedReconnect(final ClientActorBehavior<T> current) {
-        // Intentional no-op
-        LOG.debug("Skipping reconnect of already-reconnecting connection {}", this);
+    @SuppressWarnings("checkstyle:hiddenField")
+    ClientActorBehavior<T> lockedReconnect(final ClientActorBehavior<T> current, final RequestException cause) {
+        this.cause = requireNonNull(cause);
+        LOG.warn("Skipping reconnect of already-reconnecting connection {}", this);
         return current;
     }
+
+    @Override
+    RequestException enrichPoison(final RequestException ex) {
+        if (ex.getCause() != null) {
+            ex.addSuppressed(cause);
+        } else {
+            ex.initCause(cause);
+        }
+
+        return ex;
+    }
+
 }