@InterfaceAudience.Private public class SingleSizeCache extends Object implements BlockCache, HeapSize
Modifier and Type | Field and Description |
---|---|
static long |
CACHE_FIXED_OVERHEAD |
Constructor and Description |
---|
SingleSizeCache(int blockSize,
int numBlocks,
org.apache.hadoop.hbase.io.hfile.slab.SlabItemActionWatcher master)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
cacheBlock(BlockCacheKey blockName,
Cacheable toBeCached)
Add block to cache (defaults to not in-memory).
|
void |
cacheBlock(BlockCacheKey cacheKey,
Cacheable buf,
boolean inMemory)
Add block to cache.
|
boolean |
evictBlock(BlockCacheKey key)
Evicts the block
|
int |
evictBlocksByHfileName(String hfileName)
Evicts all blocks for the given HFile.
|
Cacheable |
getBlock(BlockCacheKey key,
boolean caching,
boolean repeat)
Fetch block from cache.
|
List<BlockCacheColumnFamilySummary> |
getBlockCacheColumnFamilySummaries(org.apache.hadoop.conf.Configuration conf)
Performs a BlockCache summary and returns a List of BlockCacheColumnFamilySummary objects.
|
long |
getBlockCount()
Returns the number of blocks currently cached in the block cache.
|
long |
getCurrentSize()
Returns the occupied size of the block cache, in bytes.
|
long |
getEvictedCount()
Returns the number of evictions that have occurred.
|
long |
getFreeSize()
Returns the free size of the block cache, in bytes.
|
long |
getOccupiedSize() |
CacheStats |
getStats()
Get the statistics for this block cache.
|
long |
heapSize() |
void |
logStats() |
void |
shutdown()
Shutdown the cache.
|
long |
size()
Returns the total size of the block cache, in bytes.
|
public SingleSizeCache(int blockSize, int numBlocks, org.apache.hadoop.hbase.io.hfile.slab.SlabItemActionWatcher master)
blockSize
- the size of each block, in bytesnumBlocks
- the number of blocks of blockSize this cache will hold.master
- the SlabCache this SingleSlabCache is assigned to.public void cacheBlock(BlockCacheKey blockName, Cacheable toBeCached)
BlockCache
cacheBlock
in interface BlockCache
blockName
- The block's cache key.toBeCached
- The object to cache.public Cacheable getBlock(BlockCacheKey key, boolean caching, boolean repeat)
BlockCache
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)HFileReaderV2.readBlock(long, long, boolean, boolean, boolean, BlockType)
public boolean evictBlock(BlockCacheKey key)
evictBlock
in interface BlockCache
key
- the key of the entry we are going to evictpublic void logStats()
public void shutdown()
BlockCache
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 getOccupiedSize()
public long getEvictedCount()
BlockCache
getEvictedCount
in interface BlockCache
public CacheStats getStats()
BlockCache
getStats
in interface BlockCache
public long getBlockCount()
BlockCache
getBlockCount
in interface BlockCache
public void cacheBlock(BlockCacheKey cacheKey, Cacheable buf, boolean inMemory)
BlockCache
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 int evictBlocksByHfileName(String hfileName)
BlockCache
evictBlocksByHfileName
in interface BlockCache
public long getCurrentSize()
BlockCache
getCurrentSize
in interface BlockCache
public List<BlockCacheColumnFamilySummary> getBlockCacheColumnFamilySummaries(org.apache.hadoop.conf.Configuration conf)
BlockCache
getBlockCacheColumnFamilySummaries
in interface BlockCache
conf
- HBaseConfigurationCopyright © 2013 The Apache Software Foundation. All rights reserved.