zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergei Babovich <sbabov...@demandware.com>
Subject Zookeeper doc example - what if fails to reestablish watch? Is more error handling required?
Date Wed, 19 Sep 2012 19:05:25 GMT
I was reviewing zookeeper example code 
In particular implementation of watch event handling in DataMonitor class.

public void process(WatchedEvent event) {
         String path = event.getPath();
         if (event.getType() == Event.EventType.None) {
             // We are are being told that the state of the
             // connection has changed
             switch (event.getState()) {
             case SyncConnected:
                 // In this particular example we don't need to do anything
                 // here - watches are automatically re-registered with
                 // server and any watches triggered while the client was
                 // disconnected will be delivered (in order of course)
             case Expired:
                 // It's all over
                 dead = true;
         } else {
             if (path != null && path.equals(znode)) {
                 // Something has changed on the node, let's find out
                 zk.exists(znode, true, this, null);
         if (chainedWatcher != null) {

My question is what if call of zk.exists to reestablish watch fails (due 
to connection loss or something else - it should be possible for remote 
call). Then watch will not be set and no further notifications about 
changes will be received. Is my understanding correct? What proper error 
handling should be in this case? Should zk.exists be called at least on 
every SyncConnected event to make ensure that watch gets reestablished 
when possible?


This e-mail message and all attachments transmitted with it may contain privileged and/or
confidential information intended solely for the use of the addressee(s). If the reader of
this message is not the intended recipient, you are hereby notified that any reading, dissemination,
distribution, copying, forwarding or other use of this message or its attachments is strictly
prohibited. If you have received this message in error, please notify the sender immediately
and delete this message, all attachments and all copies and backups thereof.
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message