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
FieldsModifier and TypeFieldDescriptionprivate final BlockCachestatic final StringConfiguration key to set interval for persisting bucket cache to disk.private final ByteBuffAllocatorstatic final StringConfiguration key to cache data blocks on write.static final StringConfiguration key to cache compound bloom filter blocks on write.static final StringConfiguration key to cache blocks when a compacted file is writtenstatic final StringConfiguration key to determine total size in bytes of compacted files beyond which we do not cache blocks on compactionstatic final StringConfiguration key to cache data blocks in compressed and/or encrypted format.static final StringConfiguration key to cache data blocks on read.static final StringConfiguration key to cache leaf and intermediate-level index blocks on write.private booleanWhether compound bloom filter blocks should be cached on writeprivate final booleanWhether data blocks should be cached when compacted file is writtenprivate longDetermine threshold beyond which we do not cache blocks on compactionprivate final booleanWhether data blocks should be stored in compressed and/or encrypted form in the cacheprivate booleanWhether 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 booleanWhether data blocks should be cached when new files are writtenprivate booleanWhether index blocks should be cached when new files are writtenstatic final booleanstatic final booleanstatic final longstatic final booleanstatic final booleanstatic final booleanstatic final booleanstatic final booleanstatic final booleanstatic final booleanstatic final CacheConfigDisabled cache configurationstatic final booleanstatic final Stringprivate final booleanstatic final StringConfiguration key to evict all blocks of a given file from the block cache when the file is closed.private booleanWhether blocks of a file should be evicted when the file is closedprivate final booleanWhether blocks should be flagged as in-memory when being cachedprivate static final org.slf4j.Loggerstatic final StringConfiguration key to prefetch all blocks of a given file into the block cache when the file is opened.private final booleanWhether data blocks should be prefetched into the cache -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateCacheConfig(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 TypeMethodDescriptionvoidEnable cache on write including: cacheDataOnWrite cacheIndexesOnWrite cacheBloomsOnWriteReturns the block cache.longReturns total file size in bytes threshold for caching while writing during compactionprivate longgetCacheCompactedBlocksOnWriteThreshold(org.apache.hadoop.conf.Configuration conf) booleanbooleanReturns true if blocks in this file should be flagged as in-memoryvoidonConfigurationChange(org.apache.hadoop.conf.Configuration conf) This method would be called by theConfigurationManagerobject when theConfigurationobject is reloaded from disk.voidsetCacheDataOnWrite(boolean cacheDataOnWrite) voidsetEvictOnClose(boolean evictOnClose) Only used for testing.booleanShould 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.booleanbooleanReturns true if blocks should be cached while writing during compaction, false if notbooleanshouldCacheCompressed(BlockType.BlockCategory category) Returns true if thisBlockType.BlockCategoryshould be compressed in blockcache, false otherwisebooleanReturns true if data blocks should be compressed in the cache, false if notbooleanReturns 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).booleanbooleanbooleanbooleanbooleanshouldLockOnCacheMiss(BlockType blockType) If we make sure the block could not be cached, we will not acquire the lock otherwise we will acquire lockbooleanReturns true if blocks should be prefetched into the cache on open, false if notbooleanshouldReadBlockFromCache(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:
-
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:
-
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_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:
-
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
-
-
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.BlockCategoryshould 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,cacheDataOnWriteshould honor the CF levelisBlockCacheEnabledconfiguration. -
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
-
getCacheCompactedBlocksOnWriteThreshold
-
toString
-
onConfigurationChange
Description copied from interface:ConfigurationObserverThis method would be called by theConfigurationManagerobject when theConfigurationobject is reloaded from disk.- Specified by:
onConfigurationChangein interfaceConfigurationObserver
-