Hi Satish -
As you've found out, you can set multiple identical watches per znode - the
zookeeper client will not detect identical watches in case you really meant
to call them several times. There's no way currently, as far as I know, to
clear the watches once they've been set. So your options are either to avoid
repeatedly setting them by detecting whether getChildren is a repeat call,
or by dealing with multiple invocations on the callback path and not doing
anything once you've established you're no longer interested.
It might well make sense to add a clearWatches(path) call to the API, which
would be useful particularly for clients where callbacks are expensive and
require a context switch (which I think is true for all clients right now!).
On Wed, Jun 10, 2009 at 8:05 PM, Satish Bhatti <cthd2...@gmail.com> wrote:
> I am using the asynchronous (callback) version of zookeeper.getChildren().
> That call returns immediately, I then wait for a certain time interval for
> nodes to appear, and if not I exit the method that made the
> call. Later on, a node gets added under that node and I see in my logfile
> that the Watcher.process() callback that I set above gets called. Now if I
> make 10 failed attempts to get a node using the above technique, and at
> later time a node does get added, I see in the logfile that the
> Watcher.process() ends up being called 10 times! Of course by this time I
> have totally lost interest in those callbacks. Question: Is there a way
> remove that asynchronous callback? i.e. If I make a asynchronous
> call, wait time t, give up, at that point can I remove the async callback?