summaryrefslogtreecommitdiffstats
path: root/zkfacade
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-01-23 20:53:44 +0100
committerHarald Musum <musum@oath.com>2018-01-23 20:53:44 +0100
commit1c712330aa2c990e939d281b15c1188978654600 (patch)
tree4289ed4d4a9ff6b991c687adb170b3db1e6af94c /zkfacade
parentd479ecf9a91b3d80822807d856f110eb19d988c4 (diff)
Change default value of zookeeperLocalhostAffinity to true
Diffstat (limited to 'zkfacade')
-rw-r--r--zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java4
-rw-r--r--zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java23
2 files changed, 11 insertions, 16 deletions
diff --git a/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java b/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java
index f875af307c5..0e0c7401e0e 100644
--- a/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java
+++ b/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java
@@ -71,7 +71,7 @@ public class Curator implements AutoCloseable {
}
private Curator(ConfigserverConfig configserverConfig, String zooKeeperEnsembleConnectionSpec) {
- this((configserverConfig.zookeeperLocalhostAffinity() || configserverConfig.system().equals("cd")) ?
+ this((configserverConfig.zookeeperLocalhostAffinity()) ?
createConnectionSpecForLocalhost(configserverConfig) : zooKeeperEnsembleConnectionSpec,
zooKeeperEnsembleConnectionSpec);
}
@@ -139,7 +139,7 @@ public class Curator implements AutoCloseable {
}
throw new IllegalArgumentException("Unable to create connect string to localhost: " +
- "There is no localhost servers specified in config: " + config);
+ "There is no localhost server specified in config: " + config);
}
private static void validateConnectionSpec(String connectionSpec) {
diff --git a/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java b/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java
index c5227fcbaa5..89d4521a20f 100644
--- a/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java
+++ b/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java
@@ -20,6 +20,8 @@ import static org.junit.Assert.assertThat;
*/
public class CuratorTest {
+ private static String localhost = HostName.getLocalhost();
+
private String spec1;
private String spec2;
private TestingServer test1;
@@ -33,8 +35,8 @@ public class CuratorTest {
port2 = allocatePort();
test1 = new TestingServer(port1);
test2 = new TestingServer(port2);
- spec1 = "localhost:" + port1;
- spec2 = "localhost:" + port2;
+ spec1 = localhost + ":" + port1;
+ spec2 = localhost + ":" + port2;
}
private int allocatePort() {
@@ -52,14 +54,7 @@ public class CuratorTest {
@Test
public void require_curator_is_created_from_config() {
try (Curator curator = createCurator(createTestConfig())) {
- assertThat(curator.connectionSpec(), is(spec1 + "," + spec2));
- }
- }
-
- @Test
- public void require_that_curator_can_produce_spec() {
- try (Curator curator = createCurator(createTestConfig())) {
- assertThat(curator.connectionSpec(), is(spec1 + "," + spec2));
+ assertThat(curator.zooKeeperEnsembleConnectionSpec(), is(spec1 + "," + spec2));
assertThat(curator.zooKeeperEnsembleCount(), is(2));
}
}
@@ -67,7 +62,7 @@ public class CuratorTest {
@Test
public void require_that_server_count_is_correct() {
ConfigserverConfig.Builder builder = new ConfigserverConfig.Builder();
- builder.zookeeperserver(createZKBuilder("localhost", port1));
+ builder.zookeeperserver(createZKBuilder(localhost, port1));
try (Curator curator = createCurator(new ConfigserverConfig(builder))) {
assertThat(curator.zooKeeperEnsembleCount(), is(1));
}
@@ -91,8 +86,8 @@ public class CuratorTest {
private ConfigserverConfig createTestConfig() {
ConfigserverConfig.Builder builder = new ConfigserverConfig.Builder();
- builder.zookeeperserver(createZKBuilder("localhost", port1));
- builder.zookeeperserver(createZKBuilder("localhost", port2));
+ builder.zookeeperserver(createZKBuilder(localhost, port1));
+ builder.zookeeperserver(createZKBuilder(localhost, port2));
return new ConfigserverConfig(builder);
}
@@ -125,7 +120,7 @@ public class CuratorTest {
private final static PortRange portRange = new PortRange();
// Get the next port from a pre-allocated range
- public static int findAvailablePort() {
+ static int findAvailablePort() {
return portRange.next();
}