Java 类org.apache.curator.framework.api.CuratorListener 实例源码

项目:redirector    文件:ListenerProxy.java   
@Override
public void addListener(Object listener) {
    CuratorListener curatorListener = (CuratorListener) listener;
    if (curator != null) {
        curator.getCuratorListenable().addListener(curatorListener);
    }
    listeners.add(curatorListener);
}
项目:redirector    文件:ListenerProxy.java   
@Override
public void addListener(Object listener, Executor executor) {
    CuratorListener curatorListener = (CuratorListener) listener;
    if (curator != null) {
        curator.getCuratorListenable().addListener(curatorListener, executor);
    }
    listeners.add(curatorListener);
}
项目:redirector    文件:ListenerProxy.java   
@Override
public void removeListener(Object listener) {
    CuratorListener curatorListener = (CuratorListener) listener;
    if (curator != null) {
        curator.getCuratorListenable().removeListener(curatorListener);
    }
    listeners.remove(curatorListener);
}
项目:redirector    文件:ListenerProxy.java   
public void clearCurator() {
    for (CuratorListener curatorListener : listeners) {
        if (curator != null) {
            curator.getCuratorListenable().removeListener(curatorListener);
        }
    }
}
项目:redirector    文件:ListenerProxy.java   
public void updateCurator(CuratorFramework curator) {
    this.curator = curator;
    for (CuratorListener curatorListener : listeners) {
        if (this.curator != null) {
            this.curator.getCuratorListenable().addListener(curatorListener);
        }
    }
}
项目:jstorm-0.9.6.3-    文件:Zookeeper.java   
/**
 * connect ZK, register Watch/unhandle Watch
 * 
 * @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);
                    JStormUtils.halt_process(1,
                            "Unrecoverable Zookeeper error");

                }
            });
    fk.start();
    return fk;
}
项目:learn_jstorm    文件:Zookeeper.java   
/**
 * connect ZK, register Watch/unhandle Watch
 * 
 * @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);
                    JStormUtils.halt_process(1,
                            "Unrecoverable Zookeeper error");

                }
            });
    fk.start();
    return fk;
}
项目:jstrom    文件:Zookeeper.java   
/**
 * connect ZK, register Watch/unhandle Watch
 * 
 * @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);
            JStormUtils.halt_process(1, "Unrecoverable Zookeeper error");

        }
    });
    fk.start();
    return fk;
}
项目:Tstream    文件:Zookeeper.java   
/**
 * connect ZK, register Watch/unhandle Watch
 * 
 * @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);
                    JStormUtils.halt_process(1,
                            "Unrecoverable Zookeeper error");

                }
            });
    fk.start();
    return fk;
}
项目:cultivar_old    文件:DefaultCuratorManagementService.java   
@Inject
DefaultCuratorManagementService(@Curator final CuratorFramework framework,
        final Set<ConnectionStateListener> connectionStateListeners, final Set<CuratorListener> curatorListeners,
        final Set<UnhandledErrorListener> unhandledErrorListeners) {
    this.framework = framework;
    this.connectionStateListeners = connectionStateListeners;
    this.curatorListeners = curatorListeners;
    this.unhandledErrorListeners = unhandledErrorListeners;
}
项目:cultivar    文件:DefaultCuratorManagementService.java   
@Inject
DefaultCuratorManagementService(@Curator final CuratorFramework framework,
        final Set<ConnectionStateListener> connectionStateListeners, final Set<CuratorListener> curatorListeners,
        final Set<UnhandledErrorListener> unhandledErrorListeners) {
    this(framework, connectionStateListeners, curatorListeners, unhandledErrorListeners, LoggerFactory
            .getLogger(DefaultCuratorManagementService.class));
}
项目:cultivar    文件:DefaultCuratorManagementService.java   
DefaultCuratorManagementService(@Curator final CuratorFramework framework,
        final Set<ConnectionStateListener> connectionStateListeners, final Set<CuratorListener> curatorListeners,
        final Set<UnhandledErrorListener> unhandledErrorListeners, final Logger log) {

    this.framework = framework;
    this.connectionStateListeners = connectionStateListeners;
    this.curatorListeners = curatorListeners;
    this.unhandledErrorListeners = unhandledErrorListeners;
    this.log = log;
}
项目:jstorm    文件:Zookeeper.java   
/**
 * 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;
}
项目:vespa    文件:MockCurator.java   
@Override
public Listenable<CuratorListener> getCuratorListenable() {
    throw new UnsupportedOperationException("Not implemented in MockCurator");
}
项目:cultivar_old    文件:CuratorModule.java   
@Override
protected void configure() {
    install(new CuratorInnerModule(dependencies));
    install(new BarrierModule());
    install(new LastKnownStateModule());

    Multibinder.newSetBinder(binder(), CuratorService.class);

    Multibinder.newSetBinder(binder(), UnhandledErrorListener.class);

    Multibinder.newSetBinder(binder(), CuratorListener.class);

    Multibinder<ConnectionStateListener> connectionStateListeners = Multibinder.newSetBinder(binder(),
            ConnectionStateListener.class);

    connectionStateListeners.addBinding().to(ConnectionStateLogger.class).in(Singleton.class);

    bind(CultivarStartStopManager.class).to(DefaultCultivarStartStopManager.class).in(Singleton.class);
}
项目:cultivar_old    文件:DefaultCuratorManagementService.java   
@Override
public void addCuratorListener(final CuratorListener listener) {
    framework.getCuratorListenable().addListener(listener);

}
项目:curator    文件:NamespaceFacade.java   
@Override
public Listenable<CuratorListener> getCuratorListenable()
{
    throw new UnsupportedOperationException("getCuratorListenable() is only available from a non-namespaced CuratorFramework instance");
}
项目:curator    文件:WatcherRemovalFacade.java   
@Override
public Listenable<CuratorListener> getCuratorListenable()
{
    return client.getCuratorListenable();
}
项目:cultivar    文件:CuratorModule.java   
@Override
protected void configure() {
    install(new CuratorInnerModule(dependencies));
    install(new BarrierModule());
    install(new LastKnownStateModule());

    bind(BlankCuratorService.class).annotatedWith(Private.class).to(BlankCuratorService.class).in(Scopes.SINGLETON);

    Multibinder.newSetBinder(binder(), CuratorService.class).addBinding()
            .to(Key.get(BlankCuratorService.class, Private.class));

    Multibinder.newSetBinder(binder(), UnhandledErrorListener.class);

    Multibinder.newSetBinder(binder(), CuratorListener.class);

    Multibinder.newSetBinder(binder(), ServiceManager.class, Cultivar.class);

    Multibinder<ConnectionStateListener> connectionStateListeners = Multibinder.newSetBinder(binder(),
            ConnectionStateListener.class);

    connectionStateListeners.addBinding().to(ConnectionStateLogger.class).in(Singleton.class);

    bind(CultivarStartStopManager.class).to(DefaultCultivarStartStopManager.class).in(Singleton.class);
}
项目:cultivar    文件:DefaultCuratorManagementService.java   
@Override
public void addCuratorListener(final CuratorListener listener) {
    framework.getCuratorListenable().addListener(listener);

}
项目:cultivar    文件:NamespacedCuratorFramework.java   
@Override
public Listenable<CuratorListener> getCuratorListenable() {
    return delegateFramework.getCuratorListenable();
}
项目:cultivar_old    文件:CuratorManagementService.java   
/**
 * Adds a curator listener to Curator.
 */
void addCuratorListener(CuratorListener listener);
项目:cultivar    文件:CuratorManagementService.java   
/**
 * Adds a curator listener to Curator.
 */
void addCuratorListener(CuratorListener listener);