diff options
author | Harald Musum <musum@yahooinc.com> | 2021-10-15 11:56:13 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2021-10-15 11:56:13 +0200 |
commit | 6263c9bec9f2655d0388d3d2933fb079f4a79381 (patch) | |
tree | 68e951a26975a0c57c86428d8144eff688f460ae /configserver | |
parent | 5be4802d05614e2453037f6d47f09304b47bc75e (diff) |
Minore refactoring
Diffstat (limited to 'configserver')
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java index 5d9a9c7b836..f34beae9c46 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java @@ -5,11 +5,14 @@ import com.google.inject.Inject; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.concurrent.DaemonThreadFactory; import com.yahoo.config.FileReference; +import com.yahoo.config.subscription.ConfigSourceSet; import com.yahoo.jrt.Int32Value; import com.yahoo.jrt.Request; import com.yahoo.jrt.StringValue; import com.yahoo.jrt.Supervisor; import com.yahoo.jrt.Transport; +import com.yahoo.vespa.config.ConnectionPool; +import com.yahoo.vespa.config.JRTConnectionPool; import com.yahoo.vespa.defaults.Defaults; import com.yahoo.vespa.filedistribution.CompressedFileReference; import com.yahoo.vespa.filedistribution.EmptyFileReferenceData; @@ -24,6 +27,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.logging.Level; @@ -71,16 +75,12 @@ public class FileServer { @Inject public FileServer(ConfigserverConfig configserverConfig) { this(new File(Defaults.getDefaults().underVespaHome(configserverConfig.fileReferencesDir())), - new FileDownloader(getOtherConfigServersInCluster(configserverConfig), - new Supervisor(new Transport("filedistribution-pool")) - .setDropEmptyBuffers(true))); + createFileDownloader(getOtherConfigServersInCluster(configserverConfig))); } // For testing only public FileServer(File rootDir) { - this(rootDir, new FileDownloader(FileDownloader.emptyConnectionPool(), - new Supervisor(new Transport("fileserver-for-testing")) - .setDropEmptyBuffers(true))); + this(rootDir, createFileDownloader(List.of())); } public FileServer(File rootDir, FileDownloader fileDownloader) { @@ -205,4 +205,18 @@ public class FileServer { executor.shutdown(); } + private static FileDownloader createFileDownloader(List<String> configServers) { + Supervisor supervisor = new Supervisor(new Transport("filedistribution-pool")).setDropEmptyBuffers(true); + return new FileDownloader(configServers.isEmpty() + ? FileDownloader.emptyConnectionPool() + : getConnectionPool(configServers, supervisor), + supervisor); + } + + private static ConnectionPool getConnectionPool(List<String> configServers, Supervisor supervisor) { + return configServers.size() > 0 + ? new JRTConnectionPool(new ConfigSourceSet(configServers), supervisor) + : FileDownloader.emptyConnectionPool(); + } + } |