Skip to content

HBASE-30329 Add topology-backed cache diagnostics - #8575

Open
VladRodionov wants to merge 1 commit into
apache:HBASE-30018from
VladRodionov:HBASE-30329-topology-cache-diagnostics
Open

HBASE-30329 Add topology-backed cache diagnostics#8575
VladRodionov wants to merge 1 commit into
apache:HBASE-30018from
VladRodionov:HBASE-30329-topology-cache-diagnostics

Conversation

@VladRodionov

Copy link
Copy Markdown
Contributor

Summary

This PR extends the topology-backed cache access framework so that cache diagnostics and cache
access are consistently routed through TopologyBackedCacheAccessService.

The main change is that plain single-tier BlockCache implementations now use the same
topology-backed access path as combined caches. Single-tier caches are represented by
SingleTierTopology, while existing two-tier cache variants continue to use topology-specific
representations:

  • BlockCache -> SingleTierTopology
  • CombinedBlockCache -> TieredExclusiveTopology
  • InclusiveCombinedBlockCache -> TieredInclusiveTopology

This keeps the legacy cache implementations underneath through BlockCacheBackedCacheEngine, but
moves the access-service boundary to the topology/cache-engine model.

Motivation

After HBASE-30305, exclusive combined-cache orchestration was moved behind
TopologyBackedCacheAccessService. Follow-up testing showed that diagnostic and compatibility paths
still had assumptions about BlockCacheBackedCacheAccessService and concrete BlockCache
implementations.

This PR removes those assumptions from the main factory path by making topology-backed access the
normal path for both single-tier and combined caches.

Changes

  • Added SingleTierTopology.
  • Added CacheTopologyType.SINGLE_TIER.
  • Added topology-backed factory support for single-tier BlockCache instances.
  • Added explicit topology-backed support for InclusiveCombinedBlockCache.
  • Preserved separate semantics for exclusive and inclusive combined caches:
    • exclusive promotion moves a block between tiers;
    • inclusive promotion copies a block and keeps the source tier;
    • inclusive eviction evicts from all tiers.
  • Added cached-block iterable diagnostics through the topology-backed service.
  • Preserved legacy default cacheBlock(key, block) behavior for single-tier caches.
  • Added test helpers for unwrapping legacy BlockCache instances from topology-backed services
    where tests still need direct compatibility checks.
  • Added focused tests for:
    • single-tier topology-backed cache access;
    • exclusive combined-cache compatibility;
    • inclusive combined-cache compatibility.

Compatibility notes

BlockCacheBackedCacheAccessService is no longer the default factory result for plain block caches.
Instead, the main factory now returns a TopologyBackedCacheAccessService backed by
SingleTierTopology.

The underlying legacy BlockCache implementations are still preserved through
BlockCacheBackedCacheEngine. This PR does not migrate LruBlockCache, BucketCache, or other
concrete cache implementations to native CacheEngine implementations yet. That remains a follow-up
migration step.

Testing

Focused tests:

mvn -pl hbase-server \
  -Dtest=TestSingleTierTopologyBackedCacheAccessService test

mvn -pl hbase-server \
  -Dtest=TestCombinedBlockCacheCompatibleTopologyBackedCacheAccessService test

mvn -pl hbase-server \
  -Dtest=TestInclusiveCombinedBlockCacheCompatibleTopologyBackedCacheAccessService test

mvn -pl hbase-server \
  -Dtest=TestHFile test

mvn -pl hbase-server \
  -Dtest=TestBlockCacheReporting test

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

Routes legacy block caches and diagnostics through the topology-backed cache framework.

Changes:

  • Adds single-tier and inclusive topology-backed cache support.
  • Adds aggregated cached-block iteration diagnostics.
  • Migrates compatibility helpers and tests to topology-backed services.

Reviewed changes

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

Show a summary per file
File Description
TestCacheOnWrite.java Uses topology-aware cache unwrapping.
TestCacheConfig.java Verifies topology-backed configuration.
TestSingleTierTopologyBackedCacheAccessService.java Tests single-tier behavior.
TestInclusiveCombinedBlockCacheCompatibleTopologyBackedCacheAccessService.java Tests inclusive topology semantics.
TestCacheAccessServices.java Updates factory expectations.
TestBlockCacheBackedCacheAccessService.java Removes legacy adapter tests.
CacheAccessServiceTestFactory.java Unwraps topology-backed caches.
CacheConfig.java Preserves single-tier legacy cache access.
TopologyBackedCacheAccessServices.java Adds single-tier and inclusive factories.
TopologyBackedCacheAccessService.java Adds single-tier writes and block iteration.
SingleTierTopology.java Defines the single-tier topology.
SingleEngineTopology.java Renames its topology type.
DefaultHBaseCachePlacementAdmissionPolicy.java Updates single-tier policy handling.
CacheTopologyType.java Introduces SINGLE_TIER.
CacheAccessServices.java Routes all cache variants by topology.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +80 to +81
return TopologyBackedCacheAccessServices.fromSingleBlockCache("single", blockCache,
DefaultHBaseCachePlacementAdmissionPolicy.INSTANCE);
Comment on lines +137 to +144
BlockCache[] blockCaches = combinedBlockCache.getBlockCaches();
if (blockCaches.length != 2) {
throw new IllegalArgumentException(
"InclusiveCombinedBlockCache must expose exactly two block caches");
}

return fromTieredInclusiveBlockCaches("inclusive-combined", blockCaches[0], blockCaches[1],
DefaultHBaseCachePlacementAdmissionPolicy.INSTANCE);
Comment on lines +263 to +266
Optional<CacheEngine> engine = topology.getEngine(CacheTier.L1);
if (!engine.isPresent()) {
return;
}

@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.

actually we get more than just topology-backed cache diagnostics , the single-tier caches refactoring. maybe call the title as Add topology-backed cache diagnostics and migrate single tier cache

* </p>
*/
@InterfaceAudience.Private
public class SingleEngineTopology implements CacheTopology {

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.

will this SingleEngineTopology use with SingleTierTopology ? or how does it work in the upcoming/next JIRA?

mainly I found no usage about this SingleEngineTopology

* assertions, cached-block iteration, metrics inspection, or other diagnostic checks.
* </p>
* <p>
* Only {@link BlockCacheBackedCacheAccessService} is supported. Services backed by future

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.

it seems this line of comment is no longer valid that we're using TopologyBackedCacheAccessServices, can you update the comment of blockCache?

*/
if (topologyView.getType() == CacheTopologyType.SINGLE) {
if (topologyView.getType() == CacheTopologyType.SINGLE_TIER) {
return TierDecision.single(CacheTier.SINGLE);

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.

I'm wondered if CacheTier.SINGLE should be removed and only keep L1 and L2? but let me know if my understanding is incorrect.

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.

3 participants