summaryrefslogtreecommitdiffstats
path: root/zkfacade
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2019-12-02 13:40:30 +0100
committerHarald Musum <musum@verizonmedia.com>2019-12-02 13:40:30 +0100
commited308e855f8093c5e369720510c51d68ce6b1f8f (patch)
treecebee8bf7b1b342cbd8d89456980a775b147981d /zkfacade
parent4e0290915f15ff1edd530daa5b53217e76b785c6 (diff)
Use regular ZooKeeper factory
Diffstat (limited to 'zkfacade')
-rw-r--r--zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java4
-rw-r--r--zkfacade/src/main/java/com/yahoo/vespa/curator/DNSResolvingFixerZooKeeperFactory.java45
-rw-r--r--zkfacade/src/main/java/com/yahoo/vespa/curator/VespaZooKeeperFactory.java22
3 files changed, 23 insertions, 48 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 c8aea1f3d21..0e20710298f 100644
--- a/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java
+++ b/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java
@@ -29,7 +29,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
import java.util.function.Function;
/**
@@ -44,7 +43,6 @@ import java.util.function.Function;
*/
public class Curator implements AutoCloseable {
- private static final long UNKNOWN_HOST_TIMEOUT_MILLIS = TimeUnit.MINUTES.toMillis(30);
private static final int ZK_SESSION_TIMEOUT = 30000;
private static final int ZK_CONNECTION_TIMEOUT = 30000;
@@ -91,7 +89,7 @@ public class Curator implements AutoCloseable {
.sessionTimeoutMs(ZK_SESSION_TIMEOUT)
.connectionTimeoutMs(ZK_CONNECTION_TIMEOUT)
.connectString(connectionSpec)
- .zookeeperFactory(new DNSResolvingFixerZooKeeperFactory(UNKNOWN_HOST_TIMEOUT_MILLIS))
+ .zookeeperFactory(new VespaZooKeeperFactory())
.dontUseContainerParents() // TODO: Remove when we know ZooKeeper 3.5 works fine, consider waiting until Vespa 8
.build());
}
diff --git a/zkfacade/src/main/java/com/yahoo/vespa/curator/DNSResolvingFixerZooKeeperFactory.java b/zkfacade/src/main/java/com/yahoo/vespa/curator/DNSResolvingFixerZooKeeperFactory.java
deleted file mode 100644
index ba045fd8acb..00000000000
--- a/zkfacade/src/main/java/com/yahoo/vespa/curator/DNSResolvingFixerZooKeeperFactory.java
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.curator;
-
-import com.yahoo.log.LogLevel;
-import org.apache.curator.utils.DefaultZookeeperFactory;
-import org.apache.curator.utils.ZookeeperFactory;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZooKeeper;
-
-import java.net.UnknownHostException;
-import java.util.concurrent.TimeUnit;
-import java.util.logging.Logger;
-
-/**
- * A ZooKeeper handle factory that handles unknown host exceptions.
- *
- * @author Ulf Lilleengen
- * @since 5.9
- */
-class DNSResolvingFixerZooKeeperFactory implements ZookeeperFactory {
-
- public static final long UNKNOWN_HOST_WAIT_TIME_MILLIS = TimeUnit.SECONDS.toMillis(10);
-
- private static final Logger log = Logger.getLogger(DNSResolvingFixerZooKeeperFactory.class.getName());
- private final DefaultZookeeperFactory zookeeperFactory;
- private final long maxTimeout;
- public DNSResolvingFixerZooKeeperFactory(long maxTimeout) {
- this.maxTimeout = maxTimeout;
- this.zookeeperFactory = new DefaultZookeeperFactory();
- }
- @Override
- public ZooKeeper newZooKeeper(String connectString, int sessionTimeout, Watcher watcher, boolean canBeReadOnly) throws Exception {
- long endTime = System.currentTimeMillis() + maxTimeout;
- do {
- try {
- return zookeeperFactory.newZooKeeper(connectString, sessionTimeout, watcher, canBeReadOnly);
- } catch (UnknownHostException e) {
- log.log(LogLevel.WARNING, "Error creating ZooKeeper handle", e);
- Thread.sleep(UNKNOWN_HOST_WAIT_TIME_MILLIS);
- }
- } while (System.currentTimeMillis() < endTime);
- throw new RuntimeException("Error creating zookeeper handle within timeout");
- }
-
-}
diff --git a/zkfacade/src/main/java/com/yahoo/vespa/curator/VespaZooKeeperFactory.java b/zkfacade/src/main/java/com/yahoo/vespa/curator/VespaZooKeeperFactory.java
new file mode 100644
index 00000000000..7c08168c536
--- /dev/null
+++ b/zkfacade/src/main/java/com/yahoo/vespa/curator/VespaZooKeeperFactory.java
@@ -0,0 +1,22 @@
+// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.curator;
+
+import org.apache.curator.utils.ZookeeperFactory;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZooKeeper;
+
+/**
+ * A ZooKeeper factory for creating a ZooKeeper client
+ *
+ * @author hmusum
+ */
+// TODO: add constructor that takes feature flag so that we can write ZooKeeper client config and start
+// ZooKeeper client with that config
+class VespaZooKeeperFactory implements ZookeeperFactory {
+
+ @Override
+ public ZooKeeper newZooKeeper(String connectString, int sessionTimeout, Watcher watcher, boolean canBeReadOnly) throws Exception {
+ return new ZooKeeper(connectString, sessionTimeout, watcher);
+ }
+
+}