Example usage for com.google.common.cache RemovalNotification wasEvicted

List of usage examples for com.google.common.cache RemovalNotification wasEvicted

Introduction

In this page you can find the example usage for com.google.common.cache RemovalNotification wasEvicted.

Prototype

public boolean wasEvicted() 

Source Link

Document

Returns true if there was an automatic removal due to eviction (the cause is neither RemovalCause#EXPLICIT nor RemovalCause#REPLACED ).

Usage

From source file:org.elasticsearch.index.cache.field.data.soft.SoftFieldDataCache.java

@Override
public void onRemoval(RemovalNotification<String, FieldData> removalNotification) {
    if (removalNotification.wasEvicted()) {
        evictions.inc();/*w  w  w  . j  a  v a 2 s  . c  o  m*/
    }
}

From source file:com.ericsson.gerrit.plugins.highavailability.cache.CacheEvictionHandler.java

@Override
public void onRemoval(String plugin, String cache, RemovalNotification<K, V> notification) {
    if (!Context.isForwardedEvent() && !notification.wasEvicted() && matcher.matches(cache)) {
        executor.execute(new CacheEvictionTask(cache, notification.getKey()));
    }/*from w  w  w .j  av a2  s .co m*/
}

From source file:com.ericsson.gerrit.plugins.evictcache.EvictCacheHandler.java

@Override
public void onRemoval(String pluginName, String cacheName, RemovalNotification<K, V> notification) {
    if (!Context.isForwardedEvent() && !notification.wasEvicted() && isSynchronized(cacheName)) {
        executor.execute(new EvictCacheTask(pluginName, cacheName, notification.getKey()));
    }/*from   w w w  .j a v a 2s. c  o m*/
}

From source file:org.elasticsearch.index.cache.filter.ShardFilterCache.java

@Override
public void onRemoval(RemovalNotification<WeightedFilterCache.FilterCacheKey, DocIdSet> removalNotification) {
    if (removalNotification.wasEvicted()) {
        evictionsMetric.inc();//from w  w w .ja  v a  2s.  co  m
    }
    if (removalNotification.getValue() != null) {
        totalMetric.dec(DocIdSets.sizeInBytes(removalNotification.getValue()));
    }
}

From source file:org.apache.distributedlog.logsegment.LogSegmentMetadataCache.java

@Override
public void onRemoval(RemovalNotification<String, LogSegmentMetadata> notification) {
    if (notification.wasEvicted()) {
        if (logger.isDebugEnabled()) {
            logger.debug("Log segment of {} was evicted.", notification.getKey());
        }//  w w w .j av a  2 s  . c  o  m
    }
}

From source file:org.elasticsearch.index.cache.query.ShardQueryCache.java

@Override
public void onRemoval(RemovalNotification<IndicesQueryCache.Key, BytesReference> removalNotification) {
    if (removalNotification.wasEvicted()) {
        evictionsMetric.inc();/*from www.  ja va 2s  .  c  om*/
    }
    long dec = 0;
    if (removalNotification.getKey() != null) {
        dec += removalNotification.getKey().ramBytesUsed();
    }
    if (removalNotification.getValue() != null) {
        dec += removalNotification.getValue().length();
    }
    totalMetric.dec(dec);
}

From source file:org.elasticsearch.index.cache.request.ShardRequestCache.java

@Override
public void onRemoval(
        RemovalNotification<IndicesRequestCache.Key, IndicesRequestCache.Value> removalNotification) {
    if (removalNotification.wasEvicted()) {
        evictionsMetric.inc();//from  w  w  w .  j av  a2s.c o  m
    }
    long dec = 0;
    if (removalNotification.getKey() != null) {
        dec += removalNotification.getKey().ramBytesUsed();
    }
    if (removalNotification.getValue() != null) {
        dec += removalNotification.getValue().ramBytesUsed();
    }
    totalMetric.dec(dec);
}

From source file:de.metas.ui.web.view.DefaultViewsRepositoryStorage.java

private final void onViewRemoved(final RemovalNotification<Object, Object> notification) {
    final IView view = (IView) notification.getValue();
    final ViewCloseReason closeReason = ViewCloseReason.fromCacheEvictedFlag(notification.wasEvicted());
    view.close(closeReason);//w w w .j a v a2 s  .  c  o  m
}

From source file:org.onosproject.incubator.rpc.grpc.LinkProviderServiceServerProxy.java

private void onRemove(RemovalNotification<Pair<String, LinkKey>, LinkDescription> n) {
    if (n.wasEvicted()) {
        getLinkProviderServiceFor(n.getKey().getLeft()).linkVanished(n.getValue());
    }/*w w w. j  av  a2 s.com*/
}

From source file:org.apache.aurora.scheduler.preemptor.BiCache.java

@Inject
public BiCache(StatsProvider statsProvider, BiCacheSettings settings, final Clock clock) {

    requireNonNull(clock);/*from   www.ja  v a2  s .  co  m*/
    this.cache = CacheBuilder.newBuilder()
            .expireAfterWrite(settings.expireAfter.as(Time.MINUTES), TimeUnit.MINUTES).ticker(new Ticker() {
                @Override
                public long read() {
                    return clock.nowNanos();
                }
            }).removalListener(new RemovalListener<K, V>() {
                @Override
                public void onRemoval(RemovalNotification<K, V> notification) {
                    removalCounter.getAndIncrement();
                    if (notification.wasEvicted()) {
                        expirationCounter.incrementAndGet();
                    }
                    inverse.remove(notification.getValue(), notification.getKey());
                }
            }).build();

    statsProvider.makeGauge(settings.cacheName + "_cache_size", cache::size);
    removalCounter = statsProvider.makeCounter(settings.cacheName + "_cache_removals");
    expirationCounter = statsProvider.makeCounter(settings.cacheName + "_cache_expiration_removals");
    explictRemovalCounter = statsProvider.makeCounter(settings.cacheName + "_cache_explicit_removals");
}