本文整理汇总了Java中org.apache.curator.framework.api.CuratorListener类的典型用法代码示例。如果您正苦于以下问题:Java CuratorListener类的具体用法?Java CuratorListener怎么用?Java CuratorListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CuratorListener类属于org.apache.curator.framework.api包,在下文中一共展示了CuratorListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addListener
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
@Override
public void addListener(Object listener) {
CuratorListener curatorListener = (CuratorListener) listener;
if (curator != null) {
curator.getCuratorListenable().addListener(curatorListener);
}
listeners.add(curatorListener);
}
示例2: removeListener
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
@Override
public void removeListener(Object listener) {
CuratorListener curatorListener = (CuratorListener) listener;
if (curator != null) {
curator.getCuratorListenable().removeListener(curatorListener);
}
listeners.remove(curatorListener);
}
示例3: clearCurator
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
public void clearCurator() {
for (CuratorListener curatorListener : listeners) {
if (curator != null) {
curator.getCuratorListenable().removeListener(curatorListener);
}
}
}
示例4: updateCurator
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
public void updateCurator(CuratorFramework curator) {
this.curator = curator;
for (CuratorListener curatorListener : listeners) {
if (this.curator != null) {
this.curator.getCuratorListenable().addListener(curatorListener);
}
}
}
示例5: mkClient
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
/**
* 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;
}
示例6: mkClient
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
/**
* 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;
}
示例7: DefaultCuratorManagementService
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
@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;
}
示例8: DefaultCuratorManagementService
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
@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));
}
示例9: mkClient
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
/**
* 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;
}
示例10: getCuratorListenable
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
@Override
public Listenable<CuratorListener> getCuratorListenable() {
throw new UnsupportedOperationException("Not implemented in MockCurator");
}
示例11: configure
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
@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);
}
示例12: addCuratorListener
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
@Override
public void addCuratorListener(final CuratorListener listener) {
framework.getCuratorListenable().addListener(listener);
}
示例13: getCuratorListenable
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
@Override
public Listenable<CuratorListener> getCuratorListenable()
{
throw new UnsupportedOperationException("getCuratorListenable() is only available from a non-namespaced CuratorFramework instance");
}
示例14: getCuratorListenable
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
@Override
public Listenable<CuratorListener> getCuratorListenable()
{
return client.getCuratorListenable();
}
示例15: configure
import org.apache.curator.framework.api.CuratorListener; //导入依赖的package包/类
@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);
}