Interface SegmentMetadataCache
- All Known Implementing Classes:
HeapMemorySegmentMetadataCache,NoopSegmentMetadataCache
public interface SegmentMetadataCache
Cache for metadata of pending segments and used segments maintained by
the Overlord to improve performance of segment allocation and other task actions.
Not to be confused with AbstractSegmentMetadataCache
which is used by Brokers to cache row signature, number of rows, etc. to aid
with Druid query performance.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRepresents a thread-safe read or write action performed on the cache within required locks.static enumCache usage modes. -
Method Summary
Modifier and TypeMethodDescriptionvoidawaitNextSync(long timeoutMillis) Waits until the cache finishes the next sync with the metadata store or until the timeout elapses, whichever is sooner.voidRefreshes the cache once the service is elected leader.booleanboolean<T> TreadCacheForDataSource(String dataSource, SegmentMetadataCache.Action<T> readAction) Performs a thread-safe read action on the cache for the given datasource.voidstart()Starts the cache on service start.voidstop()Stops the cache on service stop.voidNotifies the cache that the service has lost leadership.<T> TwriteCacheForDataSource(String dataSource, SegmentMetadataCache.Action<T> writeAction) Performs a thread-safe write action on the cache for the given datasource.
-
Method Details
-
start
void start()Starts the cache on service start. -
stop
void stop()Stops the cache on service stop. -
becomeLeader
void becomeLeader()Refreshes the cache once the service is elected leader. -
stopBeingLeader
void stopBeingLeader()Notifies the cache that the service has lost leadership. -
isEnabled
boolean isEnabled()- Returns:
- true if the cache is enabled
-
isSyncedForRead
boolean isSyncedForRead()- Returns:
- true if the cache is enabled and synced with the metadata store. Reads can be done from the cache only if it is synced but writes can happen even before the sync has finished.
-
awaitNextSync
void awaitNextSync(long timeoutMillis) Waits until the cache finishes the next sync with the metadata store or until the timeout elapses, whichever is sooner. -
getDataSourcesSnapshot
DataSourcesSnapshot getDataSourcesSnapshot()- Returns:
- Latest snapshot of the datasources with all their used segments.
-
readCacheForDataSource
Performs a thread-safe read action on the cache for the given datasource. Read actions can be concurrent with other reads but are mutually exclusive from other write actions on the same datasource. -
writeCacheForDataSource
Performs a thread-safe write action on the cache for the given datasource. Write actions are mutually exclusive from other writes or reads on the same datasource.
-