If we are in reconnect state, we should never attempt to initiate
reconnection, as that would leave us without the timer running --
which is a problem since we need to be timing out requests which
are queued even as we are attempting to reconnect to the backend.
Change-Id: Ic955a2e5b743617c26cc72815df94d0c4584704c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
584be7bf6b41f2f8b01dd718aba8d3b6cf7426ef)
if (delay >= DEBUG_DELAY_NANOS) {
if (delay > MAX_DELAY_NANOS) {
LOG.info("Capping {} throttle delay from {} to {} seconds", this,
- TimeUnit.NANOSECONDS.toSeconds(delay), MAX_DELAY_SECONDS);
+ TimeUnit.NANOSECONDS.toSeconds(delay), MAX_DELAY_SECONDS, new Throwable());
delay = MAX_DELAY_NANOS;
}
if (LOG.isDebugEnabled()) {
this.cause = Preconditions.checkNotNull(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, final RequestException cause) {
this.cause = Preconditions.checkNotNull(cause);
- LOG.debug("Skipping reconnect of already-reconnecting connection {}", this);
+ LOG.warn("Skipping reconnect of already-reconnecting connection {}", this);
return current;
}
Assert.assertFalse(timeout.isPresent());
}
- @Test
- public void testCheckTimeoutConnectionTimeouted() throws Exception {
- final Consumer<Response<?, ?>> callback = mock(Consumer.class);
- connection.sendRequest(createRequest(replyToProbe.ref()), callback);
- final long now = context.ticker().read() + ConnectedClientConnection.BACKEND_ALIVE_TIMEOUT_NANOS;
- final Optional<Long> timeout = connection.checkTimeout(now);
- Assert.assertNull(timeout);
- }
-
@Test
public void testCheckTimeout() throws Exception {
final Consumer<Response<?, ?>> callback = mock(Consumer.class);
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
+import java.util.Optional;
+import java.util.function.Consumer;
+import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.controller.cluster.access.ABIVersion;
import org.opendaylight.controller.cluster.access.concepts.RequestException;
+import org.opendaylight.controller.cluster.access.concepts.Response;
public class ConnectedClientConnectionTest
extends AbstractClientConnectionTest<ConnectedClientConnection<BackendInfo>, BackendInfo> {
+ @Test
+ public void testCheckTimeoutConnectionTimedout() throws Exception {
+ final Consumer<Response<?, ?>> callback = mock(Consumer.class);
+ connection.sendRequest(createRequest(replyToProbe.ref()), callback);
+ final long now = context.ticker().read() + ConnectedClientConnection.BACKEND_ALIVE_TIMEOUT_NANOS;
+ final Optional<Long> timeout = connection.checkTimeout(now);
+ Assert.assertNull(timeout);
+ }
+
@Override
protected ConnectedClientConnection<BackendInfo> createConnection() {
final BackendInfo backend = new BackendInfo(backendProbe.ref(), 0L, ABIVersion.BORON, 10);
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
+import java.util.Optional;
import java.util.function.Consumer;
import org.junit.Assert;
import org.junit.Test;
public class ReconnectingClientConnectionTest
extends AbstractClientConnectionTest<ReconnectingClientConnection<BackendInfo>, BackendInfo> {
+ @Test
+ public void testCheckTimeoutConnectionTimedout() throws Exception {
+ final Consumer<Response<?, ?>> callback = mock(Consumer.class);
+ connection.sendRequest(createRequest(replyToProbe.ref()), callback);
+ final long now = context.ticker().read() + ConnectedClientConnection.BACKEND_ALIVE_TIMEOUT_NANOS;
+ final Optional<Long> timeout = connection.checkTimeout(now);
+ Assert.assertNotNull(timeout);
+ Assert.assertTrue(timeout.isPresent());
+ }
+
@Override
protected ReconnectingClientConnection<BackendInfo> createConnection() {
final BackendInfo backend = new BackendInfo(backendProbe.ref(), 0L, ABIVersion.BORON, 10);