org.apache.hadoop.hbase.io.hfile
Class SimpleBlockCache

java.lang.Object
  extended by org.apache.hadoop.hbase.io.hfile.SimpleBlockCache
All Implemented Interfaces:
BlockCache

public class SimpleBlockCache
extends Object
implements BlockCache

Simple one RFile soft reference cache.


Field Summary
 int dumps
           
 
Constructor Summary
SimpleBlockCache()
          Constructor
 
Method Summary
 void cacheBlock(BlockCacheKey cacheKey, Cacheable block)
          Add block to cache (defaults to not in-memory).
 void cacheBlock(BlockCacheKey cacheKey, Cacheable block, boolean inMemory)
          Add block to cache.
 boolean evictBlock(BlockCacheKey cacheKey)
          Evict block from cache.
 int evictBlocksByHfileName(String string)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dumps

public int dumps
Constructor Detail

SimpleBlockCache

public SimpleBlockCache()
Constructor

Method Detail

size

public long size()
Description copied from interface: BlockCache
Returns the total size of the block cache, in bytes.

Specified by:
size in interface BlockCache
Returns:
the size

getBlock

public Cacheable getBlock(BlockCacheKey cacheKey,
                          boolean caching,
                          boolean repeat)
Description copied from interface: BlockCache
Fetch block from cache.

Specified by:
getBlock in interface BlockCache
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.

cacheBlock

public void cacheBlock(BlockCacheKey cacheKey,
                       Cacheable block)
Description copied from interface: BlockCache
Add block to cache (defaults to not in-memory).

Specified by:
cacheBlock in interface BlockCache
Parameters:
cacheKey - The block's cache key.
block - The object to cache.

cacheBlock

public void cacheBlock(BlockCacheKey cacheKey,
                       Cacheable block,
                       boolean inMemory)
Description copied from interface: BlockCache
Add block to cache.

Specified by:
cacheBlock in interface BlockCache
Parameters:
cacheKey - The block's cache key.
block - The block contents wrapped in a ByteBuffer.
inMemory - Whether block should be treated as in-memory

evictBlock

public boolean evictBlock(BlockCacheKey cacheKey)
Description copied from interface: BlockCache
Evict block from cache.

Specified by:
evictBlock in interface BlockCache
Parameters:
cacheKey - Block to evict
Returns:
true if block existed and was evicted, false if not

shutdown

public void shutdown()
Description copied from interface: BlockCache
Shutdown the cache.

Specified by:
shutdown in interface BlockCache

getStats

public CacheStats getStats()
Description copied from interface: BlockCache
Get the statistics for this block cache.

Specified by:
getStats in interface BlockCache
Returns:
Stats

getFreeSize

public long getFreeSize()
Description copied from interface: BlockCache
Returns the free size of the block cache, in bytes.

Specified by:
getFreeSize in interface BlockCache
Returns:
free space in cache, in bytes

getCurrentSize

public long getCurrentSize()
Description copied from interface: BlockCache
Returns the occupied size of the block cache, in bytes.

Specified by:
getCurrentSize in interface BlockCache
Returns:
occupied space in cache, in bytes

getEvictedCount

public long getEvictedCount()
Description copied from interface: BlockCache
Returns the number of evictions that have occurred.

Specified by:
getEvictedCount in interface BlockCache
Returns:
number of evictions

evictBlocksByHfileName

public int evictBlocksByHfileName(String string)
Description copied from interface: BlockCache
Evicts all blocks for the given HFile.

Specified by:
evictBlocksByHfileName in interface BlockCache
Returns:
the number of blocks evicted

getBlockCacheColumnFamilySummaries

public List<BlockCacheColumnFamilySummary> getBlockCacheColumnFamilySummaries(org.apache.hadoop.conf.Configuration conf)
Description copied from interface: BlockCache
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.

Specified by:
getBlockCacheColumnFamilySummaries in interface BlockCache
Parameters:
conf - HBaseConfiguration
Returns:
List of BlockCacheColumnFamilySummary

getBlockCount

public long getBlockCount()
Description copied from interface: BlockCache
Returns the number of blocks currently cached in the block cache.

Specified by:
getBlockCount in interface BlockCache
Returns:
number of blocks in the cache


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