aboutsummaryrefslogtreecommitdiffstats
path: root/config/src
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2021-10-07 13:15:48 +0200
committerHarald Musum <musum@yahooinc.com>2021-10-07 13:15:48 +0200
commit35cc39659cd8acefcee399a1fc2a5228dd38adc5 (patch)
treef740e3c2d2bc653f2dee1afd396a8b86d132cd1a /config/src
parent03224ae1749a058c88ee926738195ae0d3204322 (diff)
Reuse supervisor when we have one
Remove unnecessary constructor
Diffstat (limited to 'config/src')
-rw-r--r--config/src/main/java/com/yahoo/vespa/config/JRTConnectionPool.java12
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java11
2 files changed, 9 insertions, 14 deletions
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 f4876826492..d7e21356ba2 100644
--- a/config/src/main/java/com/yahoo/vespa/config/JRTConnectionPool.java
+++ b/config/src/main/java/com/yahoo/vespa/config/JRTConnectionPool.java
@@ -37,19 +37,15 @@ public class JRTConnectionPool implements ConnectionPool {
private volatile JRTConnection currentConnection;
public JRTConnectionPool(ConfigSourceSet sourceSet) {
- this(sourceSet, "config-jrt-pool" + sourceSet.hashCode());
+ this(sourceSet, new Supervisor(new Transport("config-pool-" + sourceSet.hashCode())).setDropEmptyBuffers(true));
}
- public JRTConnectionPool(ConfigSourceSet sourceSet, String poolName) {
- this.poolName = poolName;
- supervisor = new Supervisor(new Transport(poolName + "-")).setDropEmptyBuffers(true);
+ public JRTConnectionPool(ConfigSourceSet sourceSet, Supervisor supervisor) {
+ this.supervisor = supervisor;
+ this.poolName = supervisor.transport().getName();
addSources(sourceSet);
}
- JRTConnectionPool(List<String> addresses) {
- this(new ConfigSourceSet(addresses));
- }
-
public void addSources(ConfigSourceSet sourceSet) {
this.sourceSet = sourceSet;
synchronized (connections) {
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 5c0876a2649..43f9a87454d 100644
--- a/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java
@@ -5,7 +5,6 @@ import com.yahoo.config.subscription.ConfigSourceSet;
import org.junit.Test;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -27,7 +26,8 @@ import static org.junit.Assert.assertTrue;
* @author hmusum
*/
public class JRTConnectionPoolTest {
- private static final List<String> sources = new ArrayList<>((Arrays.asList("host0", "host1", "host2")));
+
+ private static final ConfigSourceSet sources = new ConfigSourceSet(List.of("host0", "host1", "host2"));
@Test
public void test_random_selection_of_source() {
@@ -57,7 +57,7 @@ public class JRTConnectionPoolTest {
public void testManySources() {
Map<String, Integer> timesUsed = new LinkedHashMap<>();
- List<String> twoSources = List.of("host0", "host1");
+ ConfigSourceSet twoSources = new ConfigSourceSet(List.of("host0", "host1"));
JRTConnectionPool sourcePool = new JRTConnectionPool(twoSources);
int count = 1000;
@@ -93,8 +93,7 @@ public class JRTConnectionPoolTest {
*/
@Test
public void updateSources() {
- List<String> twoSources = List.of("host0", "host1");
-
+ ConfigSourceSet twoSources = new ConfigSourceSet(List.of("host0", "host1"));
JRTConnectionPool sourcePool = new JRTConnectionPool(twoSources);
ConfigSourceSet sourcesBefore = sourcePool.getSourceSet();
@@ -130,7 +129,7 @@ public class JRTConnectionPoolTest {
@Test
public void testFailingSources() {
- List<String> sources = List.of("host0", "host1", "host2");
+ ConfigSourceSet sources = new ConfigSourceSet(List.of("host0", "host1"));
JRTConnectionPool connectionPool = new JRTConnectionPool(sources);
Connection firstConnection = connectionPool.getCurrent();