You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by Tharindu Kumara <zo...@gmail.com> on 2017/07/19 04:41:27 UTC

How to capture the watch event generated by zoo_aexists?

Hi,

In order to check the existence of a node in zookeeper, the api provides
two functions. Namely zoo_aexists and zoo_awexists.

zoo_awexists function provides the ability to inject and watcher object
through it's arguments and we can capture the watch event through that
object.

----- ZOOAPI int zoo_awexists( zhandle_t *  zh, const char * path, watcher_fn
watcher, void * watcherCtx, stat_completion_t completion, const void * data )


But zoo_aexists does not provide that kind of argument. It is only gives us
the ability to specify whether it need to be watched or not.

----- ZOOAPI int zoo_aexists( zhandle_t * zh, const char * path, int
watch, stat_completion_t
 completion, const void * data )

The zookeeper documentation says that, watch if nonzero, a watch will be
set at the server to notify the client if the node changes. The watch will
be set even if the node does not exist. This allows clients to watch for
nodes to appear.

My questions is when we using zoo_aexists in an application, how and what
would be the best way to capture the watch event generated by zoo_aexists.​


Thanks
Tharindu