You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ta...@apache.org on 2026/09/30 18:05:35 UTC
(hbase) branch HBASE-30018 updated: HBASE-30380 Add configuration change propagation through CacheAccessService (#8704)
This is an automated email from the ASF dual-hosted git repository.
taklwu pushed a commit to branch HBASE-30018
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/HBASE-30018 by this push:
new 806ce17f6bc HBASE-30380 Add configuration change propagation through CacheAccessService (#8704)
806ce17f6bc is described below
commit 806ce17f6bc361cc1a79a06959ac97b468ad4cc4
Author: Vladimir Rodionov <vl...@gmail.com>
AuthorDate: Wed Sep 30 11:05:29 2026 -0700
HBASE-30380 Add configuration change propagation through CacheAccessService (#8704)
Signed-off-by: Tak Lon (Stephen) Wu <ta...@apache.org>
---
.../apache/hadoop/hbase/io/hfile/CacheConfig.java | 8 +++--
.../hadoop/hbase/io/hfile/cache/CacheEngine.java | 15 ++++++----
.../hadoop/hbase/io/hfile/TestCacheConfig.java | 31 ++++++++++++++++++++
.../cache/TestBlockCacheBackedCacheEngine.java | 12 ++++++++
.../TestTopologyBackedCacheAccessService.java | 34 ++++++++++++++++++++++
5 files changed, 92 insertions(+), 8 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 0950f58d29b..76901051b7b 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
@@ -641,11 +641,15 @@ public class CacheConfig implements PropagatingConfigurationObserver {
@Override
public void registerChildren(ConfigurationManager manager) {
- manager.registerObserver(blockCache);
+ if (cacheAccessService != null) {
+ manager.registerObserver(cacheAccessService);
+ }
}
@Override
public void deregisterChildren(ConfigurationManager manager) {
- manager.deregisterObserver(blockCache);
+ if (cacheAccessService != null) {
+ manager.deregisterObserver(cacheAccessService);
+ }
}
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/CacheEngine.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/CacheEngine.java
index 2b718344f8d..d175fc9e93d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/CacheEngine.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/CacheEngine.java
@@ -21,6 +21,7 @@ import java.util.Map;
import java.util.Optional;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.conf.ConfigurationObserver;
import org.apache.hadoop.hbase.io.hfile.BlockCacheKey;
import org.apache.hadoop.hbase.io.hfile.BlockType;
import org.apache.hadoop.hbase.io.hfile.CacheStats;
@@ -65,7 +66,7 @@ import org.apache.yetus.audience.InterfaceAudience;
* </ul>
*/
@InterfaceAudience.Private
-public interface CacheEngine {
+public interface CacheEngine extends ConfigurationObserver {
/**
* Returns a human-readable name for this cache engine instance.
@@ -309,14 +310,15 @@ public interface CacheEngine {
}
/**
- * Refreshes this engine's configuration.
+ * Handles a runtime configuration change.
* <p>
- * The default implementation is a no-op.
+ * The default implementation is a no-op. Cache engines that support dynamic reconfiguration may
+ * override this method.
* </p>
- * @param config new configuration
+ * @param conf updated configuration
*/
- default void onConfigurationChange(Configuration config) {
- // noop
+ @Override
+ default void onConfigurationChange(Configuration conf) {
}
/**
@@ -368,4 +370,5 @@ public interface CacheEngine {
default void setEvictionListener(CacheEvictionListener listener) {
// noop
}
+
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestCacheConfig.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestCacheConfig.java
index 4952f0d9043..52d5bf704c3 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestCacheConfig.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestCacheConfig.java
@@ -23,6 +23,8 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -36,6 +38,7 @@ import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.Waiter;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
+import org.apache.hadoop.hbase.conf.ConfigurationManager;
import org.apache.hadoop.hbase.io.ByteBuffAllocator;
import org.apache.hadoop.hbase.io.hfile.BlockType.BlockCategory;
import org.apache.hadoop.hbase.io.hfile.bucket.BucketCache;
@@ -468,4 +471,32 @@ public class TestCacheConfig {
assertTrue(l2.getBlockCount() > initialL2BlockCount);
}
+
+ /**
+ * Verifies that CacheConfig registers its CacheAccessService as a configuration child.
+ */
+ @Test
+ public void testRegistersCacheAccessServiceAsConfigurationChild() {
+ ConfigurationManager manager = mock(ConfigurationManager.class);
+ CacheConfig cacheConfig = new CacheConfig(conf);
+ CacheAccessService cacheAccessService = cacheConfig.getCacheAccessService();
+
+ cacheConfig.registerChildren(manager);
+
+ verify(manager).registerObserver(cacheAccessService);
+ }
+
+ /**
+ * Verifies that CacheConfig deregisters its CacheAccessService as a configuration child.
+ */
+ @Test
+ public void testDeregistersCacheAccessServiceAsConfigurationChild() {
+ ConfigurationManager manager = mock(ConfigurationManager.class);
+ CacheConfig cacheConfig = new CacheConfig(conf);
+ CacheAccessService cacheAccessService = cacheConfig.getCacheAccessService();
+
+ cacheConfig.deregisterChildren(manager);
+
+ verify(manager).deregisterObserver(cacheAccessService);
+ }
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestBlockCacheBackedCacheEngine.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestBlockCacheBackedCacheEngine.java
index 13384cf6499..388f90ba238 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestBlockCacheBackedCacheEngine.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestBlockCacheBackedCacheEngine.java
@@ -217,4 +217,16 @@ public class TestBlockCacheBackedCacheEngine {
assertFalse(engine.isCacheEnabled());
}
+
+ /**
+ * Verifies that configuration changes are propagated to the wrapped legacy block cache.
+ */
+ @Test
+ public void testConfigurationChangePropagatedToLegacyBlockCache() {
+ BlockCache blockCache = mock(BlockCache.class);
+ BlockCacheBackedCacheEngine engine = new BlockCacheBackedCacheEngine(blockCache);
+ Configuration conf = new Configuration(false);
+ engine.onConfigurationChange(conf);
+ verify(blockCache).onConfigurationChange(conf);
+ }
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestTopologyBackedCacheAccessService.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestTopologyBackedCacheAccessService.java
index 9d7be3dad5a..4f7967e7ad5 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestTopologyBackedCacheAccessService.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestTopologyBackedCacheAccessService.java
@@ -522,6 +522,40 @@ public class TestTopologyBackedCacheAccessService {
verify(topology, never()).handleAccess(key, l2);
}
+ /**
+ * Verifies that configuration changes are propagated to the engine in a single-tier topology.
+ */
+ @Test
+ public void testConfigurationChangePropagatedToSingleTierEngine() {
+ CacheEngine engine = mock(CacheEngine.class);
+ CacheTopology topology = new SingleTierTopology("single", engine);
+ TopologyBackedCacheAccessService service = new TopologyBackedCacheAccessService(topology,
+ new DefaultHBaseCachePlacementAdmissionPolicy());
+ Configuration conf = new Configuration(false);
+
+ service.onConfigurationChange(conf);
+
+ verify(engine).onConfigurationChange(conf);
+ }
+
+ /**
+ * Verifies that configuration changes are propagated to every engine in a tiered topology.
+ */
+ @Test
+ public void testConfigurationChangePropagatedToTieredEngines() {
+ CacheEngine l1 = mock(CacheEngine.class);
+ CacheEngine l2 = mock(CacheEngine.class);
+ CacheTopology topology = new TieredExclusiveTopology("tiered", l1, l2);
+ TopologyBackedCacheAccessService service = new TopologyBackedCacheAccessService(topology,
+ new DefaultHBaseCachePlacementAdmissionPolicy());
+ Configuration conf = new Configuration(false);
+
+ service.onConfigurationChange(conf);
+
+ verify(l1).onConfigurationChange(conf);
+ verify(l2).onConfigurationChange(conf);
+ }
+
private static CacheRequestContext requestContext() {
return CacheRequestContext.newBuilder().withCaching(true).withRepeat(false)
.withUpdateCacheMetrics(true).withBlockType(BlockType.DATA).build();