Package org.apache.hadoop.hbase.io.hfile
Class CacheConfig
java.lang.Object
org.apache.hadoop.hbase.io.hfile.CacheConfig
- All Implemented Interfaces:
ConfigurationObserver
Stores all of the cache objects and configuration for a single HFile.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final BlockCache
static final String
Configuration key to set interval for persisting bucket cache to disk.private final ByteBuffAllocator
static final String
Configuration key to cache data blocks on write.static final String
Configuration key to cache compound bloom filter blocks on write.static final String
Configuration key to cache blocks when a compacted file is writtenstatic final String
Configuration key to determine total size in bytes of compacted files beyond which we do not cache blocks on compactionstatic final String
Configuration key to cache data blocks in compressed and/or encrypted format.static final String
Configuration key to cache data blocks on read.static final String
Configuration key to cache leaf and intermediate-level index blocks on write.private boolean
Whether compound bloom filter blocks should be cached on writeprivate final boolean
Whether data blocks should be cached when compacted file is writtenprivate long
Determine threshold beyond which we do not cache blocks on compactionprivate final boolean
Whether data blocks should be stored in compressed and/or encrypted form in the cacheprivate boolean
Whether blocks should be cached on read (default is on if there is a cache but this can be turned off on a per-family or per-request basis).private boolean
Whether data blocks should be cached when new files are writtenprivate boolean
Whether index blocks should be cached when new files are writtenstatic final boolean
static final boolean
static final long
static final boolean
static final boolean
static final boolean
static final boolean
static final boolean
static final boolean
static final boolean
static final double
static final boolean
static final CacheConfig
Disabled cache configurationstatic final boolean
static final String
private final boolean
static final String
Configuration key to evict all blocks of a given file from the block cache when the file is closed.static final String
private boolean
Whether blocks of a file should be evicted when the file is closedprivate final double
private final boolean
Whether blocks should be flagged as in-memory when being cachedprivate static final org.slf4j.Logger
static final String
Configuration key to prefetch all blocks of a given file into the block cache when the file is opened.static final String
Configuration key to set the heap usage threshold limit once prefetch threads should be interrupted.private final boolean
Whether data blocks should be prefetched into the cache -
Constructor Summary
ModifierConstructorDescriptionprivate
CacheConfig
(org.apache.hadoop.conf.Configuration conf) Create a cache configuration using the specified configuration object and defaults for family level settings.CacheConfig
(org.apache.hadoop.conf.Configuration conf, ColumnFamilyDescriptor family, BlockCache blockCache, ByteBuffAllocator byteBuffAllocator) Create a cache configuration using the specified configuration object and family descriptor.CacheConfig
(org.apache.hadoop.conf.Configuration conf, BlockCache blockCache) CacheConfig
(CacheConfig cacheConf) Constructs a cache configuration copied from the specified configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Enable cache on write including: cacheDataOnWrite cacheIndexesOnWrite cacheBloomsOnWriteReturns the block cache.long
Returns total file size in bytes threshold for caching while writing during compactionprivate long
getCacheCompactedBlocksOnWriteThreshold
(org.apache.hadoop.conf.Configuration conf) double
boolean
boolean
Checks if the current heap usage is below the threshold configured by "hbase.rs.prefetchheapusage" (0.8 by default).boolean
Returns true if blocks in this file should be flagged as in-memoryvoid
onConfigurationChange
(org.apache.hadoop.conf.Configuration conf) This method would be called by theConfigurationManager
object when theConfiguration
object is reloaded from disk.void
setCacheDataOnWrite
(boolean cacheDataOnWrite) void
setEvictOnClose
(boolean evictOnClose) Only used for testing.boolean
Should we cache a block of a particular category? We always cache important blocks such as index blocks, as long as the block cache is available.boolean
boolean
Returns true if blocks should be cached while writing during compaction, false if notboolean
shouldCacheCompressed
(BlockType.BlockCategory category) Returns true if thisBlockType.BlockCategory
should be compressed in blockcache, false otherwiseboolean
Returns true if data blocks should be compressed in the cache, false if notboolean
Returns whether the DATA blocks of this HFile should be cached on read or not (we always cache the meta blocks, the INDEX and BLOOM blocks).boolean
boolean
boolean
boolean
boolean
shouldLockOnCacheMiss
(BlockType blockType) If we make sure the block could not be cached, we will not acquire the lock otherwise we will acquire lockboolean
Returns true if blocks should be prefetched into the cache on open, false if notboolean
shouldReadBlockFromCache
(BlockType blockType) Return true if we may find this type of block in block cache.toString()
-
Field Details
-
LOG
-
DISABLED
Disabled cache configuration -
CACHE_DATA_ON_READ_KEY
Configuration key to cache data blocks on read. Bloom blocks and index blocks are always be cached if the block cache is enabled.- See Also:
-
CACHE_BLOCKS_ON_WRITE_KEY
Configuration key to cache data blocks on write. There are separate switches for bloom blocks and non-root index blocks.- See Also:
-
CACHE_INDEX_BLOCKS_ON_WRITE_KEY
Configuration key to cache leaf and intermediate-level index blocks on write.- See Also:
-
CACHE_BLOOM_BLOCKS_ON_WRITE_KEY
Configuration key to cache compound bloom filter blocks on write.- See Also:
-
CACHE_DATA_BLOCKS_COMPRESSED_KEY
Configuration key to cache data blocks in compressed and/or encrypted format.- See Also:
-
EVICT_BLOCKS_ON_CLOSE_KEY
Configuration key to evict all blocks of a given file from the block cache when the file is closed.- See Also:
-
EVICT_BLOCKS_ON_SPLIT_KEY
- See Also:
-
PREFETCH_BLOCKS_ON_OPEN_KEY
Configuration key to prefetch all blocks of a given file into the block cache when the file is opened.- See Also:
-
CACHE_COMPACTED_BLOCKS_ON_WRITE_KEY
Configuration key to cache blocks when a compacted file is written- See Also:
-
CACHE_COMPACTED_BLOCKS_ON_WRITE_THRESHOLD_KEY
Configuration key to determine total size in bytes of compacted files beyond which we do not cache blocks on compaction- See Also:
-
DROP_BEHIND_CACHE_COMPACTION_KEY
- See Also:
-
BUCKETCACHE_PERSIST_INTERVAL_KEY
Configuration key to set interval for persisting bucket cache to disk.- See Also:
-
PREFETCH_HEAP_USAGE_THRESHOLD
Configuration key to set the heap usage threshold limit once prefetch threads should be interrupted.- See Also:
-
DEFAULT_CACHE_DATA_ON_READ
- See Also:
-
DEFAULT_CACHE_DATA_ON_WRITE
- See Also:
-
DEFAULT_IN_MEMORY
- See Also:
-
DEFAULT_CACHE_INDEXES_ON_WRITE
- See Also:
-
DEFAULT_CACHE_BLOOMS_ON_WRITE
- See Also:
-
DEFAULT_EVICT_ON_CLOSE
- See Also:
-
DEFAULT_EVICT_ON_SPLIT
- See Also:
-
DEFAULT_CACHE_DATA_COMPRESSED
- See Also:
-
DEFAULT_PREFETCH_ON_OPEN
- See Also:
-
DEFAULT_CACHE_COMPACTED_BLOCKS_ON_WRITE
- See Also:
-
DROP_BEHIND_CACHE_COMPACTION_DEFAULT
- See Also:
-
DEFAULT_CACHE_COMPACTED_BLOCKS_ON_WRITE_THRESHOLD
- See Also:
-
DEFAULT_PREFETCH_HEAP_USAGE_THRESHOLD
- See Also:
-
cacheDataOnRead
Whether blocks should be cached on read (default is on if there is a cache but this can be turned off on a per-family or per-request basis). If off we will STILL cache meta blocks; i.e. INDEX and BLOOM types. This cannot be disabled. -
inMemory
Whether blocks should be flagged as in-memory when being cached -
cacheDataOnWrite
Whether data blocks should be cached when new files are written -
cacheIndexesOnWrite
Whether index blocks should be cached when new files are written -
cacheBloomsOnWrite
Whether compound bloom filter blocks should be cached on write -
evictOnClose
Whether blocks of a file should be evicted when the file is closed -
cacheDataCompressed
Whether data blocks should be stored in compressed and/or encrypted form in the cache -
prefetchOnOpen
Whether data blocks should be prefetched into the cache -
cacheCompactedDataOnWrite
Whether data blocks should be cached when compacted file is written -
cacheCompactedDataOnWriteThreshold
Determine threshold beyond which we do not cache blocks on compaction -
dropBehindCompaction
-
blockCache
-
byteBuffAllocator
-
heapUsageThreshold
-
-
Constructor Details
-
CacheConfig
Create a cache configuration using the specified configuration object and defaults for family level settings. Only use if no column family context.- Parameters:
conf
- hbase configuration
-
CacheConfig
-
CacheConfig
public CacheConfig(org.apache.hadoop.conf.Configuration conf, ColumnFamilyDescriptor family, BlockCache blockCache, ByteBuffAllocator byteBuffAllocator) Create a cache configuration using the specified configuration object and family descriptor.- Parameters:
conf
- hbase configurationfamily
- column family configuration
-
CacheConfig
Constructs a cache configuration copied from the specified configuration. -
CacheConfig
private CacheConfig()
-
-
Method Details
-
shouldCacheDataOnRead
Returns whether the DATA blocks of this HFile should be cached on read or not (we always cache the meta blocks, the INDEX and BLOOM blocks).- Returns:
- true if blocks should be cached on read, false if not
-
shouldDropBehindCompaction
-
shouldCacheBlockOnRead
Should we cache a block of a particular category? We always cache important blocks such as index blocks, as long as the block cache is available. -
isInMemory
Returns true if blocks in this file should be flagged as in-memory -
shouldCacheDataOnWrite
- Returns:
- true if data blocks should be written to the cache when an HFile is written, false if not
-
setCacheDataOnWrite
- Parameters:
cacheDataOnWrite
- whether data blocks should be written to the cache when an HFile is written
-
enableCacheOnWrite
Enable cache on write including: cacheDataOnWrite cacheIndexesOnWrite cacheBloomsOnWrite -
shouldCacheIndexesOnWrite
- Returns:
- true if index blocks should be written to the cache when an HFile is written, false if not
-
shouldCacheBloomsOnWrite
- Returns:
- true if bloom blocks should be written to the cache when an HFile is written, false if not
-
shouldEvictOnClose
- Returns:
- true if blocks should be evicted from the cache when an HFile reader is closed, false if not
-
setEvictOnClose
Only used for testing.- Parameters:
evictOnClose
- whether blocks should be evicted from the cache when an HFile reader is closed
-
shouldCacheDataCompressed
Returns true if data blocks should be compressed in the cache, false if not -
shouldCacheCompressed
Returns true if thisBlockType.BlockCategory
should be compressed in blockcache, false otherwise -
shouldPrefetchOnOpen
Returns true if blocks should be prefetched into the cache on open, false if not -
shouldCacheCompactedBlocksOnWrite
Returns true if blocks should be cached while writing during compaction, false if not -
getCacheCompactedBlocksOnWriteThreshold
Returns total file size in bytes threshold for caching while writing during compaction -
shouldReadBlockFromCache
Return true if we may find this type of block in block cache.TODO: today
family.isBlockCacheEnabled()
only meanscacheDataOnRead
, so here we consider lots of other configurations such ascacheDataOnWrite
. We should fix this in the future,cacheDataOnWrite
should honor the CF levelisBlockCacheEnabled
configuration. -
isHeapUsageBelowThreshold
Checks if the current heap usage is below the threshold configured by "hbase.rs.prefetchheapusage" (0.8 by default). -
shouldLockOnCacheMiss
If we make sure the block could not be cached, we will not acquire the lock otherwise we will acquire lock -
getBlockCache
Returns the block cache.- Returns:
- the block cache, or null if caching is completely disabled
-
isCombinedBlockCache
-
getByteBuffAllocator
-
getHeapUsageThreshold
-
getCacheCompactedBlocksOnWriteThreshold
-
toString
-
onConfigurationChange
Description copied from interface:ConfigurationObserver
This method would be called by theConfigurationManager
object when theConfiguration
object is reloaded from disk.- Specified by:
onConfigurationChange
in interfaceConfigurationObserver
-