public class IndexerSQLMetadataStorageCoordinator extends Object implements IndexerMetadataStorageCoordinator
| Constructor and Description |
|---|
IndexerSQLMetadataStorageCoordinator(com.fasterxml.jackson.databind.ObjectMapper jsonMapper,
org.apache.druid.metadata.MetadataStorageTablesConfig dbTables,
SQLMetadataConnector connector) |
| Modifier and Type | Method and Description |
|---|---|
SegmentIdentifier |
allocatePendingSegment(String dataSource,
String sequenceName,
String previousSegmentId,
org.joda.time.Interval interval,
String maxVersion,
boolean skipSegmentLineageCheck)
Allocate a new pending segment in the pending segments table.
|
Set<org.apache.druid.timeline.DataSegment> |
announceHistoricalSegments(Set<org.apache.druid.timeline.DataSegment> segments)
Attempts to insert a set of segments to the database.
|
SegmentPublishResult |
announceHistoricalSegments(Set<org.apache.druid.timeline.DataSegment> segments,
DataSourceMetadata startMetadata,
DataSourceMetadata endMetadata)
Attempts to insert a set of segments to the metadata storage.
|
boolean |
deleteDataSourceMetadata(String dataSource)
Removes entry for 'dataSource' from the dataSource metadata table.
|
int |
deletePendingSegments(String dataSource,
org.joda.time.Interval deleteInterval)
Delete pending segments created in the given interval for the given dataSource from the pending segments table.
|
void |
deleteSegments(Set<org.apache.druid.timeline.DataSegment> segments) |
DataSourceMetadata |
getDataSourceMetadata(String dataSource)
Read dataSource metadata.
|
List<org.apache.druid.timeline.DataSegment> |
getUnusedSegmentsForInterval(String dataSource,
org.joda.time.Interval interval)
Get all segments which include ONLY data within the given interval and are not flagged as used.
|
List<Pair<org.apache.druid.timeline.DataSegment,String>> |
getUsedSegmentAndCreatedDateForInterval(String dataSource,
org.joda.time.Interval interval)
Get all used segments and the created_date of these segments in a given datasource and interval
|
List<org.apache.druid.timeline.DataSegment> |
getUsedSegmentsForIntervals(String dataSource,
List<org.joda.time.Interval> intervals)
Get all segments which may include any data in the interval and are flagged as used.
|
boolean |
insertDataSourceMetadata(String dataSource,
DataSourceMetadata metadata)
Insert dataSourceMetadata entry for 'dataSource'.
|
boolean |
resetDataSourceMetadata(String dataSource,
DataSourceMetadata dataSourceMetadata)
Resets dataSourceMetadata entry for 'dataSource' to the one supplied.
|
void |
start() |
protected org.apache.druid.metadata.IndexerSQLMetadataStorageCoordinator.DataSourceMetadataUpdateResult |
updateDataSourceMetadataWithHandle(org.skife.jdbi.v2.Handle handle,
String dataSource,
DataSourceMetadata startMetadata,
DataSourceMetadata endMetadata)
Compare-and-swap dataSource metadata in a transaction.
|
void |
updateSegmentMetadata(Set<org.apache.druid.timeline.DataSegment> segments) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetUsedSegmentsForInterval@Inject
public IndexerSQLMetadataStorageCoordinator(com.fasterxml.jackson.databind.ObjectMapper jsonMapper,
org.apache.druid.metadata.MetadataStorageTablesConfig dbTables,
SQLMetadataConnector connector)
public void start()
public List<org.apache.druid.timeline.DataSegment> getUsedSegmentsForIntervals(String dataSource, List<org.joda.time.Interval> intervals)
IndexerMetadataStorageCoordinatorgetUsedSegmentsForIntervals in interface IndexerMetadataStorageCoordinatordataSource - The datasource to queryintervals - The intervals for which all applicable and used datasources are requested.public Set<org.apache.druid.timeline.DataSegment> announceHistoricalSegments(Set<org.apache.druid.timeline.DataSegment> segments) throws IOException
announceHistoricalSegments in interface IndexerMetadataStorageCoordinatorsegments - set of segments to addIOExceptionpublic SegmentPublishResult announceHistoricalSegments(Set<org.apache.druid.timeline.DataSegment> segments, DataSourceMetadata startMetadata, DataSourceMetadata endMetadata) throws IOException
announceHistoricalSegments in interface IndexerMetadataStorageCoordinatorsegments - set of segments to add, must all be from the same dataSourcestartMetadata - dataSource metadata pre-insert must match this startMetadata according to
DataSourceMetadata.matches(DataSourceMetadata). If null, this insert will
not involve a metadata transactionendMetadata - dataSource metadata post-insert will have this endMetadata merged in with
DataSourceMetadata.plus(DataSourceMetadata). If null, this insert will not
involve a metadata transactionIOExceptionpublic SegmentIdentifier allocatePendingSegment(String dataSource, String sequenceName, @Nullable String previousSegmentId, org.joda.time.Interval interval, String maxVersion, boolean skipSegmentLineageCheck)
IndexerMetadataStorageCoordinatorallocatePendingSegment in interface IndexerMetadataStorageCoordinatordataSource - dataSource for which to allocate a segmentsequenceName - name of the group of ingestion tasks producing a segment seriespreviousSegmentId - previous segment in the series; may be null or empty, meaning this is the first segmentinterval - interval for which to allocate a segmentmaxVersion - use this version if we have no better version to use. The returned segment identifier may
have a version lower than this one, but will not have one higher.skipSegmentLineageCheck - if true, perform lineage validation using previousSegmentId for this sequence.
Should be set to false if replica tasks would index events in same orderpublic int deletePendingSegments(String dataSource, org.joda.time.Interval deleteInterval)
IndexerMetadataStorageCoordinatorcreated_date field of the pending segments table is checked to find segments to be deleted.deletePendingSegments in interface IndexerMetadataStorageCoordinatordataSource - dataSourcedeleteInterval - interval to check the created_date of pendingSegmentspublic DataSourceMetadata getDataSourceMetadata(String dataSource)
getDataSourceMetadata in interface IndexerMetadataStorageCoordinatorprotected org.apache.druid.metadata.IndexerSQLMetadataStorageCoordinator.DataSourceMetadataUpdateResult updateDataSourceMetadataWithHandle(org.skife.jdbi.v2.Handle handle,
String dataSource,
DataSourceMetadata startMetadata,
DataSourceMetadata endMetadata)
throws IOException
handle - database handledataSource - druid dataSourcestartMetadata - dataSource metadata pre-insert must match this startMetadata according to
DataSourceMetadata.matches(DataSourceMetadata)endMetadata - dataSource metadata post-insert will have this endMetadata merged in with
DataSourceMetadata.plus(DataSourceMetadata)announceHistoricalSegments(Set, DataSourceMetadata, DataSourceMetadata)
achieve its own guarantee.RuntimeException - if state is unknown after this callIOExceptionpublic boolean deleteDataSourceMetadata(String dataSource)
IndexerMetadataStorageCoordinatordeleteDataSourceMetadata in interface IndexerMetadataStorageCoordinatordataSource - identifierpublic boolean resetDataSourceMetadata(String dataSource, DataSourceMetadata dataSourceMetadata) throws IOException
IndexerMetadataStorageCoordinatorresetDataSourceMetadata in interface IndexerMetadataStorageCoordinatordataSource - identifierdataSourceMetadata - value to setIOExceptionpublic void updateSegmentMetadata(Set<org.apache.druid.timeline.DataSegment> segments)
updateSegmentMetadata in interface IndexerMetadataStorageCoordinatorpublic void deleteSegments(Set<org.apache.druid.timeline.DataSegment> segments)
deleteSegments in interface IndexerMetadataStorageCoordinatorpublic List<org.apache.druid.timeline.DataSegment> getUnusedSegmentsForInterval(String dataSource, org.joda.time.Interval interval)
IndexerMetadataStorageCoordinatorgetUnusedSegmentsForInterval in interface IndexerMetadataStorageCoordinatordataSource - The datasource the segments belong tointerval - Filter the data segments to ones that include data in this interval exclusively. Start is inclusive, end is exclusivepublic List<Pair<org.apache.druid.timeline.DataSegment,String>> getUsedSegmentAndCreatedDateForInterval(String dataSource, org.joda.time.Interval interval)
IndexerMetadataStorageCoordinatorgetUsedSegmentAndCreatedDateForInterval in interface IndexerMetadataStorageCoordinatordataSource - The datasource to queryinterval - The interval for which all applicable and used datasources are requested. Start is inclusive, end is exclusivepublic boolean insertDataSourceMetadata(String dataSource, DataSourceMetadata metadata)
IndexerMetadataStorageCoordinatorinsertDataSourceMetadata in interface IndexerMetadataStorageCoordinatordataSource - identifiermetadata - value to setCopyright © 2011–2018 The Apache Software Foundation. All rights reserved.