BucketCache
.@InterfaceAudience.Private @Deprecated public class SlabCache extends Object implements BlockCache, HeapSize
Constructor and Description |
---|
SlabCache(long size,
long avgBlockSize)
Deprecated.
Default constructor, creates an empty SlabCache.
|
Modifier and Type | Method and Description |
---|---|
void |
addSlabByConf(org.apache.hadoop.conf.Configuration conf)
Deprecated.
A way of allocating the desired amount of Slabs of each particular size.
|
void |
cacheBlock(BlockCacheKey cacheKey,
Cacheable cachedItem)
Deprecated.
Cache the block with the specified key and buffer.
|
void |
cacheBlock(BlockCacheKey cacheKey,
Cacheable buf,
boolean inMemory)
Deprecated.
We don't care about whether its in memory or not, so we just pass the call
through.
|
boolean |
evictBlock(BlockCacheKey cacheKey)
Deprecated.
Evicts a block from the cache.
|
int |
evictBlocksByHfileName(String hfileName)
Deprecated.
Evicts all blocks for the given HFile.
|
Cacheable |
getBlock(BlockCacheKey key,
boolean caching,
boolean repeat,
boolean updateCacheMetrics)
Deprecated.
Get the buffer of the block with the specified name.
|
BlockCache[] |
getBlockCaches()
Deprecated.
|
long |
getBlockCount()
Deprecated.
Returns the number of blocks currently cached in the block cache.
|
long |
getCurrentSize()
Deprecated.
Returns the occupied size of the block cache, in bytes.
|
long |
getEvictedCount()
Deprecated.
|
long |
getFreeSize()
Deprecated.
Returns the free size of the block cache, in bytes.
|
Map<Integer,SingleSizeCache> |
getSizer()
Deprecated.
|
CacheStats |
getStats()
Deprecated.
Get the statistics for this block cache.
|
long |
heapSize()
Deprecated.
|
Iterator<CachedBlock> |
iterator()
Deprecated.
|
void |
onEviction(BlockCacheKey key,
SingleSizeCache notifier)
Deprecated.
This is called as a callback when an item is removed from a SingleSizeCache.
|
void |
onInsertion(BlockCacheKey key,
SingleSizeCache notifier)
Deprecated.
This is called as a callback when an item is inserted into a SingleSizeCache.
|
void |
shutdown()
Deprecated.
Sends a shutdown to all SingleSizeCache's contained by this cache.
|
long |
size()
Deprecated.
Returns the total size of the block cache, in bytes.
|
public SlabCache(long size, long avgBlockSize)
size
- Total size allocated to the SlabCache. (Bytes)avgBlockSize
- Average size of a block being cached.public Map<Integer,SingleSizeCache> getSizer()
public void addSlabByConf(org.apache.hadoop.conf.Configuration conf)
conf
- Configuration file.public void cacheBlock(BlockCacheKey cacheKey, Cacheable cachedItem)
It is assumed this will NEVER be called on an already cached block. If that is done, it is assumed that you are reinserting the same exact block due to a race condition, and will throw a runtime exception.
cacheBlock
in interface BlockCache
cacheKey
- block cache keycachedItem
- block bufferpublic void cacheBlock(BlockCacheKey cacheKey, Cacheable buf, boolean inMemory)
cacheBlock
in interface BlockCache
cacheKey
- The block's cache key.buf
- The block contents wrapped in a ByteBuffer.inMemory
- Whether block should be treated as in-memorypublic CacheStats getStats()
BlockCache
getStats
in interface BlockCache
public Cacheable getBlock(BlockCacheKey key, boolean caching, boolean repeat, boolean updateCacheMetrics)
getBlock
in interface BlockCache
key
- Block to fetch.caching
- Whether this request has caching enabled (used for stats)repeat
- Whether this is a repeat lookup for the same block
(used to avoid double counting cache misses when doing double-check locking)updateCacheMetrics
- Whether to update cache metrics or notpublic boolean evictBlock(BlockCacheKey cacheKey)
evictBlock
in interface BlockCache
cacheKey
- Block to evictpublic void onEviction(BlockCacheKey key, SingleSizeCache notifier)
key
- the key of the item being evictednotifier
- the object notifying the SlabCache of the eviction.public void onInsertion(BlockCacheKey key, SingleSizeCache notifier)
key
- the key of the item being addednotifier
- the object notifying the SlabCache of the insertion..public void shutdown()
shutdown
in interface BlockCache
public long heapSize()
public long size()
BlockCache
size
in interface BlockCache
public long getFreeSize()
BlockCache
getFreeSize
in interface BlockCache
public long getBlockCount()
BlockCache
getBlockCount
in interface BlockCache
public long getCurrentSize()
BlockCache
getCurrentSize
in interface BlockCache
public long getEvictedCount()
public int evictBlocksByHfileName(String hfileName)
BlockCache
evictBlocksByHfileName
in interface BlockCache
public Iterator<CachedBlock> iterator()
iterator
in interface Iterable<CachedBlock>
iterator
in interface BlockCache
public BlockCache[] getBlockCaches()
getBlockCaches
in interface BlockCache
Copyright © 2014 The Apache Software Foundation. All rights reserved.