use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.NodeCache in project fabric8 by jboss-fuse.
the class HttpMappingRuleConfiguration method initializeNodeCache.
private void initializeNodeCache(final Map<String, ?> configuration) {
if (immediateUpdate == true) {
if (nodeCache == null) {
final String containerName = fabricService.get().getCurrentContainer().getId();
final String factoryPid = (String) configuration.get("fabric.zookeeper.pid");
nodeCache = new NodeCache(curator.get(), ZkPath.CONFIG_CONTAINER.getPath(containerName));
nodeCache.getListenable().addListener(new NodeCacheListener() {
@Override
public void nodeChanged() throws Exception {
LOG.info("Detected version change in container {} with http gateway profile {}.", containerName, factoryPid);
updateConfiguration(configuration);
}
});
try {
nodeCache.start();
LOG.info("Enabling immediateUpdate in HTTP Gateway on container {} for factoryPid={}.", containerName, factoryPid);
} catch (Exception e) {
LOG.warn("Possible problems when enabling immediateUpdate in HTTP Gateway rule", e);
}
}
} else {
if (nodeCache != null) {
try {
LOG.info("Disabling immediateUpdate in HTTP Gateway");
nodeCache.close();
nodeCache = null;
} catch (IOException e) {
LOG.warn("Possible problems when disabling immediateUpdate in HTTP Gateway", e);
}
}
}
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.NodeCache in project Mycat_plus by coderczp.
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_plus by coderczp.
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 dble by actiontech.
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) {
final NodeCache node = new NodeCache(zkConn, path);
node.start(true);
runWatch(node, zkListen);
LOGGER.info("ZktoxmlMain loadZkWatch path:" + path + " regist success");
}
}
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.NodeCache in project xian by happyyangyuan.
the class ServiceDiscoveryImpl method makeNodeCache.
private NodeCache makeNodeCache(final ServiceInstance<T> instance) {
if (!watchInstances) {
return null;
}
final NodeCache nodeCache = new NodeCache(client, pathForInstance(instance.getName(), instance.getId()));
try {
nodeCache.start(true);
} catch (Exception e) {
ThreadUtils.checkInterrupted(e);
log.error("Could not start node cache for: " + instance, e);
}
NodeCacheListener listener = new NodeCacheListener() {
@Override
public void nodeChanged() throws Exception {
if (nodeCache.getCurrentData() != null) {
ServiceInstance<T> newInstance = serializer.deserialize(nodeCache.getCurrentData().getData());
Entry<T> entry = services.get(newInstance.getId());
if (entry != null) {
synchronized (entry) {
entry.service = newInstance;
}
}
} else {
log.warn("Instance data has been deleted for: " + instance);
}
}
};
nodeCache.getListenable().addListener(listener);
return nodeCache;
}
Aggregations