Skip to content

HBASE-30024 Add BlockCache-backed CacheEngine adapter for TieredExclusiveTopology#8476

Merged
taklwu merged 1 commit into
apache:HBASE-30018from
VladRodionov:HBASE-30024-tiered-exclusive-topology
Jul 17, 2026
Merged

HBASE-30024 Add BlockCache-backed CacheEngine adapter for TieredExclusiveTopology#8476
taklwu merged 1 commit into
apache:HBASE-30018from
VladRodionov:HBASE-30024-tiered-exclusive-topology

Conversation

@VladRodionov

Copy link
Copy Markdown
Contributor

Summary

This PR adds a compatibility bridge from the existing BlockCache API to the new CacheEngine abstraction.

TieredExclusiveTopology and TopologyBackedCacheAccessService operate on CacheEngine instances, but the existing production cache implementations such as LruBlockCache, BucketCache, TinyLfuBlockCache, and LruAdaptiveBlockCache still implement BlockCache. BlockCacheBackedCacheEngine allows these legacy cache implementations to participate in topology-backed cache wiring before they are migrated to implement CacheEngine directly.

This is an incremental migration step. It does not change production cache wiring and does not remove or replace CombinedBlockCache.

Changes

  • Adds BlockCacheBackedCacheEngine, a CacheEngine adapter backed by an existing BlockCache.
  • Adds CacheEngines helper factory for creating CacheEngine instances from legacy BlockCache instances.
  • Adds unit tests for adapter delegation and null validation.
  • Adds tests proving that TopologyBackedCacheAccessService can operate through TieredExclusiveTopology using BlockCache-backed engines.

Migration path

The new cache architecture is moving toward:

CacheAccessService
  -> CacheTopology
      -> CacheEngine(s)

AI assistance disclosure

This PR was prepared with assistance from ChatGPT. All changes were reviewed, tested, and submitted by the author.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a transitional compatibility layer in hbase-server to let existing BlockCache implementations participate in the newer CacheEngine/CacheTopology wiring (specifically TieredExclusiveTopology + TopologyBackedCacheAccessService) without changing current production cache configuration.

Changes:

  • Introduces BlockCacheBackedCacheEngine, a CacheEngine adapter that delegates storage operations to an underlying legacy BlockCache.
  • Adds CacheEngines factory helpers to wrap a BlockCache as a CacheEngine with null validation.
  • Adds unit tests for adapter delegation/validation and integration-style tests exercising TopologyBackedCacheAccessService through a tiered topology using block-cache-backed engines.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/BlockCacheBackedCacheEngine.java Adds a CacheEngine adapter delegating to a wrapped BlockCache.
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/CacheEngines.java Adds a small factory utility to create CacheEngine instances from BlockCache.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestBlockCacheBackedCacheEngine.java Adds delegation and argument-validation tests for the adapter.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestCacheEngines.java Adds tests for the CacheEngines.fromBlockCache factory helper.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestTopologyBackedCacheAccessServiceWithBlockCacheBackedEngines.java Adds tests proving topology-backed cache access works using BlockCache-backed engines across tiers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


@Tag(IOTests.TAG)
@Tag(SmallTests.TAG)
class TestCacheEngines {
Comment on lines +174 to +182
@Test
void testFactoryCreatesBlockCacheBackedEngine() {
BlockCache blockCache = mock(BlockCache.class);
CacheEngine engine = CacheEngines.fromBlockCache(blockCache);

assertTrue(engine instanceof BlockCacheBackedCacheEngine);
assertSame(blockCache, ((BlockCacheBackedCacheEngine) engine).getBlockCache());
}

Comment on lines +183 to +187
@Test
void testFactoryRejectsNullBlockCache() {
assertThrows(NullPointerException.class, () -> CacheEngines.fromBlockCache(null));
}

@anmolnar anmolnar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

@taklwu taklwu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +138 to +139
verify(l1).cacheBlock(key, block, false, false);
verify(l2).cacheBlock(key, block, false, false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a blocker: this is a interesting show case, basically we I don't think we have this forked cache today.

@taklwu
taklwu merged commit b8cb97f into apache:HBASE-30018 Jul 17, 2026
13 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants