Skip to content

HBASE-30196 Add diagnostic cached-block iteration capability for plug…#8384

Open
VladRodionov wants to merge 1 commit into
apache:HBASE-30018from
VladRodionov:HBASE-30196-cache-diagnostic-iteration
Open

HBASE-30196 Add diagnostic cached-block iteration capability for plug…#8384
VladRodionov wants to merge 1 commit into
apache:HBASE-30018from
VladRodionov:HBASE-30196-cache-diagnostic-iteration

Conversation

@VladRodionov

@VladRodionov VladRodionov commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds a diagnostic/test bridge for cached-block iteration while the block cache architecture is migrating from direct BlockCache usage toward CacheAccessService.

The existing BlockCache interface extends Iterable, and a number of tests and diagnostic paths rely on that capability. CacheAccessService should remain the normal read/write-path facade and should not become a full replacement for every BlockCache method. However, tests and diagnostics still need a way to access the legacy cached-block iterator during the transition.

Changes

  • Allows BlockCacheBackedCacheAccessService to expose the cached-block iteration capability by delegating to the backing BlockCache.
  • Adds helper support for discovering or unwrapping diagnostic cache views from CacheAccessService in test code.
  • Adds/updates test factory support for compatibility tests that need both CacheAccessService and the underlying legacy BlockCache.
  • Updates affected tests to work through CacheAccessService while preserving existing diagnostic/cache-inspection behavior.

Compatibility notes

This is a transition/diagnostic capability. It does not change cache read/write semantics.

The main runtime path still uses CacheAccessService for cache access. Cached-block iteration remains intended for tests, diagnostics, and admin-style inspection only. Future CacheEngine/topology-backed implementations can expose equivalent diagnostic iteration when available.

Out of scope

  • No BlockCacheFactory refactoring.
  • No CacheEngine runtime wiring.
  • No migration of LruBlockCache, LruAdaptiveBlockCache, TinyLfuBlockCache, or BucketCache to CacheEngine.
  • No broad test migration.
  • No cache eviction/admission behavior changes.

Testing

Ran:

mvn -pl hbase-server  test
mvn -pl hbase-server -DskipTests compile
mvn -pl hbase-server spotless:check
mvn -pl hbase-server checkstyle:check

Disclosure

Parts of this PR, including helper code structure and PR description text, were prepared with assistance from ChatGPT and reviewed 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 diagnostic bridge for cached-block iteration while the HBase block cache API migrates from direct BlockCache usage toward CacheAccessService. It updates several tests to use CacheAccessService while preserving the ability to inspect cached blocks for diagnostic assertions.

Changes:

  • Make BlockCacheBackedCacheAccessService expose cached-block iteration by delegating to the backing BlockCache iterator.
  • Add/adjust CacheConfig constructors and test helpers to support CacheAccessService-based test wiring.
  • Update affected tests to use CacheAccessService while keeping legacy diagnostic/cache-inspection behavior.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSecureBulkLoadManager.java Update test CacheConfig construction to use CacheAccessService-aware constructor signature.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestRowIndexV1RoundTrip.java Update CacheConfig construction for CacheAccessService signature.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestPrefetch.java Switch test wiring from BlockCache to CacheAccessService via test factory.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileReaderImpl.java Mock CacheAccessService instead of BlockCache for corrupt-cache test path.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFile.java Update tests to create/access caches through CacheAccessService test factory and unwrap legacy cache when needed.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestForceCacheImportantBlocks.java Use CacheAccessService in test setup and stats checks; unwrap legacy BlockCache for region creation.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestCacheOnWrite.java Convert cache-on-write tests to CacheAccessService while retaining cached-block inspection logic.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestCacheConfig.java Update cache config tests to use CacheAccessService test factory and the new APIs.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/CacheAccessServiceTestFactory.java Add helper to unwrap the legacy BlockCache from a CacheAccessService for compatibility tests.
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAvoidCellReferencesIntoShippedBlocks.java Update test to obtain cached-block iteration via CacheAccessServices helper (but currently contains a runtime type bug).
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java Add constructors supporting CacheAccessService and centralize config initialization.
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/TopologyBackedCacheAccessService.java Add getCurrentSize() and adjust size-related documentation/behavior (currently inconsistent).
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/NoOpCacheAccessService.java Implement getCurrentSize() for the disabled cache service.
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/CacheAccessServices.java Add helper for optional cached-block iteration discovery via CacheAccessService.
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/CacheAccessService.java Extend ConfigurationObserver and add getCurrentSize() API.
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/BlockCacheBackedCacheAccessService.java Implement Iterable<CachedBlock> and delegate iteration and getCurrentSize() to the backing BlockCache.

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

Comment on lines +418 to +419
iterator = (Iterator<CachedBlock>) CacheAccessServices.asCachedBlockIterable(cache)
.orElseThrow();

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.

ditto

Comment thread hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestCacheOnWrite.java Outdated
* @param conf hbase configuration
* @param blockCache block cache to use for this configuration
*/
public CacheConfig(Configuration conf, BlockCache blockCache) {

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.

with the new public CacheConfig(Configuration conf, CacheAccessService service) { , will we migrate or remove this constructor in the future ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the test only constructor, which mirrors (Configuration, BlockCache) counterpart. The old one will be removed. Removing (Configuration conf, CacheAccessService service) will require some extensive refactoring of a CacheConfig class. Not sure if CacheConfig refactoring will be a part of this work.

Comment thread hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestCacheOnWrite.java Outdated
Comment on lines +418 to +419
iterator = (Iterator<CachedBlock>) CacheAccessServices.asCachedBlockIterable(cache)
.orElseThrow();

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.

ditto

@VladRodionov VladRodionov force-pushed the HBASE-30196-cache-diagnostic-iteration branch from dce868a to cffd012 Compare June 23, 2026 01:02
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