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]> 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 >
