* @return
*/
public CuratorFramework mkClient(Map conf, List<String> servers,
Object port, String root, final WatcherCallBack watcher) {
CuratorFramework fk = Utils.newCurator(conf, servers, port, root);
fk.getCuratorListenable().addListener(new CuratorListener() {
@Override
public void eventReceived(CuratorFramework _fk, CuratorEvent e)
throws Exception {
if (e.getType().equals(CuratorEventType.WATCHED)) {
WatchedEvent event = e.getWatchedEvent();
watcher.execute(event.getState(), event.getType(),
event.getPath());
}
}
});
fk.getUnhandledErrorListenable().addListener(
new UnhandledErrorListener() {
@Override
public void unhandledError(String msg, Throwable error) {
String errmsg = "Unrecoverable Zookeeper error, halting process: "
+ msg;
LOG.error(errmsg, error);
StormUtils.halt_process(1,
"Unrecoverable Zookeeper error");
}
});
fk.start();
return fk;
}