Curator (in recent releases) maintains an internal counter. Every time a new
ZooKeeper instance is allocated, it’s incremented. You can get this value via:
client.getZookeeperClient().getInstanceIndex()
So, keep your own counter to compare against. Add a ConnectionStateListener,
whenever there is a RECONNECT, compare the versions. If they’re different then
the ZooKeeper instance is new.
-JZ
From: Karthik Kambatla [email protected]
Reply: Karthik Kambatla [email protected]
Date: May 30, 2014 at 2:35:24 PM
To: Jordan Zimmerman [email protected]
Cc: [email protected] [email protected]
Subject: Re: CuratorFramework: multiple auths
Thanks Jordan. Will file a JIRA, and see if I can post a patch as well.
Is there a way to be notified when the underlying ZooKeeper instance is
updated?
On Fri, May 30, 2014 at 12:31 PM, Jordan Zimmerman <[email protected]>
wrote:
It looks like this is a limitation of Curator. Multiple auth support would need
to be added. Please open an issue in the Curator Jira.
For now, you’ll need to get the underlying ZooKeeper instance directly and add
it:
curator.getZookeeperClient().getZooKeeper().addAuth(…)
Note, however, that if there is a connection problem Curator will allocate a
new ZooKeeper instance and you’d have to add the auth to that as well.
-Jordan
From: Karthik Kambatla [email protected]
Reply: [email protected] [email protected]
Date: May 30, 2014 at 12:07:23 PM
To: [email protected] [email protected]
Subject: CuratorFramework: multiple auths
Hi
I am very new to Curator, but have used ZK before. Firstly, let me thank you
for putting Curator together - it makes talking to Zookeeper very easy.
I have one of those noob questions and will greatly appreciate any help.
For my usecase, I need multiple auths - multiple schemes - for my connection.
In the vanilla ZK world, I would call Zookeeper#addAuthInfo for each of my
schemes. How do I achieve the same using Curator?
CuratorFrameworkFactory.Builder#authorization seems to allow adding a single
auth. I googled around but couldn't find much information. I was considering
calling CuratorFramework#getZookeeperClient#getZookeeper()#addAuthInfo, but
wasn't sure if these auths would be preserved across disconnects/ session
timeouts.
Is there a way to either add multiple auths or get notified if the underlying
client changes?
Thanks again for all your help,
Karthik