Skip to content

Commit c354c23

Browse files
committed
HBASE-29732 Add hbase.rs.evictblocksonsplit to UI and CacheConfig logs (#7483)
Signed-off-by: Dávid Paksy <[email protected]> Signed-off-by: Wellington Chevreuil <[email protected]>
1 parent 569842c commit c354c23

2 files changed

Lines changed: 52 additions & 11 deletions

File tree

hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ public class CacheConfig implements PropagatingConfigurationObserver {
7373
*/
7474
public static final String EVICT_BLOCKS_ON_CLOSE_KEY = "hbase.rs.evictblocksonclose";
7575

76+
/**
77+
* Configuration key to evict all blocks of a parent region from the block cache when the region
78+
* split or merge.
79+
*/
7680
public static final String EVICT_BLOCKS_ON_SPLIT_KEY = "hbase.rs.evictblocksonsplit";
7781

7882
/**
@@ -146,6 +150,11 @@ public class CacheConfig implements PropagatingConfigurationObserver {
146150
/** Whether blocks of a file should be evicted when the file is closed */
147151
private volatile boolean evictOnClose;
148152

153+
/**
154+
* Whether blocks of a parent region should be evicted from cache when the region split or merge
155+
*/
156+
private boolean evictOnSplit;
157+
149158
/** Whether data blocks should be stored in compressed and/or encrypted form in the cache */
150159
private boolean cacheDataCompressed;
151160

@@ -202,17 +211,18 @@ public CacheConfig(Configuration conf, ColumnFamilyDescriptor family, BlockCache
202211
// if they are enabled in the global configuration.
203212
this.cacheDataOnWrite =
204213
conf.getBoolean(CACHE_BLOCKS_ON_WRITE_KEY, DEFAULT_CACHE_DATA_ON_WRITE)
205-
|| (family == null ? false : family.isCacheDataOnWrite());
214+
|| (family != null && family.isCacheDataOnWrite());
206215
this.cacheIndexesOnWrite =
207216
conf.getBoolean(CACHE_INDEX_BLOCKS_ON_WRITE_KEY, DEFAULT_CACHE_INDEXES_ON_WRITE)
208-
|| (family == null ? false : family.isCacheIndexesOnWrite());
217+
|| (family != null && family.isCacheIndexesOnWrite());
209218
this.cacheBloomsOnWrite =
210219
conf.getBoolean(CACHE_BLOOM_BLOCKS_ON_WRITE_KEY, DEFAULT_CACHE_BLOOMS_ON_WRITE)
211-
|| (family == null ? false : family.isCacheBloomsOnWrite());
220+
|| (family != null && family.isCacheBloomsOnWrite());
212221
this.evictOnClose = conf.getBoolean(EVICT_BLOCKS_ON_CLOSE_KEY, DEFAULT_EVICT_ON_CLOSE)
213-
|| (family == null ? false : family.isEvictBlocksOnClose());
222+
|| (family != null && family.isEvictBlocksOnClose());
223+
this.evictOnSplit = conf.getBoolean(EVICT_BLOCKS_ON_SPLIT_KEY, DEFAULT_EVICT_ON_SPLIT);
214224
this.prefetchOnOpen = conf.getBoolean(PREFETCH_BLOCKS_ON_OPEN_KEY, DEFAULT_PREFETCH_ON_OPEN)
215-
|| (family == null ? false : family.isPrefetchBlocksOnOpen());
225+
|| (family != null && family.isPrefetchBlocksOnOpen());
216226
this.cacheCompactedDataOnWrite = conf.getBoolean(CACHE_COMPACTED_BLOCKS_ON_WRITE_KEY,
217227
DEFAULT_CACHE_COMPACTED_BLOCKS_ON_WRITE);
218228
this.cacheCompactedDataOnWriteThreshold = getCacheCompactedBlocksOnWriteThreshold(conf);
@@ -233,6 +243,7 @@ public CacheConfig(CacheConfig cacheConf) {
233243
this.cacheIndexesOnWrite = cacheConf.cacheIndexesOnWrite;
234244
this.cacheBloomsOnWrite = cacheConf.cacheBloomsOnWrite;
235245
this.evictOnClose = cacheConf.evictOnClose;
246+
this.evictOnSplit = cacheConf.evictOnSplit;
236247
this.cacheDataCompressed = cacheConf.cacheDataCompressed;
237248
this.prefetchOnOpen = cacheConf.prefetchOnOpen;
238249
this.cacheCompactedDataOnWrite = cacheConf.cacheCompactedDataOnWrite;
@@ -250,9 +261,11 @@ private CacheConfig() {
250261
this.cacheIndexesOnWrite = false;
251262
this.cacheBloomsOnWrite = false;
252263
this.evictOnClose = false;
264+
this.evictOnSplit = false;
253265
this.cacheDataCompressed = false;
254266
this.prefetchOnOpen = false;
255267
this.cacheCompactedDataOnWrite = false;
268+
this.cacheCompactedDataOnWriteThreshold = DEFAULT_CACHE_COMPACTED_BLOCKS_ON_WRITE_THRESHOLD;
256269
this.dropBehindCompaction = false;
257270
this.blockCache = null;
258271
this.byteBuffAllocator = ByteBuffAllocator.HEAP;
@@ -284,7 +297,7 @@ public boolean shouldCacheBlockOnRead(BlockCategory category) {
284297
public boolean shouldCacheBlockOnRead(BlockCategory category, HFileInfo hFileInfo,
285298
Configuration conf) {
286299
Optional<Boolean> cacheFileBlock = Optional.of(true);
287-
// For DATA blocks only, if BuckeCache is in use, we don't need to cache block again
300+
// For DATA blocks only, if BucketCache is in use, we don't need to cache block again
288301
if (getBlockCache().isPresent() && category.equals(BlockCategory.DATA)) {
289302
Optional<Boolean> result = getBlockCache().get().shouldCacheFile(hFileInfo, conf);
290303
if (result.isPresent()) {
@@ -349,21 +362,28 @@ public boolean shouldEvictOnClose() {
349362
}
350363

351364
/**
352-
* Only used for testing.
353365
* @param evictOnClose whether blocks should be evicted from the cache when an HFile reader is
354366
* closed
355367
*/
356368
public void setEvictOnClose(boolean evictOnClose) {
357369
this.evictOnClose = evictOnClose;
358370
}
359371

372+
/**
373+
* @return true if blocks of parent region should be evicted from the cache when the region split
374+
* or merge, false if not
375+
*/
376+
public boolean shouldEvictOnSplit() {
377+
return this.evictOnSplit;
378+
}
379+
360380
/** Returns true if data blocks should be compressed in the cache, false if not */
361381
public boolean shouldCacheDataCompressed() {
362382
return this.cacheDataOnRead && this.cacheDataCompressed;
363383
}
364384

365385
/**
366-
* Returns true if this {@link BlockCategory} should be compressed in blockcache, false otherwise
386+
* Returns true if this {@link BlockCategory} should be compressed in BlockCache, false otherwise
367387
*/
368388
public boolean shouldCacheCompressed(BlockCategory category) {
369389
switch (category) {
@@ -481,8 +501,12 @@ public String toString() {
481501
return "cacheDataOnRead=" + shouldCacheDataOnRead() + ", cacheDataOnWrite="
482502
+ shouldCacheDataOnWrite() + ", cacheIndexesOnWrite=" + shouldCacheIndexesOnWrite()
483503
+ ", cacheBloomsOnWrite=" + shouldCacheBloomsOnWrite() + ", cacheEvictOnClose="
484-
+ shouldEvictOnClose() + ", cacheDataCompressed=" + shouldCacheDataCompressed()
485-
+ ", prefetchOnOpen=" + shouldPrefetchOnOpen();
504+
+ shouldEvictOnClose() + ", cacheEvictOnSplit=" + shouldEvictOnSplit()
505+
+ ", cacheDataCompressed=" + shouldCacheDataCompressed() + ", prefetchOnOpen="
506+
+ shouldPrefetchOnOpen() + ", cacheCompactedDataOnWrite="
507+
+ shouldCacheCompactedBlocksOnWrite() + ", cacheCompactedDataOnWriteThreshold="
508+
+ getCacheCompactedBlocksOnWriteThreshold() + ", dropBehindCompaction="
509+
+ shouldDropBehindCompaction();
486510
}
487511

488512
@Override

hbase-server/src/main/resources/hbase-webapps/regionserver/blockCacheConfig.jsp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if (cacheConfig == null) { %>
4040
<tr>
4141
<td>Cache DATA on Write</td>
4242
<td><%= cacheConfig.shouldCacheDataOnWrite() %></td>
43-
<td>True if DATA blocks are cached on write.</td>
43+
<td>True if DATA blocks are cached on write</td>
4444
</tr>
4545
<tr>
4646
<td>Cache INDEX on Write</td>
@@ -58,6 +58,12 @@ if (cacheConfig == null) { %>
5858
<td>True if blocks are evicted from cache when an HFile
5959
reader is closed</td>
6060
</tr>
61+
<tr>
62+
<td>Evict blocks on Split</td>
63+
<td><%= cacheConfig.shouldEvictOnSplit() %></td>
64+
<td>True if blocks of the parent region are evicted
65+
from the cache when split or merge</td>
66+
</tr>
6167
<tr>
6268
<td>Cache DATA in compressed format</td>
6369
<td><%= cacheConfig.shouldCacheDataCompressed() %></td>
@@ -68,5 +74,16 @@ if (cacheConfig == null) { %>
6874
<td><%= cacheConfig.shouldPrefetchOnOpen() %></td>
6975
<td>True if blocks are prefetched into cache on open</td>
7076
</tr>
77+
<tr>
78+
<td>Cache compacted data on Write</td>
79+
<td><%= cacheConfig.shouldCacheCompactedBlocksOnWrite() %></td>
80+
<td>True if blocks are cached while writing during compaction</td>
81+
</tr>
82+
<tr>
83+
<td>Cache compacted data on Write Threshold</td>
84+
<td><%= cacheConfig.getCacheCompactedBlocksOnWriteThreshold() %></td>
85+
<td>Total file size in bytes threshold for caching
86+
while writing during compaction</td>
87+
</tr>
7188
</table>
7289
<% } %>

0 commit comments

Comments
 (0)