summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2021-06-15 08:46:59 +0200
committerHarald Musum <musum@verizonmedia.com>2021-06-15 08:46:59 +0200
commit109dd89384b9db3c4bc4bc2a6e325456bc6f853b (patch)
treed7fe4dcb2b66f24a63386aa8cd1b43dc6418d0b2
parent5667784f2fca043d79863160946dce85832890b6 (diff)
Add constructor for naming JRTConnectionPool
-rw-r--r--config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionAndUrlDownload.java6
-rw-r--r--config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionRpcServer.java6
-rw-r--r--config/src/main/java/com/yahoo/vespa/config/JRTConnectionPool.java12
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDistributionUtil.java6
4 files changed, 20 insertions, 10 deletions
diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionAndUrlDownload.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionAndUrlDownload.java
index 2767d2c8027..1dba56805a5 100644
--- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionAndUrlDownload.java
+++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionAndUrlDownload.java
@@ -1,4 +1,4 @@
-// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.proxy.filedistribution;
import com.yahoo.concurrent.DaemonThreadFactory;
@@ -26,7 +26,9 @@ public class FileDistributionAndUrlDownload {
new ScheduledThreadPoolExecutor(1, new DaemonThreadFactory("file references and downloads cleanup"));
public FileDistributionAndUrlDownload(Supervisor supervisor, ConfigSourceSet source) {
- fileDistributionRpcServer = new FileDistributionRpcServer(supervisor, new FileDownloader(new JRTConnectionPool(source)));
+ fileDistributionRpcServer =
+ new FileDistributionRpcServer(supervisor,
+ new FileDownloader(new JRTConnectionPool(source, "filedistribution-jrt-pool-")));
urlDownloadRpcServer = new UrlDownloadRpcServer(supervisor);
cleanupExecutor.scheduleAtFixedRate(new CachedFilesMaintainer(), delay.toSeconds(), delay.toSeconds(), TimeUnit.SECONDS);
}
diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionRpcServer.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionRpcServer.java
index a25e86926a1..ea3a69c54a2 100644
--- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionRpcServer.java
+++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionRpcServer.java
@@ -1,4 +1,4 @@
-// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.proxy.filedistribution;
import com.yahoo.concurrent.DaemonThreadFactory;
@@ -41,7 +41,7 @@ class FileDistributionRpcServer {
FileDistributionRpcServer(Supervisor supervisor, FileDownloader downloader) {
this.supervisor = supervisor;
this.downloader = downloader;
- declareFileDistributionMethods();
+ declareMethods();
}
void close() {
@@ -53,7 +53,7 @@ class FileDistributionRpcServer {
}
}
- private void declareFileDistributionMethods() {
+ private void declareMethods() {
// Legacy method, needs to be the same name as used in filedistributor
supervisor.addMethod(new Method("waitFor", "s", "s", this::getFile)
.methodDesc("get path to file reference")
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 26eafb67c1b..e5bcb56ccb3 100644
--- a/config/src/main/java/com/yahoo/vespa/config/JRTConnectionPool.java
+++ b/config/src/main/java/com/yahoo/vespa/config/JRTConnectionPool.java
@@ -29,6 +29,7 @@ public class JRTConnectionPool implements ConnectionPool {
private final Supervisor supervisor;
private final Map<String, JRTConnection> connections = new LinkedHashMap<>();
+ private final String poolName;
// The config sources used by this connection pool.
private ConfigSourceSet sourceSet = null;
@@ -37,11 +38,16 @@ public class JRTConnectionPool implements ConnectionPool {
private volatile JRTConnection currentConnection;
public JRTConnectionPool(ConfigSourceSet sourceSet) {
- supervisor = new Supervisor(new Transport("config-jrtpool-" + sourceSet.hashCode())).useSmallBuffers();
+ this(sourceSet, "config-jrt-pool-" + sourceSet.hashCode());
+ }
+
+ public JRTConnectionPool(ConfigSourceSet sourceSet, String poolName) {
+ this.poolName = poolName;
+ supervisor = new Supervisor(new Transport(poolName)).useSmallBuffers();
addSources(sourceSet);
}
- public JRTConnectionPool(List<String> addresses) {
+ JRTConnectionPool(List<String> addresses) {
this(new ConfigSourceSet(addresses));
}
@@ -131,7 +137,7 @@ public class JRTConnectionPool implements ConnectionPool {
}
public String toString() {
- StringBuilder sb = new StringBuilder();
+ StringBuilder sb = new StringBuilder(poolName + ": ");
synchronized (connections) {
for (JRTConnection conn : connections.values()) {
sb.append(conn.toString());
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 33cd425d6aa..cfe7349a1c6 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
@@ -40,7 +40,7 @@ public class FileDistributionUtil {
/**
* Returns a connection pool with all config servers except this one, or an empty pool if there
- * is only one config server.
+ * is only one config server (no point in trying to download from yourself).
*/
public static ConnectionPool createConnectionPool(ConfigserverConfig configserverConfig) {
List<String> configServers = ConfigServerSpec.fromConfig(configserverConfig)
@@ -49,7 +49,9 @@ public class FileDistributionUtil {
.map(spec -> "tcp/" + spec.getHostName() + ":" + spec.getConfigServerPort())
.collect(Collectors.toList());
- return configServers.size() > 0 ? new JRTConnectionPool(new ConfigSourceSet(configServers)) : emptyConnectionPool();
+ return configServers.size() > 0
+ ? new JRTConnectionPool(new ConfigSourceSet(configServers), "filedistribution-jrt-pool-")
+ : emptyConnectionPool();
}
public static boolean fileReferenceExistsOnDisk(File downloadDirectory, FileReference applicationPackageReference) {