@InterfaceAudience.Private public interface BlockCache extends Iterable<CachedBlock>
Cacheable
interface can be put in the
cache.Modifier and Type | Method and Description |
---|---|
default Optional<Boolean> |
blockFitsIntoTheCache(HFileBlock block)
Checks whether there's enough space left in the cache to accommodate the passed block.
|
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.
|
default void |
cacheBlock(BlockCacheKey cacheKey,
Cacheable buf,
boolean inMemory,
boolean waitWhenCache)
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,
boolean updateCacheMetrics)
Fetch block from cache.
|
default Cacheable |
getBlock(BlockCacheKey cacheKey,
boolean caching,
boolean repeat,
boolean updateCacheMetrics,
BlockType blockType)
Fetch block from cache.
|
BlockCache[] |
getBlockCaches()
Returns The list of sub blockcaches that make up this one; returns null if no sub caches.
|
long |
getBlockCount()
Returns the number of blocks currently cached in the block cache.
|
default Optional<Integer> |
getBlockSize(BlockCacheKey key)
Returns an Optional containing the size of the block related to the passed key.
|
long |
getCurrentDataSize()
Returns the occupied size of data blocks, in bytes.
|
long |
getCurrentSize()
Returns the occupied size of the block cache, in bytes.
|
long |
getDataBlockCount()
Returns the number of data blocks currently cached in the block cache.
|
long |
getFreeSize()
Returns the free size of the block cache, in bytes.
|
default Optional<Map<String,Pair<String,Long>>> |
getFullyCachedFiles()
Returns an Optional containing the map of files that have been fully cached (all its blocks are
present in the cache.
|
long |
getMaxSize()
Returns the Max size of the block cache, in bytes.
|
default Optional<Map<String,Long>> |
getRegionCachedInfo()
Returns an Optional containing a map of regions and the percentage of how much of it has been
cached so far.
|
CacheStats |
getStats()
Get the statistics for this block cache.
|
default Optional<Boolean> |
isAlreadyCached(BlockCacheKey key)
Checks whether the block for the passed key is already cached.
|
default boolean |
isMetaBlock(BlockType blockType)
Check if block type is meta or index block
|
Iterator<CachedBlock> |
iterator()
Returns Iterator over the blocks in the cache.
|
default void |
notifyFileCachingCompleted(org.apache.hadoop.fs.Path fileName,
int totalBlockCount,
int dataBlockCount,
long size)
Notifies the cache implementation that the given file has been fully cached (all its blocks
made into the cache).
|
default Optional<Boolean> |
shouldCacheFile(String fileName)
Checks whether blocks for the passed file should be cached or not.
|
void |
shutdown()
Shutdown the cache.
|
long |
size()
Returns the total size of the block cache, in bytes.
|
forEach, spliterator
void cacheBlock(BlockCacheKey cacheKey, Cacheable buf, boolean inMemory)
cacheKey
- The block's cache key.buf
- The block contents wrapped in a ByteBuffer.inMemory
- Whether block should be treated as in-memorydefault void cacheBlock(BlockCacheKey cacheKey, Cacheable buf, boolean inMemory, boolean waitWhenCache)
cacheKey
- The block's cache key.buf
- The block contents wrapped in a ByteBuffer.inMemory
- Whether block should be treated as in-memorywaitWhenCache
- Whether to wait for the cache to be flushed mainly when BucketCache is
configured.void cacheBlock(BlockCacheKey cacheKey, Cacheable buf)
cacheKey
- The block's cache key.buf
- The object to cache.Cacheable getBlock(BlockCacheKey cacheKey, boolean caching, boolean repeat, boolean updateCacheMetrics)
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 notdefault Cacheable getBlock(BlockCacheKey cacheKey, boolean caching, boolean repeat, boolean updateCacheMetrics, BlockType blockType)
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 notblockType
- BlockTypeboolean evictBlock(BlockCacheKey cacheKey)
cacheKey
- Block to evictint evictBlocksByHfileName(String hfileName)
CacheStats getStats()
void shutdown()
long size()
long getMaxSize()
long getFreeSize()
long getCurrentSize()
long getCurrentDataSize()
long getBlockCount()
long getDataBlockCount()
Iterator<CachedBlock> iterator()
iterator
in interface Iterable<CachedBlock>
BlockCache[] getBlockCaches()
default boolean isMetaBlock(BlockType blockType)
blockType
- block type of a given HFile blockdefault void notifyFileCachingCompleted(org.apache.hadoop.fs.Path fileName, int totalBlockCount, int dataBlockCount, long size)
fileName
- the file that has been completely cached.totalBlockCount
- the total of blocks cached for this file.dataBlockCount
- number of DATA block type cached.size
- the size, in bytes, cached.default Optional<Boolean> blockFitsIntoTheCache(HFileBlock block)
block
- the block we want to check if fits into the cache.default Optional<Boolean> shouldCacheFile(String fileName)
fileName
- to check if it should be cached.default Optional<Boolean> isAlreadyCached(BlockCacheKey key)
key
- for the block we want to check if it's already in the cache.default Optional<Integer> getBlockSize(BlockCacheKey key)
key
- for the block we want to check if it's already in the cache.default Optional<Map<String,Pair<String,Long>>> getFullyCachedFiles()
default Optional<Map<String,Long>> getRegionCachedInfo()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.