@InterfaceAudience.Private public class CacheConfig extends Object
Modifier and Type | Field and Description |
---|---|
private BlockCache |
blockCache |
private ByteBuffAllocator |
byteBuffAllocator |
static String |
CACHE_BLOCKS_ON_WRITE_KEY
Configuration key to cache data blocks on write.
|
static String |
CACHE_BLOOM_BLOCKS_ON_WRITE_KEY
Configuration key to cache compound bloom filter blocks on write.
|
static String |
CACHE_COMPACTED_BLOCKS_ON_WRITE_KEY
Configuration key to cache blocks when a compacted file is written
|
static String |
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
|
static String |
CACHE_DATA_BLOCKS_COMPRESSED_KEY
Configuration key to cache data blocks in compressed and/or encrypted format.
|
static String |
CACHE_DATA_ON_READ_KEY
Configuration key to cache data blocks on read.
|
static String |
CACHE_INDEX_BLOCKS_ON_WRITE_KEY
Configuration key to cache leaf and intermediate-level index blocks on write.
|
private boolean |
cacheBloomsOnWrite
Whether compound bloom filter blocks should be cached on write
|
private boolean |
cacheCompactedDataOnWrite
Whether data blocks should be cached when compacted file is written
|
private long |
cacheCompactedDataOnWriteThreshold
Determine threshold beyond which we do not cache blocks on compaction
|
private boolean |
cacheDataCompressed
Whether data blocks should be stored in compressed and/or encrypted form in the cache
|
private boolean |
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).
|
private boolean |
cacheDataOnWrite
Whether data blocks should be cached when new files are written
|
private boolean |
cacheIndexesOnWrite
Whether index blocks should be cached when new files are written
|
static boolean |
DEFAULT_CACHE_BLOOMS_ON_WRITE |
static boolean |
DEFAULT_CACHE_COMPACTED_BLOCKS_ON_WRITE |
static long |
DEFAULT_CACHE_COMPACTED_BLOCKS_ON_WRITE_THRESHOLD |
static boolean |
DEFAULT_CACHE_DATA_COMPRESSED |
static boolean |
DEFAULT_CACHE_DATA_ON_READ |
static boolean |
DEFAULT_CACHE_DATA_ON_WRITE |
static boolean |
DEFAULT_CACHE_INDEXES_ON_WRITE |
static boolean |
DEFAULT_EVICT_ON_CLOSE |
static boolean |
DEFAULT_IN_MEMORY |
static boolean |
DEFAULT_PREFETCH_ON_OPEN |
static CacheConfig |
DISABLED
Disabled cache configuration
|
static boolean |
DROP_BEHIND_CACHE_COMPACTION_DEFAULT |
static String |
DROP_BEHIND_CACHE_COMPACTION_KEY |
private boolean |
dropBehindCompaction |
static String |
EVICT_BLOCKS_ON_CLOSE_KEY
Configuration key to evict all blocks of a given file from the block cache when the file is
closed.
|
private boolean |
evictOnClose
Whether blocks of a file should be evicted when the file is closed
|
private boolean |
inMemory
Whether blocks should be flagged as in-memory when being cached
|
private static org.slf4j.Logger |
LOG |
static String |
PREFETCH_BLOCKS_ON_OPEN_KEY
Configuration key to prefetch all blocks of a given file into the block cache when the file is
opened.
|
private boolean |
prefetchOnOpen
Whether data blocks should be prefetched into the cache
|
Modifier | Constructor and Description |
---|---|
private |
CacheConfig() |
|
CacheConfig(CacheConfig cacheConf)
Constructs a cache configuration copied from the specified configuration.
|
|
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,
BlockCache blockCache) |
|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
enableCacheOnWrite()
Enable cache on write including: cacheDataOnWrite cacheIndexesOnWrite cacheBloomsOnWrite
|
Optional<BlockCache> |
getBlockCache()
Returns the block cache.
|
ByteBuffAllocator |
getByteBuffAllocator() |
long |
getCacheCompactedBlocksOnWriteThreshold()
Returns total file size in bytes threshold for caching while writing during compaction
|
private long |
getCacheCompactedBlocksOnWriteThreshold(org.apache.hadoop.conf.Configuration conf) |
boolean |
isCombinedBlockCache() |
boolean |
isInMemory()
Returns true if blocks in this file should be flagged as in-memory
|
void |
setCacheDataOnWrite(boolean cacheDataOnWrite) |
void |
setEvictOnClose(boolean evictOnClose)
Only used for testing.
|
boolean |
shouldCacheBlockOnRead(BlockType.BlockCategory category)
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 |
shouldCacheBloomsOnWrite() |
boolean |
shouldCacheCompactedBlocksOnWrite()
Returns true if blocks should be cached while writing during compaction, false if not
|
boolean |
shouldCacheCompressed(BlockType.BlockCategory category)
Returns true if this
BlockType.BlockCategory should be compressed in blockcache, false otherwise |
boolean |
shouldCacheDataCompressed()
Returns true if data blocks should be compressed in the cache, false if not
|
boolean |
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).
|
boolean |
shouldCacheDataOnWrite() |
boolean |
shouldCacheIndexesOnWrite() |
boolean |
shouldDropBehindCompaction() |
boolean |
shouldEvictOnClose() |
boolean |
shouldLockOnCacheMiss(BlockType blockType)
If we make sure the block could not be cached, we will not acquire the lock otherwise we will
acquire lock
|
boolean |
shouldPrefetchOnOpen()
Returns true if blocks should be prefetched into the cache on open, false if not
|
boolean |
shouldReadBlockFromCache(BlockType blockType)
Return true if we may find this type of block in block cache.
|
String |
toString() |
private static final org.slf4j.Logger LOG
public static final CacheConfig DISABLED
public static final String CACHE_DATA_ON_READ_KEY
public static final String CACHE_BLOCKS_ON_WRITE_KEY
public static final String CACHE_INDEX_BLOCKS_ON_WRITE_KEY
public static final String CACHE_BLOOM_BLOCKS_ON_WRITE_KEY
public static final String CACHE_DATA_BLOCKS_COMPRESSED_KEY
public static final String EVICT_BLOCKS_ON_CLOSE_KEY
public static final String PREFETCH_BLOCKS_ON_OPEN_KEY
public static final String CACHE_COMPACTED_BLOCKS_ON_WRITE_KEY
public static final String CACHE_COMPACTED_BLOCKS_ON_WRITE_THRESHOLD_KEY
public static final String DROP_BEHIND_CACHE_COMPACTION_KEY
public static final boolean DEFAULT_CACHE_DATA_ON_READ
public static final boolean DEFAULT_CACHE_DATA_ON_WRITE
public static final boolean DEFAULT_IN_MEMORY
public static final boolean DEFAULT_CACHE_INDEXES_ON_WRITE
public static final boolean DEFAULT_CACHE_BLOOMS_ON_WRITE
public static final boolean DEFAULT_EVICT_ON_CLOSE
public static final boolean DEFAULT_CACHE_DATA_COMPRESSED
public static final boolean DEFAULT_PREFETCH_ON_OPEN
public static final boolean DEFAULT_CACHE_COMPACTED_BLOCKS_ON_WRITE
public static final boolean DROP_BEHIND_CACHE_COMPACTION_DEFAULT
public static final long DEFAULT_CACHE_COMPACTED_BLOCKS_ON_WRITE_THRESHOLD
private final boolean cacheDataOnRead
private final boolean inMemory
private boolean cacheDataOnWrite
private boolean cacheIndexesOnWrite
private boolean cacheBloomsOnWrite
private volatile boolean evictOnClose
private final boolean cacheDataCompressed
private final boolean prefetchOnOpen
private final boolean cacheCompactedDataOnWrite
private long cacheCompactedDataOnWriteThreshold
private final boolean dropBehindCompaction
private final BlockCache blockCache
private final ByteBuffAllocator byteBuffAllocator
public CacheConfig(org.apache.hadoop.conf.Configuration conf)
conf
- hbase configurationpublic CacheConfig(org.apache.hadoop.conf.Configuration conf, BlockCache blockCache)
public CacheConfig(org.apache.hadoop.conf.Configuration conf, ColumnFamilyDescriptor family, BlockCache blockCache, ByteBuffAllocator byteBuffAllocator)
conf
- hbase configurationfamily
- column family configurationpublic CacheConfig(CacheConfig cacheConf)
private CacheConfig()
public boolean shouldCacheDataOnRead()
public boolean shouldDropBehindCompaction()
public boolean shouldCacheBlockOnRead(BlockType.BlockCategory category)
public boolean isInMemory()
public boolean shouldCacheDataOnWrite()
public void setCacheDataOnWrite(boolean cacheDataOnWrite)
cacheDataOnWrite
- whether data blocks should be written to the cache when an HFile is
writtenpublic void enableCacheOnWrite()
public boolean shouldCacheIndexesOnWrite()
public boolean shouldCacheBloomsOnWrite()
public boolean shouldEvictOnClose()
public void setEvictOnClose(boolean evictOnClose)
evictOnClose
- whether blocks should be evicted from the cache when an HFile reader is
closedpublic boolean shouldCacheDataCompressed()
public boolean shouldCacheCompressed(BlockType.BlockCategory category)
BlockType.BlockCategory
should be compressed in blockcache, false otherwisepublic boolean shouldPrefetchOnOpen()
public boolean shouldCacheCompactedBlocksOnWrite()
public long getCacheCompactedBlocksOnWriteThreshold()
public boolean shouldReadBlockFromCache(BlockType blockType)
TODO: today family.isBlockCacheEnabled()
only means cacheDataOnRead
, so here we
consider lots of other configurations such as cacheDataOnWrite
. We should fix this in
the future, cacheDataOnWrite
should honor the CF level isBlockCacheEnabled
configuration.
public boolean shouldLockOnCacheMiss(BlockType blockType)
public Optional<BlockCache> getBlockCache()
public boolean isCombinedBlockCache()
public ByteBuffAllocator getByteBuffAllocator()
private long getCacheCompactedBlocksOnWriteThreshold(org.apache.hadoop.conf.Configuration conf)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.