@Override public int evictBlocksByHfileName(String hfileName) { stats.evicted(0, true); // Just assuming only one block for file here. return 0; }
@Override public boolean evictBlock(BlockCacheKey cacheKey) { stats.evicted(0, cacheKey != null ? cacheKey.isPrimary() : true); return false; }
stats.evicted(block.getCachedTime(), block.getCacheKey().isPrimary()); if (victimHandler != null) { victimHandler.cacheBlock(block.getCacheKey(), block.getBuffer());
@Override public void onEviction(BlockCacheKey key, SingleSizeCache notifier) { stats.evicted(); backingStore.remove(key); }
@Override public int evictBlocksByHfileName(String hfileName) { stats.evicted(0, true); // Just assuming only one block for file here. return 0; }
protected long evictBlock(CachedBlock block) { map.remove(block.getCacheKey()); updateSizeMetrics(block, true); elements.decrementAndGet(); stats.evicted(); return block.heapSize(); }
@Override public boolean evictBlock(BlockCacheKey cacheKey) { stats.evicted(0, cacheKey != null ? cacheKey.isPrimary() : true); return false; }
@Override public boolean evictBlock(BlockCacheKey cacheKey) { stats.evict(); boolean cacheA = onHeapCache.evictBlock(cacheKey); boolean cacheB = offHeapCache.evictBlock(cacheKey); boolean evicted = cacheA || cacheB; if (evicted) { stats.evicted(); } return evicted; }
private void doEviction(BlockCacheKey key, CacheablePair evictedBlock) { long evictedHeap = 0; synchronized (evictedBlock) { if (evictedBlock.serializedData == null) { // someone else already freed return; } evictedHeap = evictedBlock.heapSize(); ByteBuffer bb = evictedBlock.serializedData; evictedBlock.serializedData = null; backingStore.free(bb); // We have to do this callback inside the synchronization here. // Otherwise we can have the following interleaving: // Thread A calls getBlock(): // SlabCache directs call to this SingleSizeCache // It gets the CacheablePair object // Thread B runs eviction // doEviction() is called and sets serializedData = null, here. // Thread A sees the null serializedData, and returns null // Thread A calls cacheBlock on the same block, and gets // "already cached" since the block is still in backingStore if (actionWatcher != null) { actionWatcher.onEviction(key, this); } } stats.evicted(); size.addAndGet(-1 * evictedHeap); }
/** * Evict the block, and it will be cached by the victim handler if exists && * block may be read again later * @param block * @param evictedByEvictionProcess true if the given block is evicted by * EvictionThread * @return the heap size of evicted block */ protected long evictBlock(LruCachedBlock block, boolean evictedByEvictionProcess) { map.remove(block.getCacheKey()); updateSizeMetrics(block, true); long val = elements.decrementAndGet(); if (LOG.isTraceEnabled()) { long size = map.size(); assertCounterSanity(size, val); } stats.evicted(block.getCachedTime(), block.getCacheKey().isPrimary()); if (evictedByEvictionProcess && victimHandler != null) { if (victimHandler instanceof BucketCache) { boolean wait = getCurrentSize() < acceptableSize(); boolean inMemory = block.getPriority() == BlockPriority.MEMORY; ((BucketCache)victimHandler).cacheBlockWithWait(block.getCacheKey(), block.getBuffer(), inMemory, wait); } else { victimHandler.cacheBlock(block.getCacheKey(), block.getBuffer()); } } return block.heapSize(); }