|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.hadoop.hbase.io.hfile.bucket.BucketCache
@InterfaceAudience.Private public class BucketCache
BucketCache uses BucketAllocator to allocate/free block, and use
ramCache and backingMap in order to
determine if a given element is in the cache. The bucket cache can use on-heap or
off-heap memory ByteBufferIOEngine or in a file FileIOEngine to
store/read the block data.
Eviction is via a similar algorithm as used in
LruBlockCache
BucketCache can be used as mainly a block cache (see
CombinedBlockCache), combined with LruBlockCache to decrease CMS GC and
heap fragmentation.
It also can be used as a secondary cache (e.g. using a file on ssd/fusionio to store
blocks) to enlarge cache space via
LruBlockCache.setVictimCache(org.apache.hadoop.hbase.io.hfile.bucket.BucketCache)
| Field Summary | |
|---|---|
static int |
DEFAULT_ERROR_TOLERATION_DURATION
|
| Constructor Summary | |
|---|---|
BucketCache(String ioEngineName,
long capacity,
int blockSize,
int[] bucketSizes,
int writerThreadNum,
int writerQLen,
String persistencePath)
|
|
BucketCache(String ioEngineName,
long capacity,
int blockSize,
int[] bucketSizes,
int writerThreadNum,
int writerQLen,
String persistencePath,
int ioErrorsTolerationDuration)
|
|
| Method Summary | |
|---|---|
void |
cacheBlock(BlockCacheKey cacheKey,
Cacheable buf)
Cache the block with the specified name and buffer. |
void |
cacheBlock(BlockCacheKey cacheKey,
Cacheable cachedItem,
boolean inMemory)
Cache the block with the specified name and buffer. |
void |
cacheBlockWithWait(BlockCacheKey cacheKey,
Cacheable cachedItem,
boolean inMemory,
boolean wait)
Cache the block to ramCache |
boolean |
evictBlock(BlockCacheKey cacheKey)
Evict block from cache. |
int |
evictBlocksByHfileName(String hfileName)
Evicts all blocks for a specific HFile. |
BucketAllocator |
getAllocator()
|
Cacheable |
getBlock(BlockCacheKey key,
boolean caching,
boolean repeat,
boolean updateCacheMetrics)
Get the buffer of the block with the specified key. |
BlockCache[] |
getBlockCaches()
|
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 |
getFreeSize()
Returns the free size of the block cache, in bytes. |
String |
getIoEngine()
|
long |
getMaxSize()
|
long |
getRealCacheSize()
|
CacheStats |
getStats()
Get the statistics for this block cache. |
long |
heapSize()
|
Iterator<CachedBlock> |
iterator()
|
void |
logStats()
|
void |
shutdown()
Shutdown the cache. |
long |
size()
Returns the total size of the block cache, in bytes. |
protected void |
startWriterThreads()
Called by the constructor to start the writer threads. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_ERROR_TOLERATION_DURATION
| Constructor Detail |
|---|
public BucketCache(String ioEngineName,
long capacity,
int blockSize,
int[] bucketSizes,
int writerThreadNum,
int writerQLen,
String persistencePath)
throws FileNotFoundException,
IOException
FileNotFoundException
IOException
public BucketCache(String ioEngineName,
long capacity,
int blockSize,
int[] bucketSizes,
int writerThreadNum,
int writerQLen,
String persistencePath,
int ioErrorsTolerationDuration)
throws FileNotFoundException,
IOException
FileNotFoundException
IOException| Method Detail |
|---|
protected void startWriterThreads()
public long getMaxSize()
public String getIoEngine()
public void cacheBlock(BlockCacheKey cacheKey,
Cacheable buf)
cacheBlock in interface BlockCachecacheKey - block's cache keybuf - block buffer
public void cacheBlock(BlockCacheKey cacheKey,
Cacheable cachedItem,
boolean inMemory)
cacheBlock in interface BlockCachecacheKey - block's cache keycachedItem - block bufferinMemory - if block is in-memory
public void cacheBlockWithWait(BlockCacheKey cacheKey,
Cacheable cachedItem,
boolean inMemory,
boolean wait)
cacheKey - block's cache keycachedItem - block bufferinMemory - if block is in-memorywait - if true, blocking wait when queue is full
public Cacheable getBlock(BlockCacheKey key,
boolean caching,
boolean repeat,
boolean updateCacheMetrics)
getBlock in interface BlockCachekey - block's cache keycaching - true if the caller caches blocks on cache missesrepeat - Whether this is a repeat lookup for the same blockupdateCacheMetrics - Whether we should update cache metrics or not
public boolean evictBlock(BlockCacheKey cacheKey)
BlockCache
evictBlock in interface BlockCachecacheKey - Block to evict
public void logStats()
public long getRealCacheSize()
public void shutdown()
BlockCache
shutdown in interface BlockCachepublic CacheStats getStats()
BlockCache
getStats in interface BlockCachepublic BucketAllocator getAllocator()
public long heapSize()
heapSize in interface HeapSizepublic long size()
BlockCache
size in interface BlockCachepublic long getFreeSize()
BlockCache
getFreeSize in interface BlockCachepublic long getBlockCount()
BlockCache
getBlockCount in interface BlockCachepublic long getCurrentSize()
BlockCache
getCurrentSize in interface BlockCachepublic int evictBlocksByHfileName(String hfileName)
This is used for evict-on-close to remove all blocks of a specific HFile.
evictBlocksByHfileName in interface BlockCachepublic Iterator<CachedBlock> iterator()
iterator in interface Iterable<CachedBlock>iterator in interface BlockCachepublic BlockCache[] getBlockCaches()
getBlockCaches in interface BlockCache
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||