本文整理汇总了Java中org.apache.curator.framework.recipes.cache.TreeCache.close方法的典型用法代码示例。如果您正苦于以下问题:Java TreeCache.close方法的具体用法?Java TreeCache.close怎么用?Java TreeCache.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.curator.framework.recipes.cache.TreeCache
的用法示例。
在下文中一共展示了TreeCache.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evictCacheData
import org.apache.curator.framework.recipes.cache.TreeCache; //导入方法依赖的package包/类
@Override
public void evictCacheData(final String cachePath) {
TreeCache cache = caches.remove(cachePath + "/");
if (null != cache) {
cache.close();
}
}
示例2: evictCacheData
import org.apache.curator.framework.recipes.cache.TreeCache; //导入方法依赖的package包/类
@Override
public void evictCacheData(final String cachePath) {
TreeCache cache = caches.remove(cachePath + "/");
if (null != cache) {
cache.close();
}
}
示例3: main
import org.apache.curator.framework.recipes.cache.TreeCache; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
// Connect to zk
try (
CuratorFramework client = CuratorFrameworkFactory.newClient(zookeeprUrls, new ExponentialBackoffRetry(1000, 3));) {
client.start();
System.err.println("CuratorFramework start....");
// Register watcher
TreeCache treeCache = new TreeCache(client, BasePath);
treeCache.getListenable().addListener((curatorClient, treeCacheEvent) -> {
ChildData childData = treeCacheEvent.getData();
if (childData == null) {
System.err.println("No data in event" + treeCacheEvent);
} else {
System.err.println("Receive event:"
+ "type:" + treeCacheEvent.getType()
+ ", path:" + childData.getPath()
+ ", data:" + String.valueOf(childData.getData())
+ ", stat:" + childData.getStat());
}
});
treeCache.start();
System.err.println("tree cache start..");
TimeUnit.MINUTES.sleep(5);
treeCache.close();
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: close
import org.apache.curator.framework.recipes.cache.TreeCache; //导入方法依赖的package包/类
@Override
public void close() {
if (this.running.compareAndSet(true, false)) {
for (TreeCache cache : this.caches.values()) {
cache.close();
}
this.caches = null;
}
}