This is an automated email from the ASF dual-hosted git repository.

wchevreuil pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new db9ed63d072 HBASE-29732 Add hbase.rs.evictblocksonsplit to UI and 
CacheConfig logs (#7483) (#7564)
db9ed63d072 is described below

commit db9ed63d0722fe2f7675426e3a3474b551790acb
Author: Liu Xiao <[email protected]>
AuthorDate: Thu Dec 18 22:22:24 2025 +0800

    HBASE-29732 Add hbase.rs.evictblocksonsplit to UI and CacheConfig logs 
(#7483) (#7564)
    
    Signed-off-by: Dávid Paksy <[email protected]>
    Signed-off-by: Wellington Chevreuil <[email protected]>
---
 .../apache/hadoop/hbase/io/hfile/CacheConfig.java  | 44 +++++++++++++++++-----
 .../regionserver/blockCacheConfig.jsp              | 19 +++++++++-
 2 files changed, 52 insertions(+), 11 deletions(-)

diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
index fc8f4d56917..475a22703e1 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
@@ -73,6 +73,10 @@ public class CacheConfig implements 
PropagatingConfigurationObserver {
    */
   public static final String EVICT_BLOCKS_ON_CLOSE_KEY = 
"hbase.rs.evictblocksonclose";
 
+  /**
+   * Configuration key to evict all blocks of a parent region from the block 
cache when the region
+   * split or merge.
+   */
   public static final String EVICT_BLOCKS_ON_SPLIT_KEY = 
"hbase.rs.evictblocksonsplit";
 
   /**
@@ -146,6 +150,11 @@ public class CacheConfig implements 
PropagatingConfigurationObserver {
   /** Whether blocks of a file should be evicted when the file is closed */
   private volatile boolean evictOnClose;
 
+  /**
+   * Whether blocks of a parent region should be evicted from cache when the 
region split or merge
+   */
+  private boolean evictOnSplit;
+
   /** Whether data blocks should be stored in compressed and/or encrypted form 
in the cache */
   private boolean cacheDataCompressed;
 
@@ -202,17 +211,18 @@ public class CacheConfig implements 
PropagatingConfigurationObserver {
       // if they are enabled in the global configuration.
       this.cacheDataOnWrite =
         conf.getBoolean(CACHE_BLOCKS_ON_WRITE_KEY, DEFAULT_CACHE_DATA_ON_WRITE)
-          || (family == null ? false : family.isCacheDataOnWrite());
+          || (family != null && family.isCacheDataOnWrite());
       this.cacheIndexesOnWrite =
         conf.getBoolean(CACHE_INDEX_BLOCKS_ON_WRITE_KEY, 
DEFAULT_CACHE_INDEXES_ON_WRITE)
-          || (family == null ? false : family.isCacheIndexesOnWrite());
+          || (family != null && family.isCacheIndexesOnWrite());
       this.cacheBloomsOnWrite =
         conf.getBoolean(CACHE_BLOOM_BLOCKS_ON_WRITE_KEY, 
DEFAULT_CACHE_BLOOMS_ON_WRITE)
-          || (family == null ? false : family.isCacheBloomsOnWrite());
+          || (family != null && family.isCacheBloomsOnWrite());
       this.evictOnClose = conf.getBoolean(EVICT_BLOCKS_ON_CLOSE_KEY, 
DEFAULT_EVICT_ON_CLOSE)
-        || (family == null ? false : family.isEvictBlocksOnClose());
+        || (family != null && family.isEvictBlocksOnClose());
+      this.evictOnSplit = conf.getBoolean(EVICT_BLOCKS_ON_SPLIT_KEY, 
DEFAULT_EVICT_ON_SPLIT);
       this.prefetchOnOpen = conf.getBoolean(PREFETCH_BLOCKS_ON_OPEN_KEY, 
DEFAULT_PREFETCH_ON_OPEN)
-        || (family == null ? false : family.isPrefetchBlocksOnOpen());
+        || (family != null && family.isPrefetchBlocksOnOpen());
       this.cacheCompactedDataOnWrite = 
conf.getBoolean(CACHE_COMPACTED_BLOCKS_ON_WRITE_KEY,
         DEFAULT_CACHE_COMPACTED_BLOCKS_ON_WRITE);
       this.cacheCompactedDataOnWriteThreshold = 
getCacheCompactedBlocksOnWriteThreshold(conf);
@@ -233,6 +243,7 @@ public class CacheConfig implements 
PropagatingConfigurationObserver {
     this.cacheIndexesOnWrite = cacheConf.cacheIndexesOnWrite;
     this.cacheBloomsOnWrite = cacheConf.cacheBloomsOnWrite;
     this.evictOnClose = cacheConf.evictOnClose;
+    this.evictOnSplit = cacheConf.evictOnSplit;
     this.cacheDataCompressed = cacheConf.cacheDataCompressed;
     this.prefetchOnOpen = cacheConf.prefetchOnOpen;
     this.cacheCompactedDataOnWrite = cacheConf.cacheCompactedDataOnWrite;
@@ -250,9 +261,11 @@ public class CacheConfig implements 
PropagatingConfigurationObserver {
     this.cacheIndexesOnWrite = false;
     this.cacheBloomsOnWrite = false;
     this.evictOnClose = false;
+    this.evictOnSplit = false;
     this.cacheDataCompressed = false;
     this.prefetchOnOpen = false;
     this.cacheCompactedDataOnWrite = false;
+    this.cacheCompactedDataOnWriteThreshold = 
DEFAULT_CACHE_COMPACTED_BLOCKS_ON_WRITE_THRESHOLD;
     this.dropBehindCompaction = false;
     this.blockCache = null;
     this.byteBuffAllocator = ByteBuffAllocator.HEAP;
@@ -284,7 +297,7 @@ public class CacheConfig implements 
PropagatingConfigurationObserver {
   public boolean shouldCacheBlockOnRead(BlockCategory category, HFileInfo 
hFileInfo,
     Configuration conf) {
     Optional<Boolean> cacheFileBlock = Optional.of(true);
-    // For DATA blocks only, if BuckeCache is in use, we don't need to cache 
block again
+    // For DATA blocks only, if BucketCache is in use, we don't need to cache 
block again
     if (getBlockCache().isPresent() && category.equals(BlockCategory.DATA)) {
       Optional<Boolean> result = 
getBlockCache().get().shouldCacheFile(hFileInfo, conf);
       if (result.isPresent()) {
@@ -349,7 +362,6 @@ public class CacheConfig implements 
PropagatingConfigurationObserver {
   }
 
   /**
-   * Only used for testing.
    * @param evictOnClose whether blocks should be evicted from the cache when 
an HFile reader is
    *                     closed
    */
@@ -357,13 +369,21 @@ public class CacheConfig implements 
PropagatingConfigurationObserver {
     this.evictOnClose = evictOnClose;
   }
 
+  /**
+   * @return true if blocks of parent region should be evicted from the cache 
when the region split
+   *         or merge, false if not
+   */
+  public boolean shouldEvictOnSplit() {
+    return this.evictOnSplit;
+  }
+
   /** Returns true if data blocks should be compressed in the cache, false if 
not */
   public boolean shouldCacheDataCompressed() {
     return this.cacheDataOnRead && this.cacheDataCompressed;
   }
 
   /**
-   * Returns true if this {@link BlockCategory} should be compressed in 
blockcache, false otherwise
+   * Returns true if this {@link BlockCategory} should be compressed in 
BlockCache, false otherwise
    */
   public boolean shouldCacheCompressed(BlockCategory category) {
     switch (category) {
@@ -481,8 +501,12 @@ public class CacheConfig implements 
PropagatingConfigurationObserver {
     return "cacheDataOnRead=" + shouldCacheDataOnRead() + ", cacheDataOnWrite="
       + shouldCacheDataOnWrite() + ", cacheIndexesOnWrite=" + 
shouldCacheIndexesOnWrite()
       + ", cacheBloomsOnWrite=" + shouldCacheBloomsOnWrite() + ", 
cacheEvictOnClose="
-      + shouldEvictOnClose() + ", cacheDataCompressed=" + 
shouldCacheDataCompressed()
-      + ", prefetchOnOpen=" + shouldPrefetchOnOpen();
+      + shouldEvictOnClose() + ", cacheEvictOnSplit=" + shouldEvictOnSplit()
+      + ", cacheDataCompressed=" + shouldCacheDataCompressed() + ", 
prefetchOnOpen="
+      + shouldPrefetchOnOpen() + ", cacheCompactedDataOnWrite="
+      + shouldCacheCompactedBlocksOnWrite() + ", 
cacheCompactedDataOnWriteThreshold="
+      + getCacheCompactedBlocksOnWriteThreshold() + ", dropBehindCompaction="
+      + shouldDropBehindCompaction();
   }
 
   @Override
diff --git 
a/hbase-server/src/main/resources/hbase-webapps/regionserver/blockCacheConfig.jsp
 
b/hbase-server/src/main/resources/hbase-webapps/regionserver/blockCacheConfig.jsp
index d73652de4cb..43f204b89e0 100644
--- 
a/hbase-server/src/main/resources/hbase-webapps/regionserver/blockCacheConfig.jsp
+++ 
b/hbase-server/src/main/resources/hbase-webapps/regionserver/blockCacheConfig.jsp
@@ -40,7 +40,7 @@ if (cacheConfig == null) { %>
   <tr>
     <td>Cache DATA on Write</td>
     <td><%= cacheConfig.shouldCacheDataOnWrite() %></td>
-    <td>True if DATA blocks are cached on write.</td>
+    <td>True if DATA blocks are cached on write</td>
   </tr>
   <tr>
     <td>Cache INDEX on Write</td>
@@ -58,6 +58,12 @@ if (cacheConfig == null) { %>
     <td>True if blocks are evicted from cache when an HFile
       reader is closed</td>
   </tr>
+  <tr>
+    <td>Evict blocks on Split</td>
+    <td><%= cacheConfig.shouldEvictOnSplit() %></td>
+    <td>True if blocks of the parent region are evicted
+      from the cache when split or merge</td>
+  </tr>
   <tr>
     <td>Cache DATA in compressed format</td>
     <td><%= cacheConfig.shouldCacheDataCompressed() %></td>
@@ -68,5 +74,16 @@ if (cacheConfig == null) { %>
     <td><%= cacheConfig.shouldPrefetchOnOpen() %></td>
     <td>True if blocks are prefetched into cache on open</td>
   </tr>
+  <tr>
+    <td>Cache compacted data on Write</td>
+    <td><%= cacheConfig.shouldCacheCompactedBlocksOnWrite() %></td>
+    <td>True if blocks are cached while writing during compaction</td>
+  </tr>
+  <tr>
+    <td>Cache compacted data on Write Threshold</td>
+    <td><%= cacheConfig.getCacheCompactedBlocksOnWriteThreshold() %></td>
+    <td>Total file size in bytes threshold for caching
+      while writing during compaction</td>
+  </tr>
 </table>
 <% } %>

Reply via email to