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 = "10.16.73.22,10.16.73.12,10.16.73.13";
        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 {

    @Override
    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
123
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
event!”
Could somebody explain for me? Thanks a lot.

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