Search in sources :

Example 1 with TreeCache

use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.TreeCache in project elastic-job by dangdangdotcom.

the class ZookeeperRegistryCenter method get.

@Override
public String get(final String key) {
    TreeCache cache = findTreeCache(key);
    if (null == cache) {
        return getDirectly(key);
    }
    ChildData resultInCache = cache.getCurrentData(key);
    if (null != resultInCache) {
        return null == resultInCache.getData() ? null : new String(resultInCache.getData(), Charsets.UTF_8);
    }
    return getDirectly(key);
}
Also used : TreeCache(org.apache.curator.framework.recipes.cache.TreeCache) ChildData(org.apache.curator.framework.recipes.cache.ChildData)

Example 2 with TreeCache

use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.TreeCache in project elastic-job by dangdangdotcom.

the class MonitorService method dumpDirectly.

private void dumpDirectly(final String path, final List<String> result) {
    for (String each : regCenter.getChildrenKeys(path)) {
        String zkPath = path + "/" + each;
        String zkValue = regCenter.get(zkPath);
        if (null == zkValue) {
            zkValue = "";
        }
        TreeCache treeCache = (TreeCache) regCenter.getRawCache("/" + jobName);
        ChildData treeCacheData = treeCache.getCurrentData(zkPath);
        String treeCachePath = null == treeCacheData ? "" : treeCacheData.getPath();
        String treeCacheValue = null == treeCacheData ? "" : new String(treeCacheData.getData());
        if (zkValue.equals(treeCacheValue) && zkPath.equals(treeCachePath)) {
            result.add(Joiner.on(" | ").join(zkPath, zkValue));
        } else {
            result.add(Joiner.on(" | ").join(zkPath, zkValue, treeCachePath, treeCacheValue));
        }
        dumpDirectly(zkPath, result);
    }
}
Also used : TreeCache(org.apache.curator.framework.recipes.cache.TreeCache) ChildData(org.apache.curator.framework.recipes.cache.ChildData)

Example 3 with TreeCache

use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.TreeCache in project elastic-job by dangdangdotcom.

the class JobNodeStorage method addDataListener.

/**
     * 注册数据监听器.
     * 
     * @param listener 数据监听器
     */
public void addDataListener(final TreeCacheListener listener) {
    TreeCache cache = (TreeCache) regCenter.getRawCache("/" + jobName);
    cache.getListenable().addListener(listener);
}
Also used : TreeCache(org.apache.curator.framework.recipes.cache.TreeCache)

Example 4 with TreeCache

use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.TreeCache in project elastic-job by dangdangdotcom.

the class CloudJobConfigurationListener method getCache.

private TreeCache getCache() {
    TreeCache result = (TreeCache) regCenter.getRawCache(CloudJobConfigurationNode.ROOT);
    if (null != result) {
        return result;
    }
    regCenter.addCacheData(CloudJobConfigurationNode.ROOT);
    return (TreeCache) regCenter.getRawCache(CloudJobConfigurationNode.ROOT);
}
Also used : TreeCache(org.apache.curator.framework.recipes.cache.TreeCache)

Example 5 with TreeCache

use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.TreeCache in project BRFS by zhangnianli.

the class CuratorTreeCache method addListener.

public void addListener(String path, AbstractTreeCacheListener listener) {
    LOG.info("add listener for tree:" + path);
    TreeCache cache = cacheMap.get(path);
    if (cache == null) {
        cache = new TreeCache(client.getInnerClient(), path);
        cacheMap.put(path, cache);
    }
    cache.getListenable().addListener(listener);
}
Also used : TreeCache(org.apache.curator.framework.recipes.cache.TreeCache)

Aggregations

TreeCache (org.apache.curator.framework.recipes.cache.TreeCache)26 ChildData (org.apache.curator.framework.recipes.cache.ChildData)6 TreeCacheListener (org.apache.curator.framework.recipes.cache.TreeCacheListener)5 CuratorFramework (org.apache.curator.framework.CuratorFramework)3 TreeCacheEvent (org.apache.curator.framework.recipes.cache.TreeCacheEvent)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 CloseableExecutorService (org.apache.curator.utils.CloseableExecutorService)2 TreeCache (org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.TreeCache)2 KeeperException (org.apache.zookeeper.KeeperException)2 OperationTimeoutException (org.apache.zookeeper.KeeperException.OperationTimeoutException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ShardingTreeCache (com.vip.saturn.job.sharding.entity.ShardingTreeCache)1 ShardingException (com.vip.saturn.job.sharding.exception.ShardingException)1 DataChangedEvent (io.shardingjdbc.orchestration.reg.listener.DataChangedEvent)1 StandardCharsets (java.nio.charset.StandardCharsets)1 EnumMap (java.util.EnumMap)1 Entry (java.util.Map.Entry)1 CountDownLatch (java.util.concurrent.CountDownLatch)1