I am new to zookeeper. I have written simple program to create Persistent Node. Its working but giving exception once execution is completed.I tried to search on google but there is no satisfactory answer. Can any one advice me anything.
public class ZkProg {
public static void main(String[] args) throws IOException, KeeperException, InterruptedException
{
ZooKeeper zk=new ZooKeeper("localhost",1281, null);
zk.create("/zookeeper/Names",new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
//zk.delete("/zookeeper/Names",-1);
zk.close();
}
}
I also had this error being logged. It is because the Zookeeper watcher is null. In the call to the constructor, the third parameter is a watcher:
ZooKeeper zk=new ZooKeeper("localhost",1281, null);
It seems that the Zookeeper ClientCnxn tries to call process on the watcher, even if it is null. However, it catches the exception and just logs the error and moves on.
If you don't want to watch events, you can write your own "StubWatcher".
Create a class that inherits from Watcher
and implement the process
method with empty body.
That should do it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.