Netflix/curator — Issue #14: Watcher events include the namespace in the path
Author: crpalmer
Created: 2012-01-04 21:30:24+00:00
State: open

Unless I am missing something, if I have an object that wants to use watches then I must pass it the namespace that was used with the CuratorFramework client was created.

In the following tiny example program, I would expect it to print "/foo" for the path but it prints "/namespace/foo".

public class WatchIncludesNamespace {

public static void main(String[] args) throws Exception {
CuratorFramework client = CuratorFrameworkFactory.builder().connectString("pt.devel.vivisimo.com:21181")
.retryPolicy(new RetryOneTime(10)).namespace("/namespace").build();
client.start();
Watcher watcher = new Watcher() {

public void process(WatchedEvent event) {
System.out.println("Event for " + event.getPath());
}
};
try {
client.create().forPath("/foo", null);
} catch (NodeExistsException e) {
}
client.getData().usingWatcher(watcher).forPath("/foo");
client.setData().forPath("/foo", "bar".getBytes("UTF-8"));
client.close();
}
}