BUG-8494: do not attempt to reconnect ReconnectingClientConnection
[controller.git] / opendaylight / md-sal / cds-access-client / src / main / java / org / opendaylight / controller / cluster / access / client / ClientActorBehavior.java
index ee63eddaa7cd26de705b7e5700e1f35dc3b323c6..554ffe97c77ae7c3011daca2a28c22f660a20e78 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.cluster.access.client;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Preconditions;
+import com.google.common.base.Stopwatch;
 import com.google.common.base.Verify;
 import java.util.Collection;
 import java.util.Map;
@@ -174,7 +175,7 @@ public abstract class ClientActorBehavior<T extends BackendInfo> extends
                 return this;
             } else if (conn != null) {
                 LOG.info("{}: connection {} indicated no leadership, reconnecting it", persistenceId(), conn, cause);
-                return conn.reconnect(this);
+                return conn.reconnect(this, cause);
             }
         }
         if (cause instanceof OutOfSequenceEnvelopeException) {
@@ -185,7 +186,7 @@ public abstract class ClientActorBehavior<T extends BackendInfo> extends
             } else if (conn != null) {
                 LOG.info("{}: connection {} indicated no sequencing mismatch on {} sequence {}, reconnecting it",
                     persistenceId(), conn, failure.getTarget(), failure.getSequence(), cause);
-                return conn.reconnect(this);
+                return conn.reconnect(this, cause);
             }
         }
 
@@ -278,6 +279,8 @@ public abstract class ClientActorBehavior<T extends BackendInfo> extends
         LOG.info("{}: resolved shard {} to {}", persistenceId(), shard, backend);
         final long stamp = connectionsLock.writeLock();
         try {
+            final Stopwatch sw = Stopwatch.createStarted();
+
             // Create a new connected connection
             final ConnectedClientConnection<T> newConn = new ConnectedClientConnection<>(conn.context(),
                     conn.cookie(), backend);
@@ -301,7 +304,7 @@ public abstract class ClientActorBehavior<T extends BackendInfo> extends
                 LOG.warn("{}: old connection {} does not match existing {}, new connection {} in limbo",
                     persistenceId(), conn, existing, newConn);
             } else {
-                LOG.info("{}: replaced connection {} with {}", persistenceId(), conn, newConn);
+                LOG.info("{}: replaced connection {} with {} in {}", persistenceId(), conn, newConn, sw);
             }
         } finally {
             connectionsLock.unlockWrite(stamp);