Package org.apache.druid.metadata
Class SqlSegmentsMetadataManager
java.lang.Object
org.apache.druid.metadata.SqlSegmentsMetadataManager
- All Implemented Interfaces:
SegmentsMetadataManager
Implementation of
SegmentsMetadataManager, that periodically polls
used segments from the metadata store to build a DataSourcesSnapshot.-
Constructor Summary
ConstructorsConstructorDescriptionSqlSegmentsMetadataManager(com.fasterxml.jackson.databind.ObjectMapper jsonMapper, com.google.common.base.Supplier<SegmentsMetadataManagerConfig> config, com.google.common.base.Supplier<MetadataStorageTablesConfig> dbTables, SQLMetadataConnector connector, SegmentSchemaCache segmentSchemaCache, CentralizedDatasourceSchemaConfig centralizedDatasourceSchemaConfig, ServiceEmitter serviceEmitter) -
Method Summary
Modifier and TypeMethodDescriptionForces the manager to poll the metadata store and update its snapshot.Returns the latest snapshot containing all used segments currently cached on the manager.booleanvoidPopulates used_status_last_updated column in the segments table iteratively until there are no segments with a NULL value for that column.voidstart()Initializes the manager when the service is being started.voidStarts polling segments from the metadata store upon becoming leader.voidstop()Cleans up resources when the service is being shut down.voidvoidStops polling segments from the metadata store when leadership is lost.
-
Constructor Details
-
SqlSegmentsMetadataManager
public SqlSegmentsMetadataManager(com.fasterxml.jackson.databind.ObjectMapper jsonMapper, com.google.common.base.Supplier<SegmentsMetadataManagerConfig> config, com.google.common.base.Supplier<MetadataStorageTablesConfig> dbTables, SQLMetadataConnector connector, SegmentSchemaCache segmentSchemaCache, CentralizedDatasourceSchemaConfig centralizedDatasourceSchemaConfig, ServiceEmitter serviceEmitter)
-
-
Method Details
-
start
public void start()Description copied from interface:SegmentsMetadataManagerInitializes the manager when the service is being started.- Specified by:
startin interfaceSegmentsMetadataManager
-
stop
public void stop()Description copied from interface:SegmentsMetadataManagerCleans up resources when the service is being shut down.- Specified by:
stopin interfaceSegmentsMetadataManager
-
startPollingDatabasePeriodically
public void startPollingDatabasePeriodically()Description copied from interface:SegmentsMetadataManagerStarts polling segments from the metadata store upon becoming leader.- Specified by:
startPollingDatabasePeriodicallyin interfaceSegmentsMetadataManager
-
stopAsyncUsedFlagLastUpdatedUpdate
public void stopAsyncUsedFlagLastUpdatedUpdate()- Specified by:
stopAsyncUsedFlagLastUpdatedUpdatein interfaceSegmentsMetadataManager
-
populateUsedFlagLastUpdatedAsync
public void populateUsedFlagLastUpdatedAsync()Description copied from interface:SegmentsMetadataManagerPopulates used_status_last_updated column in the segments table iteratively until there are no segments with a NULL value for that column.- Specified by:
populateUsedFlagLastUpdatedAsyncin interfaceSegmentsMetadataManager
-
isPollingDatabasePeriodically
public boolean isPollingDatabasePeriodically()- Specified by:
isPollingDatabasePeriodicallyin interfaceSegmentsMetadataManager- Returns:
- true if currently the leader and polling the metadata store.
-
stopPollingDatabasePeriodically
public void stopPollingDatabasePeriodically()Description copied from interface:SegmentsMetadataManagerStops polling segments from the metadata store when leadership is lost.- Specified by:
stopPollingDatabasePeriodicallyin interfaceSegmentsMetadataManager
-
getRecentDataSourcesSnapshot
Description copied from interface:SegmentsMetadataManagerReturns the latest snapshot containing all used segments currently cached on the manager. This method returns immediately if the poll period has not elapsed since the latest snapshot was built. Otherwise, it blocks until the snapshot has been refreshed.- Specified by:
getRecentDataSourcesSnapshotin interfaceSegmentsMetadataManager
-
forceUpdateDataSourcesSnapshot
Description copied from interface:SegmentsMetadataManagerForces the manager to poll the metadata store and update its snapshot. If a poll is already in progress, a new poll is not started. This method blocks until the poll finishes and the snapshot has been refreshed.- Specified by:
forceUpdateDataSourcesSnapshotin interfaceSegmentsMetadataManager- Returns:
- The updated snapshot.
-