zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 沈冠璞 <shengua...@360.cn>
Subject Re: getData return result between Watcher process?
Date Tue, 21 Oct 2014 02:40:30 GMT
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 <bijuatapache@gmail.com<mailto:bijuatapache@gmail.com>>
写道:

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, 沈冠璞 <shenguanpu@360.cn<mailto:shenguanpu@360.cn>>
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


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