org.apache.hadoop.hbase.io.hfile
Interface BlockCache

All Known Implementing Classes:
DoubleBlockCache, LruBlockCache, SimpleBlockCache, SingleSizeCache, SlabCache

public interface BlockCache

Block cache interface. Anything that implements the Cacheable interface can be put in the cache.


Method Summary
 void cacheBlock(BlockCacheKey cacheKey, Cacheable buf)
          Add block to cache (defaults to not in-memory).
 void cacheBlock(BlockCacheKey cacheKey, Cacheable buf, boolean inMemory)
          Add block to cache.
 boolean evictBlock(BlockCacheKey cacheKey)
          Evict block from cache.
 int evictBlocksByHfileName(String hfileName)
          Evicts all blocks for the given HFile.
 Cacheable getBlock(BlockCacheKey cacheKey, 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.
 CacheStats getStats()
          Get the statistics for this block cache.
 void shutdown()
          Shutdown the cache.
 long size()
          Returns the total size of the block cache, in bytes.
 

Method Detail

cacheBlock

void cacheBlock(BlockCacheKey cacheKey,
                Cacheable buf,
                boolean inMemory)
Add block to cache.

Parameters:
cacheKey - The block's cache key.
buf - The block contents wrapped in a ByteBuffer.
inMemory - Whether block should be treated as in-memory

cacheBlock

void cacheBlock(BlockCacheKey cacheKey,
                Cacheable buf)
Add block to cache (defaults to not in-memory).

Parameters:
cacheKey - The block's cache key.
buf - The object to cache.

getBlock

Cacheable getBlock(BlockCacheKey cacheKey,
                   boolean caching,
                   boolean repeat)
Fetch block from cache.

Parameters:
cacheKey - 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)
Returns:
Block or null if block is not in 2 cache.

evictBlock

boolean evictBlock(BlockCacheKey cacheKey)
Evict block from cache.

Parameters:
cacheKey - Block to evict
Returns:
true if block existed and was evicted, false if not

evictBlocksByHfileName

int evictBlocksByHfileName(String hfileName)
Evicts all blocks for the given HFile.

Returns:
the number of blocks evicted

getStats

CacheStats getStats()
Get the statistics for this block cache.

Returns:
Stats

shutdown

void shutdown()
Shutdown the cache.


size

long size()
Returns the total size of the block cache, in bytes.

Returns:
size of cache, in bytes

getFreeSize

long getFreeSize()
Returns the free size of the block cache, in bytes.

Returns:
free space in cache, in bytes

getCurrentSize

long getCurrentSize()
Returns the occupied size of the block cache, in bytes.

Returns:
occupied space in cache, in bytes

getEvictedCount

long getEvictedCount()
Returns the number of evictions that have occurred.

Returns:
number of evictions

getBlockCount

long getBlockCount()
Returns the number of blocks currently cached in the block cache.

Returns:
number of blocks in the cache

getBlockCacheColumnFamilySummaries

List<BlockCacheColumnFamilySummary> getBlockCacheColumnFamilySummaries(org.apache.hadoop.conf.Configuration conf)
                                                                       throws IOException
Performs a BlockCache summary and returns a List of BlockCacheColumnFamilySummary objects. This method could be fairly heavyweight in that it evaluates the entire HBase file-system against what is in the RegionServer BlockCache.

The contract of this interface is to return the List in sorted order by Table name, then ColumnFamily.

Parameters:
conf - HBaseConfiguration
Returns:
List of BlockCacheColumnFamilySummary
Throws:
IOException - exception


Copyright © 2014 The Apache Software Foundation. All Rights Reserved.