请问如何查看znodes的子znodes?
how to watch the sub-znodes of znodes please?
我使用 Curator 编程 Zookeeper.I 想要观看 zonde.My 的子 znode 代码如下:
CuratorFramework frameWork = CuratorFrameworkFactory.builder()
.retryPolicy(new RetryNTimes(3, 1000))
.connectString("127.0.0.1:2181").build();
frameWork.start();
CuratorWatcher watcher = new CuratorWatcher () {
@Override
public void process(WatchedEvent event) throws Exception
{
System.out.println("event :" + event);
}
};
frameWork.getChildren().usingWatcher(watcher).forPath("/aa");
frameWork.setData().forPath("/aa/dd", "asdfd".getBytes());
当调用“/aa/dd”的setdata时,我希望观察者triggered.But失败,请问有人知道吗?
策展人有一个食谱可以做到这一点。请参阅 TreeCache:http://curator.apache.org/curator-recipes/tree-cache.html
我使用 Curator 编程 Zookeeper.I 想要观看 zonde.My 的子 znode 代码如下:
CuratorFramework frameWork = CuratorFrameworkFactory.builder()
.retryPolicy(new RetryNTimes(3, 1000))
.connectString("127.0.0.1:2181").build();
frameWork.start();
CuratorWatcher watcher = new CuratorWatcher () {
@Override
public void process(WatchedEvent event) throws Exception
{
System.out.println("event :" + event);
}
};
frameWork.getChildren().usingWatcher(watcher).forPath("/aa"); frameWork.setData().forPath("/aa/dd", "asdfd".getBytes());
当调用“/aa/dd”的setdata时,我希望观察者triggered.But失败,请问有人知道吗?
策展人有一个食谱可以做到这一点。请参阅 TreeCache:http://curator.apache.org/curator-recipes/tree-cache.html