HBASE-30206 Add test factory helpers for CacheAccessService-backed ca…#8359
Merged
taklwu merged 1 commit intoJun 16, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds bridge utilities to simplify test migration from legacy BlockCache implementations to the newer CacheAccessService facade, while keeping the underlying legacy cache construction paths intact.
Changes:
- Add
CacheAccessServices.fromConfiguration(Configuration)to build aCacheAccessServicevia the existingBlockCacheFactorypath. - Introduce test-only helpers (
CacheAccessServiceTestFactory,CacheAccessServiceTestInstance) to create/wrap legacy cache implementations with aCacheAccessService. - Add a new unit test class covering the new test factory helpers.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/CacheAccessServices.java | Adds a Configuration-based factory method for producing CacheAccessService via BlockCacheFactory. |
| hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/CacheAccessServiceTestFactory.java | Provides test-only “constructor-shaped” helpers to create legacy caches and return a CacheAccessService or paired instance. |
| hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/CacheAccessServiceTestInstance.java | Adds a helper wrapper that keeps a concrete BlockCache alongside its CacheAccessService facade. |
| hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestCacheAccessServiceTestFactory.java | Adds unit tests for the new test factory helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
|
Thank you, @taklwu for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds test-only factory helpers for creating CacheAccessService instances backed by existing legacy BlockCache implementations.
The goal is to make test migration to CacheAccessService less verbose. Many existing tests directly instantiate concrete BlockCache implementations such as LruBlockCache, LruAdaptiveBlockCache, TinyLfuBlockCache, and BucketCache. For integration-style tests that only need a cache facade, replacing a one-line constructor with several lines of BlockCache construction plus CacheAccessService wrapping adds noise.
This PR provides constructor-shaped test helpers that keep those tests concise while preserving the current legacy-backed implementation path.
Changes
Compatibility notes
The factory helpers are test-only bridge utilities. They currently create legacy BlockCache implementations and wrap them with BlockCacheBackedCacheAccessService.
This does not change production cache construction. It also does not migrate existing cache implementations to CacheEngine. Later, when CacheEngine and topology-backed services are available, these factory internals can be updated without rewriting all integration-style tests again.
Out of scope
Testing
Ran:
mvn -pl hbase-server -Dtest=TestCacheAccessServiceTestFactory test mvn -pl hbase-server -DskipTests compile mvn -pl hbase-server spotless:check mvn -pl hbase-server checkstyle:checkDisclosure
Parts of this PR, including helper code structure and PR description text, were prepared with assistance from ChatGPT 5.5 and reviewed by the author.