本文整理匯總了Java中org.apache.curator.framework.recipes.cache.PathChildrenCache.close方法的典型用法代碼示例。如果您正苦於以下問題:Java PathChildrenCache.close方法的具體用法?Java PathChildrenCache.close怎麽用?Java PathChildrenCache.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.curator.framework.recipes.cache.PathChildrenCache
的用法示例。
在下文中一共展示了PathChildrenCache.close方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: close
import org.apache.curator.framework.recipes.cache.PathChildrenCache; //導入方法依賴的package包/類
/**
* Close the trigger.
*/
@Override
public void close() {
// Close each of the caches that we originally opened
for (PathChildrenCache cache : caches) {
try {
cache.close();
} catch (IOException ex) {
logger.error("Unable to close cache {}", ex);
}
}
if (curator != null) {
curator.close();
curator = null;
curatorHelper = null;
}
isOpen = false;
}
示例2: shutdownGracefully
import org.apache.curator.framework.recipes.cache.PathChildrenCache; //導入方法依賴的package包/類
@Override
public void shutdownGracefully() {
for (PathChildrenCache childrenCache : services.values()) {
try {
childrenCache.close();
} catch (IOException ignored) {}
}
client.close();
}
示例3: removeDataListener
import org.apache.curator.framework.recipes.cache.PathChildrenCache; //導入方法依賴的package包/類
@Override
public void removeDataListener(String path, DataListener listener) {
try {
// 第一步:移除dataListenerMap中的數據
PathChildrenCacheListener pathChildrenCacheListener = dataListenerMap.get(listener);
if(pathChildrenCacheListener == null){
return;
} else {
dataListenerMap.remove(listener);
// 第二步:移除Set<DataListener>中的數據
Set<DataListener> dataListenerSet = dataListenersMap.get(path);
if(dataListenerSet != null && dataListenerSet.contains(listener)){
dataListenerSet.remove(listener);
}
// 第三步:移除dataListenersMap和childDataMap中的數據
if(dataListenerSet == null || dataListenerSet.isEmpty()){
dataListenersMap.remove(path);
childDataMap.remove(path);
}
}
// 第四步:取消監聽,並移除pathChildrenCacheMap中的數據
PathChildrenCache pathChildrenCache = pathChildrenCacheMap.get(path);
if(pathChildrenCache != null){
pathChildrenCache.getListenable().removeListener(pathChildrenCacheListener);
((PathChildrenCacheListenerImpl)listener).unwatch();
if(pathChildrenCache.getListenable().size() == 0){
pathChildrenCacheMap.remove(path);
pathChildrenCache.close();
}
}
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
示例4: unregisterBucketListener
import org.apache.curator.framework.recipes.cache.PathChildrenCache; //導入方法依賴的package包/類
@Override
public void unregisterBucketListener(int bucket) {
PathChildrenCache cache = bucketCacheMap.remove(bucket);
if (cache != null) {
try {
cache.clear();
cache.close();
} catch (IOException e) {
log.warn("unable to close watch on bucket {} with exception {}", bucket, e);
}
}
}
示例5: deleteCacheIfPossible
import org.apache.curator.framework.recipes.cache.PathChildrenCache; //導入方法依賴的package包/類
private void deleteCacheIfPossible(final ConnectionSlot slot) throws IOException {
final boolean hasMoreConnectionsToPartition = ACQUIRED_SLOTS.stream()
.anyMatch(s -> s.getPartition().equals(slot.getPartition())
&& s.getClient().equals(slot.getClient())
&& s.getEventType().equals(slot.getEventType()));
if (!hasMoreConnectionsToPartition) {
final String consumerPath = zkPathForConsumer(slot.getClient(), slot.getEventType(), slot.getPartition());
final PathChildrenCache cache = SLOTS_CACHES.remove(consumerPath);
if (cache != null) {
cache.close();
}
}
}