use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.NodeCache in project nakadi by zalando.
the class AbstractZkSubscriptionClient method subscribeForCursorsReset.
@Override
public final Closeable subscribeForCursorsReset(final Runnable listener) throws NakadiRuntimeException, UnsupportedOperationException {
final NodeCache cursorResetCache = new NodeCache(getCurator(), resetCursorPath);
cursorResetCache.getListenable().addListener(listener::run);
try {
cursorResetCache.start();
} catch (final Exception e) {
throw new NakadiRuntimeException(e);
}
return () -> {
try {
cursorResetCache.getListenable().clear();
cursorResetCache.close();
} catch (final IOException e) {
throw new NakadiRuntimeException(e);
}
};
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.NodeCache in project xian by happyyangyuan.
the class ZkKeyValueCacheUtil method createNodeCache.
private static NodeCache createNodeCache(String subPath) {
String fullPath = getFullPath(subPath);
NodeCache nodeCache = new NodeCache(ZkConnection.client, fullPath);
try {
nodeCache.start();
} catch (Exception e) {
LOG.error(e);
}
nodeCache.getListenable().addListener(() -> {
String newDataStr = new String(nodeCache.getCurrentData().getData());
LOG.info("监听到zk缓存取值有变化:" + fullPath + "=" + newDataStr);
loadingCache.get(subPath).snd = newDataStr;
});
return nodeCache;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.NodeCache in project Mycat-Server by MyCATApache.
the class ZktoXmlMain method loadZkWatch.
private static void loadZkWatch(Set<String> setPaths, final CuratorFramework zkConn, final ZookeeperProcessListen zkListen) throws Exception {
if (null != setPaths && !setPaths.isEmpty()) {
for (String path : setPaths) {
// 进行本地节点的监控操作
NodeCache node = runWatch(zkConn, path, zkListen);
node.start();
LOGGER.info("ZktoxmlMain loadZkWatch path:" + path + " regist success");
}
}
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.NodeCache in project Mycat-Server by MyCATApache.
the class ZktoXmlMain method runWatch.
/**
* 进行zk的watch操作
* 方法描述
* @param zkConn zk的连接信息
* @param path 路径信息
* @param zkListen 监控路径信息
* @throws Exception
* @创建日期 2016年9月20日
*/
private static NodeCache runWatch(final CuratorFramework zkConn, final String path, final ZookeeperProcessListen zkListen) throws Exception {
final NodeCache cache = new NodeCache(zkConn, path);
NodeCacheListener listen = new NodeCacheListener() {
@Override
public void nodeChanged() throws Exception {
LOGGER.info("ZktoxmlMain runWatch process path event start ");
LOGGER.info("NodeCache changed, path is: " + cache.getCurrentData().getPath());
String notPath = cache.getCurrentData().getPath();
// 进行通知更新
zkListen.notifly(notPath);
LOGGER.info("ZktoxmlMain runWatch process path event over");
}
};
// 添加监听
cache.getListenable().addListener(listen);
return cache;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.NodeCache in project dubbo by alibaba.
the class Curator5ZookeeperClient method removeTargetDataListener.
@Override
protected void removeTargetDataListener(String path, Curator5ZookeeperClient.NodeCacheListenerImpl nodeCacheListener) {
NodeCache nodeCache = nodeCacheMap.get(path);
if (nodeCache != null) {
nodeCache.getListenable().removeListener(nodeCacheListener);
}
nodeCacheListener.dataListener = null;
}
Aggregations