java读取zookeeper中的配置文件信息
public static void main(String[] args) {String connectString = "127.0.0.1:2181";int sessionTimeout = 4000;Watcher watcher = new Watcher() {public void proce
·
public static void main(String[] args) {
String connectString = "127.0.0.1:2181";
int sessionTimeout = 4000;
Watcher watcher = new Watcher() {
public void process(WatchedEvent event) {
//System.out.println(event.getPath());
}
};
try {
ZooKeeper zooKeeper = new ZooKeeper(connectString, sessionTimeout, watcher);
List<String> list = zooKeeper.getChildren("/config", false);
for (String path : list) {
System.out.println(path);
byte[] b = zooKeeper.getData("/config/"+path, false, null) ;
System.out.println( new String(b) );
}
} catch (IOException e) {
e.printStackTrace();
} catch (KeeperException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
更多推荐
已为社区贡献1条内容
所有评论(0)