From 1ea7116333f2ef811ac1b927db9477012cc56cd9 Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Wed, 6 Oct 2021 20:55:54 +0200 Subject: setError() -> switchConnection() and remove setError() --- .../yahoo/config/subscription/impl/JRTConfigRequester.java | 2 +- .../com/yahoo/config/subscription/impl/MockConnection.java | 5 +---- .../src/main/java/com/yahoo/vespa/config/ConnectionPool.java | 11 ++--------- .../main/java/com/yahoo/vespa/config/JRTConnectionPool.java | 8 +------- .../java/com/yahoo/vespa/config/JRTConnectionPoolTest.java | 4 ++-- .../config/server/filedistribution/FileDistributionUtil.java | 3 --- .../yahoo/vespa/filedistribution/FileReferenceDownloader.java | 4 ++-- .../com/yahoo/vespa/filedistribution/FileDownloaderTest.java | 5 +---- 8 files changed, 10 insertions(+), 32 deletions(-) diff --git a/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java b/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java index 7713d509f69..ce24d784776 100644 --- a/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java +++ b/config/src/main/java/com/yahoo/config/subscription/impl/JRTConfigRequester.java @@ -165,7 +165,7 @@ public class JRTConfigRequester implements RequestWaiter { // The subscription object has an "old" config, which is all we have to offer back now log.log(INFO, "Failure of config subscription tp " + connection.getAddress() + ", clients will keep existing config until resolved: " + sub); - connectionPool.setError(connection, jrtReq.errorCode()); + connectionPool.switchConnection(connection); failures++; long delay = calculateFailedRequestDelay(failures, timingValues); // The logging depends on whether we are configured or not. diff --git a/config/src/main/java/com/yahoo/config/subscription/impl/MockConnection.java b/config/src/main/java/com/yahoo/config/subscription/impl/MockConnection.java index e9e7f3e7bce..c27e4cb2bc8 100644 --- a/config/src/main/java/com/yahoo/config/subscription/impl/MockConnection.java +++ b/config/src/main/java/com/yahoo/config/subscription/impl/MockConnection.java @@ -1,4 +1,4 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.subscription.impl; import com.yahoo.jrt.Request; @@ -61,9 +61,6 @@ public class MockConnection implements ConnectionPool, Connection { @Override public void close() {} - @Override - public void setError(Connection connection, int errorCode) { } - @Override public Connection getCurrent() { return this; diff --git a/config/src/main/java/com/yahoo/vespa/config/ConnectionPool.java b/config/src/main/java/com/yahoo/vespa/config/ConnectionPool.java index 93135fc4661..1ee44bfee87 100644 --- a/config/src/main/java/com/yahoo/vespa/config/ConnectionPool.java +++ b/config/src/main/java/com/yahoo/vespa/config/ConnectionPool.java @@ -1,4 +1,4 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config; import com.yahoo.jrt.Supervisor; @@ -10,18 +10,11 @@ public interface ConnectionPool extends AutoCloseable { void close(); - /** - * Sets the supplied Connection to have an error, implementations are expected to call - * {@link #switchConnection(Connection)} after setting state for the supplied Connection. - * - */ - void setError(Connection connection, int i); - Connection getCurrent(); /** * Switches to another (healthy, if one exists) Connection instance. - * Returns the resulting Connection. See also {@link #setError(Connection, int)} + * Returns the resulting Connection. * * @return a Connection */ diff --git a/config/src/main/java/com/yahoo/vespa/config/JRTConnectionPool.java b/config/src/main/java/com/yahoo/vespa/config/JRTConnectionPool.java index 78580328bf9..f4876826492 100644 --- a/config/src/main/java/com/yahoo/vespa/config/JRTConnectionPool.java +++ b/config/src/main/java/com/yahoo/vespa/config/JRTConnectionPool.java @@ -1,4 +1,4 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config; import com.yahoo.config.subscription.ConfigSourceSet; @@ -18,7 +18,6 @@ import java.util.logging.Logger; * The current connection is chosen randomly when calling {#link {@link #switchConnection()}} * (it will continue to use the same connection if there is only one source). * The current connection is available with {@link #getCurrent()}. - * When calling {@link #setError(Connection, int)}, {@link #switchConnection()} will always be called. * * @author Gunnar Gauslaa Bergem * @author hmusum @@ -115,11 +114,6 @@ public class JRTConnectionPool implements ConnectionPool { return sourceSet; } - @Override - public void setError(Connection connection, int errorCode) { - switchConnection(connection); - } - public JRTConnectionPool updateSources(List addresses) { ConfigSourceSet newSources = new ConfigSourceSet(addresses); return updateSources(newSources); diff --git a/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java b/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java index bfe132c9660..5c0876a2649 100644 --- a/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java @@ -1,4 +1,4 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config; import com.yahoo.config.subscription.ConfigSourceSet; @@ -160,7 +160,7 @@ public class JRTConnectionPoolTest { } private JRTConnection failAndGetNewConnection(JRTConnectionPool connectionPool, Connection failingConnection) { - connectionPool.setError(failingConnection, 123); + connectionPool.switchConnection(failingConnection); return connectionPool.getCurrent(); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDistributionUtil.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDistributionUtil.java index 1985fd534fb..e1cace830a6 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDistributionUtil.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDistributionUtil.java @@ -74,9 +74,6 @@ public class FileDistributionUtil { } } - @Override - public void setError(Connection connection, int i) {} - @Override public Connection getCurrent() { return null; } diff --git a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java index 949b1b703cd..952684b7b0b 100644 --- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java @@ -1,4 +1,4 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.filedistribution; import com.yahoo.concurrent.DaemonThreadFactory; @@ -114,7 +114,7 @@ public class FileReferenceDownloader { log.log(logLevel, () -> "Downloading file " + fileReference + " from " + connection.getAddress() + " failed: " + request + ", error: " + request.errorMessage() + ", will use another config server for next request" + " (retry count " + retryCount + ", rpc timeout " + rpcTimeout.getSeconds() + ")"); - connectionPool.setError(connection, request.errorCode()); + connectionPool.switchConnection(connection); return false; } } diff --git a/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java b/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java index 6169f6fbe55..15cc28007ce 100644 --- a/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java +++ b/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java @@ -1,4 +1,4 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.filedistribution; import com.yahoo.config.FileReference; @@ -324,9 +324,6 @@ public class FileDownloaderTest { public void close() { } - @Override - public void setError(Connection connection, int errorCode) { } - @Override public Connection getCurrent() { return this; -- cgit v1.2.3