List of usage examples for com.google.common.cache RemovalNotification getKey
@Nullable
@Override
public K getKey()
From source file:org.rub.nds.saml.samllib.verifier.SAMLIDCache.java
/** * *//*from w w w . j a v a2 s.c o m*/ public static void initialize() { SAMLIDCache.cachedIDs = CacheBuilder.newBuilder().maximumSize(1000) .expireAfterWrite(SAMLIDCache.cacheDuration, TimeUnit.MINUTES) .removalListener(new RemovalListener<String, String>() { @Override public void onRemoval(RemovalNotification<String, String> rn) { _log.debug("SAML Response ID " + rn.getKey() + " has been removed from the cache."); } }).build(new CacheLoader<String, String>() { @Override public String load(String key) { return key; } }); }
From source file:rub.nds.oidc.oidc_op.OIDCCache.java
/** * *///from www .j a v a 2 s . co m public static void initialize() { OIDCCache.cachedIDs = CacheBuilder.newBuilder().maximumSize(1000) .expireAfterWrite(OIDCCache.cacheDuration, TimeUnit.MINUTES) .removalListener(new RemovalListener<String, TokenCollection>() { @Override public void onRemoval(RemovalNotification<String, TokenCollection> rn) { _log.debug("ID " + rn.getKey() + " has been removed from the cache."); } }).build(new CacheLoader<String, TokenCollection>() { @Override public TokenCollection load(String key) throws ExecutionException { return getElement(key); } }); }
From source file:rapture.kernel.cache.KernelCaches.java
private static Cache<RaptureURI, Optional<String>> setupObjectStorageCache() { return CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES) .removalListener(new RemovalListener<RaptureURI, Optional<String>>() { @Override//from ww w.j av a 2 s . c o m public void onRemoval(RemovalNotification<RaptureURI, Optional<String>> notification) { if (notification.getCause() != RemovalCause.REPLACED) { if (log.isTraceEnabled()) log.trace("Removed " + notification.getKey() + " from local cache because " + notification.getCause()); } } }).build(); }
From source file:com.comcast.cdn.traffic_control.traffic_router.core.dns.ZoneManager.java
private static LoadingCache<ZoneKey, Zone> createZoneCache(final ZoneCacheType cacheType, final CacheBuilderSpec spec) { final RemovalListener<ZoneKey, Zone> removalListener = new RemovalListener<ZoneKey, Zone>() { public void onRemoval(final RemovalNotification<ZoneKey, Zone> removal) { LOGGER.debug(cacheType + " " + removal.getKey().getClass().getSimpleName() + " " + removal.getKey().getName() + " evicted from cache: " + removal.getCause()); }//from www . j a va 2s .co m }; return CacheBuilder.from(spec).recordStats().removalListener(removalListener) .build(new CacheLoader<ZoneKey, Zone>() { final boolean writeZone = (cacheType == ZoneCacheType.STATIC) ? true : false; public Zone load(final ZoneKey zoneKey) throws IOException, GeneralSecurityException { LOGGER.debug("loading " + cacheType + " " + zoneKey.getClass().getSimpleName() + " " + zoneKey.getName()); return loadZone(zoneKey, writeZone); } public ListenableFuture<Zone> reload(final ZoneKey zoneKey, final Zone prevZone) throws IOException, GeneralSecurityException { final ListenableFutureTask<Zone> zoneTask = ListenableFutureTask .create(new Callable<Zone>() { public Zone call() throws IOException, GeneralSecurityException { return loadZone(zoneKey, writeZone); } }); zoneExecutor.execute(zoneTask); return zoneTask; } }); }
From source file:com.oneops.opamp.cache.WatchedByCacheAttributeRemovalListener.java
@Override public void onRemoval(RemovalNotification<String, String> notif) { logger.info("Removing attribute(notifyOnlyifStatechanges) for " + notif.getKey() + " as it's " + notif.getCause());//from ww w .ja v a 2 s.c o m }
From source file:com.oneops.antenna.cache.SinkRemovalListener.java
@Override public void onRemoval(RemovalNotification<SinkKey, List<BasicSubscriber>> notif) { logger.warn("Removing sink subscribers for " + notif.getKey().getNsPath() + " as it's " + notif.getCause()); }
From source file:com.streamsets.pipeline.lib.jdbc.multithread.cache.JdbcTableReadContextInvalidationListener.java
@Override public void onRemoval( RemovalNotification<TableRuntimeContext, TableReadContext> tableReadContextRemovalNotification) { Optional.ofNullable(tableReadContextRemovalNotification.getKey()).ifPresent(tableContext -> { LOG.debug("Closing statement and result set for : {}", tableContext.getQualifiedName()); Optional.ofNullable(tableReadContextRemovalNotification.getValue()).ifPresent(readContext -> { readContext.setNumberOfBatches(0); //Destroy and close statement/result set. readContext.destroy();//from w w w . j av a2 s.co m }); }); }
From source file:ru.justblender.secure.SecureCommands.java
private void notifyExpired(RemovalNotification notification) { CommandSender sender = (CommandSender) notification.getKey(); if (sender == null || notification.getCause() != RemovalCause.EXPIRED) return;//from w w w . j a va 2 s.c om sender.sendMessage( "cYou couldn't enter the secret code in time for command \"" + notification.getValue() + "\"."); getLogger().severe(sender.getName() + " failed 2FA (timed out) for command /" + notification.getValue()); }
From source file:co.cask.cdap.explore.service.hive.ActiveOperationRemovalHandler.java
@Override public void onRemoval(RemovalNotification<QueryHandle, OperationInfo> notification) { LOG.trace("Got removal notification for handle {} with cause {}", notification.getKey(), notification.getCause());/*from w ww .java2 s .com*/ executorService.submit(new ResourceCleanup(notification.getKey(), notification.getValue())); }
From source file:org.trimou.engine.cache.DefaultComputingCacheFactory.java
@Override public <K, V> ComputingCache<K, V> create(final String consumerId, final Function<K, V> computingFunction, final Long expirationTimeout, final Long maxSize, final Listener<K> listener) { CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder(); if (expirationTimeout != null && expirationTimeout > 0) { builder.expireAfterWrite(expirationTimeout, TimeUnit.MILLISECONDS); }/*from ww w. java2 s. c o m*/ if (maxSize != null) { builder.maximumSize(maxSize); } if (listener != null) { builder.removalListener(new RemovalListener<K, V>() { @Override public void onRemoval(RemovalNotification<K, V> notification) { listener.entryInvalidated(notification.getKey(), notification.getCause().toString()); } }); } return new LoadingCacheAdapter<K, V>(builder.build(new CacheLoaderAdapter<K, V>(computingFunction))); }