Skip to content

HBASE-30023 Refactor write path, prefetch, and compaction cache popul…#8325

Open
VladRodionov wants to merge 1 commit into
apache:HBASE-30018from
VladRodionov:HBASE-30023-cache-access-service-write-path
Open

HBASE-30023 Refactor write path, prefetch, and compaction cache popul…#8325
VladRodionov wants to merge 1 commit into
apache:HBASE-30018from
VladRodionov:HBASE-30023-cache-access-service-write-path

Conversation

@VladRodionov

Copy link
Copy Markdown
Contributor

Summary

This PR continues the pluggable block cache refactoring by migrating cache population paths to use CacheAccessService instead of calling BlockCache directly where the code is part of HFile cache access behavior.

The change keeps the runtime behavior legacy-compatible. Existing BlockCache implementations are still used through BlockCacheBackedCacheAccessService. This PR does not refactor BlockCacheFactory, does not introduce CacheEngine-backed runtime wiring, and does not attempt to migrate all remaining BlockCache references.

The main goal is to make CacheAccessService the HBase-facing facade for cache lookup, insertion, invalidation, admission checks, and related cache operations while preserving existing behavior.

Changes

  • Migrates additional cache population code paths from direct BlockCache usage to CacheAccessService.
  • Preserves simple cacheBlock(...) overloads on CacheAccessService so legacy-style call sites do not need to construct CacheWriteContext manually.
  • Keeps CacheWriteContext available for future richer policy-aware cache insertion paths.
  • Adds/uses compatibility forwarding for cache admission hooks such as shouldCacheBlock(...) and shouldCacheFile(...) where existing paths depend on them.
  • Adds/uses CacheAccessService.ifEnabled(...) for call sites that need the old Optional#ifPresent(...) style behavior when cache is disabled.
  • Preserves disabled-cache behavior through NoOpCacheAccessService.
  • Updates affected tests.

Compatibility notes

This PR intentionally does not force every cache insertion call site to specify a precise CacheWriteSource.

Existing HBase cache population code does not always expose whether a block insertion comes from flush, compaction, bulk load, or another writer path. Guessing that source could introduce incorrect policy behavior later. Therefore, this PR keeps compatibility-oriented overloads and uses richer context only where the information is already available and meaningful.

Out of scope

  • No BlockCacheFactory refactoring.
  • No CacheEngine adapter migration.
  • No migration of LruBlockCache, LruAdaptiveBlockCache, TinyLfuBlockCache, or BucketCache to CacheEngine.
  • No removal of BlockCache from CacheConfig.
  • No removal of getBlockCache().
  • No migration of BlockCache.iterator().
  • No diagnostic JSP/admin page migration.
  • No broad migration of implementation-specific cache tests.
  • No topology-backed runtime wiring.

Testing

Ran the affected HFile cache-on-write test successfully:

bash mvn -pl hbase-server -Dtest=TestHFile#testWriterCacheOnWriteSkipDoesNotLeak test

Also verified build/package after resolving a stale local class output issue unrelated to this PR.

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.

1 participant