Class IndexingStateCache
java.lang.Object
org.apache.druid.segment.metadata.IndexingStateCache
- Direct Known Subclasses:
NoopIndexingStateCache
In-memory cache of indexing states used by
HeapMemorySegmentMetadataCache.
This cache stores indexing states for published segments polled from the metadata store. It is the primary way to read indexing states in production.
The cache is populated during segment metadata cache sync operations and provides fast lookups without hitting the database.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIndexingState(String fingerprint, CompactionState state) Adds or updates a single indexing state in the cache.voidclear()Clears the cache.getIndexingStateByFingerprint(String fingerprint) Retrieves an indexing state by its fingerprint.Gets the full cached map (immutable copy).booleanvoidresetIndexingStatesForPublishedSegments(Map<String, CompactionState> fingerprintToStateMap) Resets the cache with indexing states polled from the metadata store.
-
Constructor Details
-
IndexingStateCache
public IndexingStateCache()
-
-
Method Details
-
isEnabled
public boolean isEnabled() -
resetIndexingStatesForPublishedSegments
public void resetIndexingStatesForPublishedSegments(Map<String, CompactionState> fingerprintToStateMap) Resets the cache with indexing states polled from the metadata store. Called after each successful poll in HeapMemorySegmentMetadataCache.- Parameters:
fingerprintToStateMap- Complete fp:state map of all active indexing state fingerprints
-
getIndexingStateByFingerprint
Retrieves an indexing state by its fingerprint. This is the indexing method for reading indexing states.- Parameters:
fingerprint- The fingerprint to look up- Returns:
- The cached indexing state, or Optional.empty() if not cached
-
addIndexingState
Adds or updates a single indexing state in the cache.This is called when a new indexing state is persisted to the database via upsertIndexingState to ensure the cache is immediately consistent without waiting for the next sync.
This method checks if the state is already cached before performing the atomic update.
- Parameters:
fingerprint- The fingerprint keystate- The indexing state to cache
-
getPublishedIndexingStateMap
Gets the full cached map (immutable copy). Used by HeapMemorySegmentMetadataCache for delta sync calculations. -
clear
public void clear()Clears the cache. Called when node stops being leader. -
getAndResetStats
- Returns:
- Summary stats for metric emission
-