org.apache.curator.framework.api.CuratorListener Java Examples

The following examples show how to use org.apache.curator.framework.api.CuratorListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Zookeeper.java    From jstorm with Apache License 2.0 5 votes vote down vote up
/**
 * connect ZK, register watchers
 */
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);
            JStormUtils.halt_process(1, "Unrecoverable zookeeper error");

        }
    });
    fk.start();
    return fk;
}
 
Example #2
Source File: NamespaceFacade.java    From xian with Apache License 2.0 4 votes vote down vote up
@Override
public Listenable<CuratorListener> getCuratorListenable()
{
    throw new UnsupportedOperationException("getCuratorListenable() is only available from a non-namespaced CuratorFramework instance");
}
 
Example #3
Source File: MockCurator.java    From vespa with Apache License 2.0 4 votes vote down vote up
@Override
public Listenable<CuratorListener> getCuratorListenable() {
    throw new UnsupportedOperationException("Not implemented in MockCurator");
}
 
Example #4
Source File: NamespaceFacade.java    From curator with Apache License 2.0 4 votes vote down vote up
@Override
public Listenable<CuratorListener> getCuratorListenable()
{
    throw new UnsupportedOperationException("getCuratorListenable() is only available from a non-namespaced CuratorFramework instance");
}
 
Example #5
Source File: WatcherRemovalFacade.java    From curator with Apache License 2.0 4 votes vote down vote up
@Override
public Listenable<CuratorListener> getCuratorListenable()
{
    return client.getCuratorListenable();
}