BUG-8540: suppress ConnectingClientConnection backend timeout 03/58203/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 23 May 2017 17:42:57 +0000 (19:42 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 4 Jun 2017 07:45:59 +0000 (09:45 +0200)
While a ClientConnection is in initial connect state we do not want
the timer to attempt to reconnect it, as it we are already trying
hard to connect it. Suppress that attempt by faking backend silent
ticks to be 0.

Change-Id: Iaf554632a56fd5be1d417d6806462edf3c746526
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a3b2c1a05f66523561a10ac898723ffdf7e68798)

opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnection.java
opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ConnectingClientConnection.java

index cd81a4e5444ca9b47a1f51a94ff79796afa106a2..6cb89eec1601e5fa901f89e7ac37d7e254698d66 100644 (file)
@@ -289,6 +289,10 @@ public abstract class AbstractClientConnection<T extends BackendInfo> {
         }
     }
 
+    long backendSilentTicks(final long now) {
+        return now - lastReceivedTicks;
+    }
+
     /*
      * We are using tri-state return here to indicate one of three conditions:
      * - if there is no timeout to schedule, return Optional.empty()
@@ -303,7 +307,7 @@ public abstract class AbstractClientConnection<T extends BackendInfo> {
             return Optional.empty();
         }
 
-        final long backendSilentTicks = now - lastReceivedTicks;
+        final long backendSilentTicks = backendSilentTicks(now);
         if (backendSilentTicks >= BACKEND_ALIVE_TIMEOUT_NANOS) {
             LOG.debug("Connection {} has not seen activity from backend for {} nanoseconds, timing out", this,
                 backendSilentTicks);
index a36267c44f735c2bca3a9491fe2f743ab632902d..07ef7695448e5d3933510f3745ef3729e09f7fb8 100644 (file)
@@ -30,6 +30,12 @@ public final class ConnectingClientConnection<T extends BackendInfo> extends Abs
         return Optional.empty();
     }
 
+    @Override
+    long backendSilentTicks(final long now) {
+        // We are still connecting and do not want the timer to attempt a reconnect
+        return 0;
+    }
+
     @Override
     ClientActorBehavior<T> lockedReconnect(final ClientActorBehavior<T> current, final RequestException cause) {
         throw new UnsupportedOperationException("Attempted to reconnect a connecting connection", cause);