I entered a bug based on your feedback:
http://sourceforge.net/tracker/index.php?func=detail&aid=1985723&group_id=209147&atid=1008544

Your WatcherImpl process method will be called for both Node events as 
well as State change events. In this case you are probably being called 
for the transition to connected state.

See this example of processing watch events:
http://zookeeper.wiki.sourceforge.net/ZooKeeperJavaExample

Second parameter is session timeout in milliseconds.
See the javadoc for the zookeeper class

  * To create a client(ZooKeeper) object, the application needs to pass 
a string
  * containing a list of host:port pairs, each corresponding to a ZooKeeper
  * server; a sessionTimeout; and an object of Watcher type.


See com.yahoo.zookeeper.Watcher.Event for list of possible state 
transitions (disconnected/expired/etc...).

Patrick

Avinash Lakshman wrote:
> I have the following two of code:
> 
>  ZooKeeper zk = new ZooKeeper("cassandra001.snc1.facebook.com:5001 
> <http://cassandra001.snc1.facebook.com:5001>", 5000, new 
> WatcherImpl());       
>  Stat stat = zk.exists("/", false);
> 
> I set my breakpoint at the second line and I see output from the 
> invocation of the process() implemented in the WatcherImpl class. My 
> question is why is the process() being invoked on creation of the 
> ZooKeeper object? Also what is the purpose of the second parameter in 
> the ZooKeeper ctor? Does it have anything to for failure detection ofthe 
> client connected to the ZooKeeper server?
> 
> Thanks in advance
> Avinash
> 
> 
> On Thu, Jun 5, 2008 at 10:49 AM, Avinash Lakshman 
> <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
> 
>     That would be awesome. This allows IMHO a cleaner design with
>     respect to handling of events. I must add that this is a great piece
>     of software though. Tremendous job in putting this together.
> 
>     Regards
>     A
> 
> 
>     On Thu, Jun 5, 2008 at 8:44 AM, Benjamin Reed <[EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>> wrote:
> 
>         As of the latest release the same watcher will be called for all
>         events. The
>         event callback includes the path of the znode that changed,
>         which is how you
>         can distinguish events.
> 
>         In the next major release, we will be allowing a watch object to
>         be passed to
>         the requests to make it easier for programmers to control what
>         is going to be
>         invoked with the watch event arrives.
> 
>         ben
> 
>         On Thursday 05 June 2008 00:15:54 Avinash Lakshman wrote:
>          > Hi All
>          >
>          > I am trying to get my feet wet with Zookeeper. I am trying to
>         set up watch
>          > events for a call to getChildren() for a particular znode. My
>         question is
>          > whether the same watcher that the ZooKeeper instance was
>         constructed with
>          > going to be called for all watch events. If so how do I know
>         for what event
>          > it is being called.
>          >
>          > Thanks
>          > A
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Zookeeper-user mailing list
> Zookeeper-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/zookeeper-user

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Zookeeper-user mailing list
Zookeeper-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/zookeeper-user

Reply via email to