thanks for your reply. but i means the order should be : hello zookeeper hello event! type=None, stat=SyncConnected, path=null 123
but the real result order is : hello zookeeper 123 hello event! type=None, stat=SyncConnected, path=null Best Regards! Guanpu Shen 在 2014年10月21日,上午9:07,Biju N <[email protected]<mailto:[email protected]>> 写道: The "System.out.println(new String(zk.getData(znode,false,null)));" is causing 123 to be displayed. On Fri, Oct 17, 2014 at 12:15 AM, 沈冠璞 <[email protected]<mailto:[email protected]>> wrote: 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
