zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 沈冠璞 <shengua...@360.cn>
Subject getData return result between Watcher process?
Date Fri, 17 Oct 2014 04:15:39 GMT
hi, I am a newbie of the zookeeper.I have a question on get data order.
here is my program:

public class ZkReader {
    public static void main(String[] args) throws IOException, InterruptedException, KeeperException
        String hostPort = ",,";
        String znode = "/test";
        ZooKeeper zk = new ZooKeeper(hostPort, 3000, new MyWatcher());
        System.out.println(new String(zk.getData(znode,false,null)));

class MyWatcher  implements Watcher {

    public void process(WatchedEvent event) {
        System.out.println("hello zookeeper");
        System.out.println(String.format("hello event! type=%s, stat=%s, path=%s",event.getType(),event.getState(),event.getPath()));

the result:
hello zookeeper
hello event! type=None, stat=SyncConnected, path=null

I don’t know why  the data of node /test: 123 , shows between  "hello zookeeper" and "hello
Could somebody explain for me? Thanks a lot.

Best Regards!
Guanpu Shen
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message