Class SqlSegmentsMetadataManagerV2
- All Implemented Interfaces:
SegmentsMetadataManager
SegmentsMetadataManager, that can use the
segments cached in SegmentMetadataCache to build a DataSourcesSnapshot.
This class acts as a wrapper over SqlSegmentsMetadataManager and the
SegmentMetadataCache. If the cache is enabled, an additional poll is
not done and the segments already present in the cache are used to build the
snapshot. If the SegmentMetadataCache is disabled, the polling is
delegated to the legacy implementation in SqlSegmentsMetadataManager.
The Coordinator always uses the snapshot to perform various segment management
duties such as loading, balancing, etc.
The Overlord uses the snapshot only when compaction supervisors are enabled.
Thus, when running the Overlord as a standalone service (i.e. not combined
with the Coordinator), startPollingDatabasePeriodically() and
stopPollingDatabasePeriodically() are called based on the current
state of DruidCompactionConfig.isUseSupervisors().
-
Constructor Summary
ConstructorsConstructorDescriptionSqlSegmentsMetadataManagerV2(SegmentMetadataCache segmentMetadataCache, SegmentSchemaCache segmentSchemaCache, SQLMetadataConnector connector, com.google.common.base.Supplier<SegmentsMetadataManagerConfig> managerConfig, com.google.common.base.Supplier<MetadataStorageTablesConfig> tablesConfig, com.google.common.base.Supplier<CentralizedDatasourceSchemaConfig> centralizedDatasourceSchemaConfig, ServiceEmitter serviceEmitter, com.fasterxml.jackson.databind.ObjectMapper jsonMapper) -
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
-
SqlSegmentsMetadataManagerV2
public SqlSegmentsMetadataManagerV2(SegmentMetadataCache segmentMetadataCache, SegmentSchemaCache segmentSchemaCache, SQLMetadataConnector connector, com.google.common.base.Supplier<SegmentsMetadataManagerConfig> managerConfig, com.google.common.base.Supplier<MetadataStorageTablesConfig> tablesConfig, com.google.common.base.Supplier<CentralizedDatasourceSchemaConfig> centralizedDatasourceSchemaConfig, ServiceEmitter serviceEmitter, com.fasterxml.jackson.databind.ObjectMapper jsonMapper)
-
-
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
-
stopPollingDatabasePeriodically
public void stopPollingDatabasePeriodically()Description copied from interface:SegmentsMetadataManagerStops polling segments from the metadata store when leadership is lost.- Specified by:
stopPollingDatabasePeriodicallyin interfaceSegmentsMetadataManager
-
isPollingDatabasePeriodically
public boolean isPollingDatabasePeriodically()- Specified by:
isPollingDatabasePeriodicallyin interfaceSegmentsMetadataManager- Returns:
- true if currently the leader and polling the metadata store.
-
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.
-
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
-
stopAsyncUsedFlagLastUpdatedUpdate
public void stopAsyncUsedFlagLastUpdatedUpdate()- Specified by:
stopAsyncUsedFlagLastUpdatedUpdatein interfaceSegmentsMetadataManager
-