commons icon indicating copy to clipboard operation
commons copied to clipboard

chroot with ZooKeeperClient?

Open jdanbrown opened this issue 13 years ago • 5 comments

Looking at the ZooKeeperClient api (and also the implementation), it looks like there's no way to connect to the zk cluster using a chroot suffix, which I typically do just by specifying the zk connect string directly, e.g.

"host-a,host-b,host-c/prod/service"

jdanbrown avatar Jul 31 '12 04:07 jdanbrown

Ack - this would be a nice improvement. Definitely happy to take a patch if you're willing.

jsirois avatar Jul 31 '12 04:07 jsirois

Sure. How about another constructor that takes the zk connect string directly? Something like:

public ZooKeeperClient(Amount<Integer, Time> sessionTimeout, Credentials credentials, String zooKeeperServers) {
  ...
  this.zooKeeperServers = zooKeeperServers;
}

In my experience those strings are specified as-is in the config, so I'm not sure if there's much advantage to trying to split it all up into hosts and ports and chroots, rather than just passing through the string directly and letting the ZooKeeper constructor complain if it can't parse it.

jdanbrown avatar Jul 31 '12 04:07 jdanbrown

I'd prefer an additional chroot argument overload too to keep with the existing style - reasoning going like this: Most internal usages use the Arg parsing facility to parse Arg<List<InetSocketAddress>> at startup - validation can fail fast here. The actual ZooKeeper client is then often created later in a background thread.

jsirois avatar Jul 31 '12 05:07 jsirois

Ok, sounds good to me. I'll submit a pull request.

jdanbrown avatar Jul 31 '12 19:07 jdanbrown

Pull requested: #53.

jdanbrown avatar Jul 31 '12 19:07 jdanbrown