com.google.common.cache.RemovalNotification#getCause ( )源码实例Demo

下面列出了com.google.common.cache.RemovalNotification#getCause ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: rubix   文件: BookKeeper.java
@Override
public void onRemoval(RemovalNotification<String, FileMetadata> notification)
{
  FileMetadata md = notification.getValue();
  try {
    md.closeAndCleanup(notification.getCause(), fileMetadataCache);
    if (!isValidatingCachingBehavior(md.getRemotePath())) {
      switch (notification.getCause()) {
        case EXPLICIT:
          cacheInvalidationCount.inc();
          break;
        case SIZE:
          cacheEvictionCount.inc();
          break;
        case EXPIRED:
          cacheExpiryCount.inc();
          break;
        default:
          break;
      }
    }
  }
  catch (IOException e) {
    log.warn("Could not cleanup FileMetadata for " + notification.getKey(), e);
  }
}
 
源代码2 项目: Singularity   文件: SingularityOfferCache.java
@Override
public void onRemoval(RemovalNotification<String, CachedOffer> notification) {
  if (notification.getCause() == RemovalCause.EXPLICIT) {
    return;
  }

  LOG.debug(
    "Cache removal for {} due to {}",
    notification.getKey(),
    notification.getCause()
  );

  synchronized (offerCache) {
    if (notification.getValue().offerState == OfferState.AVAILABLE) {
      declineOffer(notification.getValue());
    } else {
      notification.getValue().expire();
    }
  }
}
 
源代码3 项目: meghanada-server   文件: MemberCacheLoader.java
@Override
public void onRemoval(final RemovalNotification<String, List<MemberDescriptor>> notification) {
  final RemovalCause cause = notification.getCause();
  if (cause.equals(RemovalCause.EXPLICIT)) {
    final String key = notification.getKey();
    boolean b = ProjectDatabaseHelper.deleteMemberDescriptors(key);
  }
}
 
源代码4 项目: meghanada-server   文件: JavaSourceLoader.java
@Override
public void onRemoval(final RemovalNotification<File, Source> notification) {
  final RemovalCause cause = notification.getCause();

  final Config config = Config.load();
  if (config.useSourceCache() && cause.equals(RemovalCause.EXPLICIT)) {
    final Source source = notification.getValue();
    try {
      deleteSource(source);
    } catch (Exception e) {
      log.catching(e);
    }
  }
}
 
源代码5 项目: StormCV   文件: BatchInputBolt.java
/**
 * Callback method for removal of items from the histories cache. Items removed from the cache need to be acked or failed
 * according to the reason they were removed
 */
@Override
public void onRemoval(RemovalNotification<CVParticle, String> notification) {
	// make sure the CVParticle object is removed from the history (even if removal was automatic!)
	history.clear(notification.getKey(), notification.getValue());
	if(notification.getCause() == RemovalCause.EXPIRED || notification.getCause() == RemovalCause.SIZE){
		// item removed automatically --> fail the tuple
		collector.fail(notification.getKey().getTuple());
	}else{
		// item removed explicitly --> ack the tuple
		collector.ack(notification.getKey().getTuple());
	}
}
 
源代码6 项目: phoenix   文件: GuidePostsCacheImpl.java
@Override
public void onRemoval(RemovalNotification<GuidePostsKey, GuidePostsInfo> notification) {
    if (logger.isTraceEnabled()) {
        final RemovalCause cause = notification.getCause();
        if (wasEvicted(cause)) {
            GuidePostsKey key = notification.getKey();
            logger.trace("Cached stats for {} with size={}bytes was evicted due to cause={}",
                    new Object[] {key, notification.getValue().getEstimatedSize(),
                            cause});
        }
    }
}
 
private void onRemoved(RemovalNotification notification) {
   if(notification.getCause() != RemovalCause.EXPLICIT) {
      logger.info("voice context for {} removed from cache because {}", notification.getKey(), notification.getCause());
   }
}
 
源代码8 项目: teku   文件: FinalizedStateCache.java
private void onRemovedFromCache(
    final RemovalNotification<UnsignedLong, BeaconState> removalNotification) {
  if (removalNotification.getCause() != RemovalCause.REPLACED) {
    availableSlots.remove(removalNotification.getKey());
  }
}
 
源代码9 项目: xian   文件: LocalNodeManager.java
public void onRemoval(RemovalNotification<String, NotifyHandler> notification) {
    String description;
    switch (notification.getCause()) {
        case REPLACED:
            description = "出现重复的ssid的notifyHandler,原ssid对应的notifyHandler被移除,ssid=" + notification.getKey();
            LOG.error(new JSONObject() {{
                put("type", "notifyHandlerMapRemoval");
                put("mapSize", handleMap.size());
                put("cause", notification.getCause().name());
                put("ssid", notification.getKey());
                put("notifyHandler", notification.getValue());
                put("description", description);
            }});
            break;
        case EXPIRED:
            description = "notifyHandler已过期:" + notification.getKey();
            LOG.info(new JSONObject() {{
                put("type", "notifyHandlerMapRemoval");
                put("mapSize", handleMap.size());
                put("cause", notification.getCause().name());
                put("ssid", notification.getKey());
                put("notifyHandler", notification.getValue());
                put("description", description);
            }});
            break;
        case SIZE:
            description = "notifyHandlerMap的size超过上限,可能是内存泄漏";
            LOG.info(new JSONObject() {{
                put("type", "notifyHandlerMapRemoval");
                put("mapSize", handleMap.size());
                put("cause", notification.getCause().name());
                put("ssid", notification.getKey());
                put("notifyHandler", notification.getValue());
                put("description", description);
            }});
            break;
        default:
            LOG.debug(new JSONObject() {{
                put("type", "notifyHandlerMapRemoval");
                put("mapSize", handleMap.size());
                put("cause", notification.getCause().name());
                put("ssid", notification.getKey());
                put("notifyHandler", notification.getValue());
                put("description", "正常删除");
            }});
    }
}