zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lei liu <liulei...@gmail.com>
Subject set wacher failed
Date Fri, 29 Jul 2011 08:23:27 GMT
I write Wacher class,   I call zk.getData(path, watch, null) in process()
method, example below code:

public class AppVersionMappingChildrenNodeWatcher implements Watcher {

    private ZooKeeperManager zooKeeperManager;

    protected Logger logger = LoggerFactory.getLogger(this.getClass());

    //process biz when some child added or deleted
    @Override
    public void process(WatchedEvent event) {

        //open a watcher
        String path = event.getPath();
        logger.info("notify path:"+path);
        String value = "";
        try {
           value = zk.getData(path, watcher, null);
            logger.info("reMonitor for zookeeper in AppVersionMappingWatcher
success,value is:"+value);
        } catch (Exception e) {
            //TODO:huangdou.c: i will lost this machine in this zookeeper
call back group
            logger.error("reOpen watcher failure, this machine will be lost.
please restart");
        }
    }
}


If zk.getData(path, watcher, null) throw Exception,  the watch will be not
left on the node with the given path. The watch will be not  triggered by a
successful operation that sets data on the node, or deletes the node, So my
application will never be notified when the data is changed on the node,
how I can handle the Exception?


Thanks,


LiuLei

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message