Package org.apache.hadoop.hbase.io.hfile
Class MemcachedBlockCache
java.lang.Object
org.apache.hadoop.hbase.io.hfile.MemcachedBlockCache
- All Implemented Interfaces:
Iterable<CachedBlock>,BlockCache
Class to store blocks into memcached. This should only be used on a cluster of Memcached daemons
that are tuned well and have a good network connection to the HBase regionservers. Any other use
will likely slow down HBase greatly.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classClass to encode and decode an HFileBlock to and from memecached's resulting byte arrays.private static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicLongprivate final AtomicLongprivate final CacheStatsprivate final net.spy.memcached.MemcachedClientprivate static final org.slf4j.Loggerstatic final intstatic final intstatic final Stringstatic final longstatic final Stringstatic final booleanstatic final Stringstatic final Stringprivate final AtomicLongprivate final ScheduledExecutorServiceStatistics thread schedule pool (for heavy debugging, could remove)static final intprivate final MemcachedBlockCache.HFileBlockTranscoderprivate final AtomicLong -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcacheBlock(BlockCacheKey cacheKey, Cacheable buf) Add block to cache (defaults to not in-memory).voidcacheBlock(BlockCacheKey cacheKey, Cacheable buf, boolean inMemory) Add block to cache.booleanevictBlock(BlockCacheKey cacheKey) Evict block from cache.intevictBlocksByHfileName(String hfileName) This method does nothing so that memcached can handle all evictions.getBlock(BlockCacheKey cacheKey, boolean caching, boolean repeat, boolean updateCacheMetrics) Fetch block from cache.Returns The list of sub blockcaches that make up this one; returns null if no sub caches.longReturns the number of blocks currently cached in the block cache.longReturns the occupied size of data blocks, in bytes.longReturns the occupied size of the block cache, in bytes.longReturns the number of data blocks currently cached in the block cache.longReturns the free size of the block cache, in bytes.longReturns the Max size of the block cache, in bytes.getStats()Get the statistics for this block cache.iterator()Returns Iterator over the blocks in the cache.voidlogStats()voidshutdown()Shutdown the cache.longsize()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, waitMethods inherited from interface org.apache.hadoop.hbase.io.hfile.BlockCache
blockFitsIntoTheCache, cacheBlock, getBlockSize, getFullyCachedFiles, isAlreadyCached, isMetaBlock, notifyFileBlockEvicted, notifyFileCachingCompleted, shouldCacheFileMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
LOG
-
MAX_SIZE
- See Also:
-
MAX_TIME
- See Also:
-
MEMCACHED_CONFIG_KEY
- See Also:
-
MEMCACHED_TIMEOUT_KEY
- See Also:
-
MEMCACHED_OPTIMEOUT_KEY
- See Also:
-
MEMCACHED_OPTIMIZE_KEY
- See Also:
-
MEMCACHED_DEFAULT_TIMEOUT
- See Also:
-
MEMCACHED_OPTIMIZE_DEFAULT
- See Also:
-
STAT_THREAD_PERIOD
- See Also:
-
client
-
tc
-
cacheStats
-
cachedCount
-
notCachedCount
-
cacheErrorCount
-
timeoutCount
-
scheduleThreadPool
Statistics thread schedule pool (for heavy debugging, could remove)
-
-
Constructor Details
-
MemcachedBlockCache
- Throws:
IOException
-
-
Method Details
-
cacheBlock
Description copied from interface:BlockCacheAdd block to cache.- Specified by:
cacheBlockin interfaceBlockCache- 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
Description copied from interface:BlockCacheAdd block to cache (defaults to not in-memory).- Specified by:
cacheBlockin interfaceBlockCache- Parameters:
cacheKey- The block's cache key.buf- The object to cache.
-
getBlock
public Cacheable getBlock(BlockCacheKey cacheKey, boolean caching, boolean repeat, boolean updateCacheMetrics) Description copied from interface:BlockCacheFetch block from cache.- Specified by:
getBlockin interfaceBlockCache- 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)updateCacheMetrics- Whether to update cache metrics or not- Returns:
- Block or null if block is not in 2 cache.
-
evictBlock
Description copied from interface:BlockCacheEvict block from cache.- Specified by:
evictBlockin interfaceBlockCache- Parameters:
cacheKey- Block to evict- Returns:
- true if block existed and was evicted, false if not
-
evictBlocksByHfileName
This method does nothing so that memcached can handle all evictions.- Specified by:
evictBlocksByHfileNamein interfaceBlockCache- Returns:
- the number of blocks evicted
-
getStats
Description copied from interface:BlockCacheGet the statistics for this block cache.- Specified by:
getStatsin interfaceBlockCache
-
shutdown
Description copied from interface:BlockCacheShutdown the cache.- Specified by:
shutdownin interfaceBlockCache
-
size
Description copied from interface:BlockCacheReturns the total size of the block cache, in bytes.- Specified by:
sizein interfaceBlockCache- Returns:
- size of cache, in bytes
-
getMaxSize
Description copied from interface:BlockCacheReturns the Max size of the block cache, in bytes.- Specified by:
getMaxSizein interfaceBlockCache- Returns:
- size of cache, in bytes
-
getFreeSize
Description copied from interface:BlockCacheReturns the free size of the block cache, in bytes.- Specified by:
getFreeSizein interfaceBlockCache- Returns:
- free space in cache, in bytes
-
getCurrentSize
Description copied from interface:BlockCacheReturns the occupied size of the block cache, in bytes.- Specified by:
getCurrentSizein interfaceBlockCache- Returns:
- occupied space in cache, in bytes
-
getCurrentDataSize
Description copied from interface:BlockCacheReturns the occupied size of data blocks, in bytes.- Specified by:
getCurrentDataSizein interfaceBlockCache- Returns:
- occupied space in cache, in bytes
-
getBlockCount
Description copied from interface:BlockCacheReturns the number of blocks currently cached in the block cache.- Specified by:
getBlockCountin interfaceBlockCache- Returns:
- number of blocks in the cache
-
getDataBlockCount
Description copied from interface:BlockCacheReturns the number of data blocks currently cached in the block cache.- Specified by:
getDataBlockCountin interfaceBlockCache- Returns:
- number of blocks in the cache
-
iterator
Description copied from interface:BlockCacheReturns Iterator over the blocks in the cache.- Specified by:
iteratorin interfaceBlockCache- Specified by:
iteratorin interfaceIterable<CachedBlock>
-
getBlockCaches
Description copied from interface:BlockCacheReturns The list of sub blockcaches that make up this one; returns null if no sub caches.- Specified by:
getBlockCachesin interfaceBlockCache
-
logStats
-