Class CoordinatorSegmentMetadataCache
java.lang.Object
org.apache.druid.segment.metadata.AbstractSegmentMetadataCache<DataSourceInformation>
org.apache.druid.segment.metadata.CoordinatorSegmentMetadataCache
public class CoordinatorSegmentMetadataCache
extends AbstractSegmentMetadataCache<DataSourceInformation>
Coordinator-side cache of segment metadata that combines segments to build
datasources. The cache provides metadata about a datasource, see The refresh is executed only on the leader Coordinator node.
Realtime segment schema refresh. Schema update for realtime segment is pushed periodically.
The schema is merged with any existing schema for the segment and the cache is updated.
Corresponding datasource is marked for refresh.
The refresh mechanism is significantly different from the other implementation,
DataSourceInformation.
Major differences from the other implementation BrokerSegmentMetadataCache are,
- Metadata query is executed only for those non-realtime segments for which the schema is not cached.
- Datasources marked for refresh are then rebuilt.
It is important to note that the datasource schema returned in getDatasource(java.lang.String) & getDataSourceInformationMap()
also includes columns from cold segments.
Cold segments are processed in a separate thread and datasource schema from cold segments is separately stored.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.druid.segment.metadata.AbstractSegmentMetadataCache
AbstractSegmentMetadataCache.ColumnTypeMergePolicy, AbstractSegmentMetadataCache.FirstTypeMergePolicy, AbstractSegmentMetadataCache.LeastRestrictiveTypeMergePolicy -
Field Summary
Fields inherited from class org.apache.druid.segment.metadata.AbstractSegmentMetadataCache
cacheExec, callbackExec, dataSourcesNeedingRebuild, isServerViewInitialized, lock, mutableSegments, ROW_SIGNATURE_INTERNER, SEGMENT_ORDER, segmentMetadataInfo, segmentsNeedingRefresh, tables -
Constructor Summary
ConstructorsConstructorDescriptionCoordinatorSegmentMetadataCache(QueryLifecycleFactory queryLifecycleFactory, CoordinatorServerView serverView, SegmentMetadataCacheConfig config, Escalator escalator, InternalQueryConfig internalQueryConfig, ServiceEmitter emitter, SegmentSchemaCache segmentSchemaCache, SegmentSchemaBackFillQueue segmentSchemaBackfillQueue, SegmentsMetadataManager segmentsMetadataManager, com.google.common.base.Supplier<SegmentsMetadataManagerConfig> segmentsMetadataManagerConfigSupplier) -
Method Summary
Modifier and TypeMethodDescriptionbuildDataSourceRowSignature(String dataSource) protected booleangetAvailableSegmentMetadata(String datasource, SegmentId segmentId) Get metadata for the specified segment, which includes information like RowSignature, realtime & numRows.getDatasource(String name) Fetch schema for the given datasource.Get metadata for all the cached segments, which includes information like RowSignature, realtime & numRows etc.voidvoidvoidExecutes SegmentMetadataQuery to fetch schema information for each segment in the refresh list.protected voidRecomputes the cold schema of all datasources and updates incoldSchemaTable.voidThis method ensures that the refresh goes through only when schemaCache is initialized.protected voidremoveSegmentAction(SegmentId segmentId) This method should be overridden by child classes to execute any action on segment removal.voidstart()Lifecycle start method.voidstop()Lifecycle stop method.protected voidunmarkSegmentAsMutable(SegmentId segmentId) protected booleanupdateSegmentMetadata(SegmentId segmentId, SegmentAnalysis analysis) Updates metadata of a segment using the results of a metadata query.voidupdateSegmentReplicationStatus(SegmentReplicationStatus segmentReplicationStatus) Methods inherited from class org.apache.druid.segment.metadata.AbstractSegmentMetadataCache
addSegment, awaitInitialization, cacheExecLoop, doInLock, emitMetric, emitMetric, getDatasourceNames, getDataSourcesNeedingRebuild, getMutableSegments, getSegmentMetadataSnapshot, getSegmentsNeedingRefresh, getTotalSegments, markDataSourceAsNeedRebuild, markSegmentAsNeedRefresh, refreshSegments, removeSegment, removeServerSegment, runSegmentMetadataQuery, setAvailableSegmentMetadata, shouldRefresh
-
Constructor Details
-
CoordinatorSegmentMetadataCache
@Inject public CoordinatorSegmentMetadataCache(QueryLifecycleFactory queryLifecycleFactory, CoordinatorServerView serverView, SegmentMetadataCacheConfig config, Escalator escalator, InternalQueryConfig internalQueryConfig, ServiceEmitter emitter, SegmentSchemaCache segmentSchemaCache, SegmentSchemaBackFillQueue segmentSchemaBackfillQueue, SegmentsMetadataManager segmentsMetadataManager, com.google.common.base.Supplier<SegmentsMetadataManagerConfig> segmentsMetadataManagerConfigSupplier)
-
-
Method Details
-
start
public void start()Description copied from class:AbstractSegmentMetadataCacheLifecycle start method.- Specified by:
startin classAbstractSegmentMetadataCache<DataSourceInformation>
-
stop
public void stop()Description copied from class:AbstractSegmentMetadataCacheLifecycle stop method.- Specified by:
stopin classAbstractSegmentMetadataCache<DataSourceInformation>
-
onLeaderStart
public void onLeaderStart() -
onLeaderStop
public void onLeaderStop() -
refreshWaitCondition
This method ensures that the refresh goes through only when schemaCache is initialized.- Overrides:
refreshWaitConditionin classAbstractSegmentMetadataCache<DataSourceInformation>- Throws:
InterruptedException
-
updateSegmentReplicationStatus
-
unmarkSegmentAsMutable
- Overrides:
unmarkSegmentAsMutablein classAbstractSegmentMetadataCache<DataSourceInformation>
-
removeSegmentAction
Description copied from class:AbstractSegmentMetadataCacheThis method should be overridden by child classes to execute any action on segment removal.- Specified by:
removeSegmentActionin classAbstractSegmentMetadataCache<DataSourceInformation>
-
fetchAggregatorsInSegmentMetadataQuery
protected boolean fetchAggregatorsInSegmentMetadataQuery()- Overrides:
fetchAggregatorsInSegmentMetadataQueryin classAbstractSegmentMetadataCache<DataSourceInformation>
-
updateSegmentMetadata
Description copied from class:AbstractSegmentMetadataCacheUpdates metadata of a segment using the results of a metadata query.- Overrides:
updateSegmentMetadatain classAbstractSegmentMetadataCache<DataSourceInformation>- Returns:
- true if the segment metadata was updated successfully.
-
iterateSegmentMetadata
Description copied from class:AbstractSegmentMetadataCacheGet metadata for all the cached segments, which includes information like RowSignature, realtime & numRows etc. This is a lower-overhead method thanAbstractSegmentMetadataCache.getSegmentMetadataSnapshot().- Overrides:
iterateSegmentMetadatain classAbstractSegmentMetadataCache<DataSourceInformation>- Returns:
- iterator of metadata.
-
getAvailableSegmentMetadata
@Nullable public AvailableSegmentMetadata getAvailableSegmentMetadata(String datasource, SegmentId segmentId) Description copied from class:AbstractSegmentMetadataCacheGet metadata for the specified segment, which includes information like RowSignature, realtime & numRows.- Overrides:
getAvailableSegmentMetadatain classAbstractSegmentMetadataCache<DataSourceInformation>- Parameters:
datasource- segment datasourcesegmentId- segment Id- Returns:
- Metadata information for the given segment
-
getDatasource
Description copied from class:AbstractSegmentMetadataCacheFetch schema for the given datasource.- Overrides:
getDatasourcein classAbstractSegmentMetadataCache<DataSourceInformation>- Parameters:
name- datasource- Returns:
- schema information for the given datasource
-
getDataSourceInformationMap
- Overrides:
getDataSourceInformationMapin classAbstractSegmentMetadataCache<DataSourceInformation>- Returns:
- Map of datasource and corresponding schema information.
-
refresh
public void refresh(Set<SegmentId> segmentsToRefresh, Set<String> dataSourcesToRebuild) throws IOException Executes SegmentMetadataQuery to fetch schema information for each segment in the refresh list. The schema information for individual segments is combined to construct a table schema, which is then cached.- Specified by:
refreshin classAbstractSegmentMetadataCache<DataSourceInformation>- Parameters:
segmentsToRefresh- segments for which the schema might have changeddataSourcesToRebuild- datasources for which the schema might have changed- Throws:
IOException- when querying segment from data nodes and tasks
-
refreshColdSegmentSchemas
protected void refreshColdSegmentSchemas()Recomputes the cold schema of all datasources and updates incoldSchemaTable. The cold schema row signature is obtained by merging the column types from the schemas of all cold segments (used segments with zero replication). -
buildDataSourceRowSignature
- Overrides:
buildDataSourceRowSignaturein classAbstractSegmentMetadataCache<DataSourceInformation>
-