From 837a3827da83fba70d781d8feca0cba1d4a61844 Mon Sep 17 00:00:00 2001 From: Erez Mazor Date: Mon, 26 Nov 2012 12:25:04 +0200 Subject: [PATCH 1/2] set connect timeout to a more reasonable value (this fails for us in production when zk is deployed across datacenters and the client is talking to an observer (IMO this should be externalized for the client to set via command line arg) --- .../main/groovy/org/linkedin/zookeeper/cli/ClientMain.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.linkedin.zookeeper-cli-impl/src/main/groovy/org/linkedin/zookeeper/cli/ClientMain.groovy b/org.linkedin.zookeeper-cli-impl/src/main/groovy/org/linkedin/zookeeper/cli/ClientMain.groovy index 361a3aa..aa2aa4f 100644 --- a/org.linkedin.zookeeper-cli-impl/src/main/groovy/org/linkedin/zookeeper/cli/ClientMain.groovy +++ b/org.linkedin.zookeeper-cli-impl/src/main/groovy/org/linkedin/zookeeper/cli/ClientMain.groovy @@ -62,7 +62,7 @@ public class ClientMain { def connectString = config.zkConnectionString ?: "localhost:2181" - client = new ZKClient(connectString, Timespan.parse('100'), null) + client = new ZKClient(connectString, Timespan.parse('10s'), null) client.start() log.debug "Talking to zookeeper on ${connectString}" From 81d8d3523aacccee64759d7d376be48079561240 Mon Sep 17 00:00:00 2001 From: Erez Mazor Date: Wed, 28 Nov 2012 22:13:36 +0200 Subject: [PATCH 2/2] added a parameter to the CLI to control zookeeper connection timeout --- .../groovy/org/linkedin/zookeeper/cli/ClientMain.groovy | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/org.linkedin.zookeeper-cli-impl/src/main/groovy/org/linkedin/zookeeper/cli/ClientMain.groovy b/org.linkedin.zookeeper-cli-impl/src/main/groovy/org/linkedin/zookeeper/cli/ClientMain.groovy index aa2aa4f..a286d1b 100644 --- a/org.linkedin.zookeeper-cli-impl/src/main/groovy/org/linkedin/zookeeper/cli/ClientMain.groovy +++ b/org.linkedin.zookeeper-cli-impl/src/main/groovy/org/linkedin/zookeeper/cli/ClientMain.groovy @@ -60,9 +60,10 @@ public class ClientMain def start() { - def connectString = config.zkConnectionString ?: "localhost:2181" + def connectString = config.zkConnectionString ?: "localhost:2181" + def connectTimeout = config.zkConnectionTimeout ?: "100" - client = new ZKClient(connectString, Timespan.parse('10s'), null) + client = new ZKClient(connectString, Timespan.parse(connectTimeout), null) client.start() log.debug "Talking to zookeeper on ${connectString}" @@ -78,9 +79,10 @@ public class ClientMain static int mainNoExit(Object args) { - def cli = new CliBuilder(usage: './bin/zk.sh [-h] [-s ] command') + def cli = new CliBuilder(usage: './bin/zk.sh [-h] [-s ] [-t ] command') cli.h(longOpt: 'help', 'display help') cli.s(longOpt: 'zkConnectionString', 'the zookeeper connection string (host:port)', args: 1, required: false) + cli.t(longOpt: 'zkConnectionTimeout', 'the zookeeper connection timeout (e.g. 10s)', args: 2, required: false) // this is splitting the main cmdline args from the command and its args boolean isMainArg = true