public class IndexerSQLMetadataStorageCoordinator extends Object implements IndexerMetadataStorageCoordinator
| Constructor and Description |
|---|
IndexerSQLMetadataStorageCoordinator(com.fasterxml.jackson.databind.ObjectMapper jsonMapper,
MetadataStorageTablesConfig dbTables,
SQLMetadataConnector connector) |
| Modifier and Type | Method and Description |
|---|---|
SegmentIdWithShardSpec |
allocatePendingSegment(String dataSource,
String sequenceName,
String previousSegmentId,
org.joda.time.Interval interval,
PartialShardSpec partialShardSpec,
String maxVersion,
boolean skipSegmentLineageCheck)
Allocate a new pending segment in the pending segments table.
|
Set<DataSegment> |
announceHistoricalSegments(Set<DataSegment> segments)
Attempts to insert a set of segments to the metadata storage.
|
SegmentPublishResult |
announceHistoricalSegments(Set<DataSegment> segments,
DataSourceMetadata startMetadata,
DataSourceMetadata endMetadata)
Attempts to insert a set of segments to the metadata storage.
|
SegmentPublishResult |
commitMetadataOnly(String dataSource,
DataSourceMetadata startMetadata,
DataSourceMetadata endMetadata)
Similar to
IndexerMetadataStorageCoordinator.announceHistoricalSegments(Set), but meant for streaming ingestion tasks for handling
the case where the task ingested no records and created no segments, but still needs to update the metadata
with the progress that the task made. |
boolean |
deleteDataSourceMetadata(String dataSource)
Removes entry for 'dataSource' from the dataSource metadata table.
|
int |
deletePendingSegments(String dataSource)
Delete all pending segments belonging to the given data source from the pending segments table.
|
int |
deletePendingSegmentsCreatedInInterval(String dataSource,
org.joda.time.Interval deleteInterval)
Delete pending segments created in the given interval belonging to the given data source from the pending segments
table.
|
void |
deleteSegments(Set<DataSegment> segments) |
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.
|
Collection<DataSegment> |
retrieveAllUsedSegments(String dataSource,
Segments visibility)
Retrieve all published used segments in the data source from the metadata store.
|
DataSourceMetadata |
retrieveDataSourceMetadata(String dataSource)
Read dataSource metadata.
|
List<DataSegment> |
retrieveUnusedSegmentsForInterval(String dataSource,
org.joda.time.Interval interval)
Retrieve all published segments which include ONLY data within the given interval and are marked as unused from the
metadata store.
|
List<Pair<DataSegment,String>> |
retrieveUsedSegmentsAndCreatedDates(String dataSource)
Retrieve all published segments which are marked as used and the created_date of these segments belonging to the
given data source from the metadata store.
|
Collection<DataSegment> |
retrieveUsedSegmentsForIntervals(String dataSource,
List<org.joda.time.Interval> intervals,
Segments visibility)
Retrieve all published segments which may include any data in the given intervals and are marked as used from the
metadata store.
|
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<DataSegment> segments) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitretrieveUsedSegmentsForInterval@Inject
public IndexerSQLMetadataStorageCoordinator(com.fasterxml.jackson.databind.ObjectMapper jsonMapper,
MetadataStorageTablesConfig dbTables,
SQLMetadataConnector connector)
public void start()
public Collection<DataSegment> retrieveUsedSegmentsForIntervals(String dataSource, List<org.joda.time.Interval> intervals, Segments visibility)
IndexerMetadataStorageCoordinatorretrieveUsedSegmentsForIntervals in interface IndexerMetadataStorageCoordinatordataSource - The data source to queryintervals - The intervals for which all applicable and used segments are requested.visibility - Whether only visible or visible as well as overshadowed segments should be returned. The
visibility is considered within the specified intervals: that is, a segment which is visible
outside of the specified intervals, but overshadowed on the specified intervals will not be
returned if Segments.ONLY_VISIBLE is passed. See more precise description in the doc for
Segments.public Collection<DataSegment> retrieveAllUsedSegments(String dataSource, Segments visibility)
IndexerMetadataStorageCoordinatorretrieveAllUsedSegments in interface IndexerMetadataStorageCoordinatordataSource - The data source to querysimilar to this method but also accepts data
interval.public List<Pair<DataSegment,String>> retrieveUsedSegmentsAndCreatedDates(String dataSource)
IndexerMetadataStorageCoordinatorSegments "visibility"
parameter. The returned collection may include overshadowed segments and their created_dates, as if Segments.INCLUDING_OVERSHADOWED was passed. It's the responsibility of the caller to filter out overshadowed ones
if needed.retrieveUsedSegmentsAndCreatedDates in interface IndexerMetadataStorageCoordinatordataSource - The data source to querypublic List<DataSegment> retrieveUnusedSegmentsForInterval(String dataSource, org.joda.time.Interval interval)
IndexerMetadataStorageCoordinatorretrieveUnusedSegmentsForInterval in interface IndexerMetadataStorageCoordinatordataSource - The data source the segments belong tointerval - Filter the data segments to ones that include data in this interval exclusively.public Set<DataSegment> announceHistoricalSegments(Set<DataSegment> segments) throws IOException
IndexerMetadataStorageCoordinatorannounceHistoricalSegments in interface IndexerMetadataStorageCoordinatorsegments - set of segments to addIOExceptionpublic SegmentPublishResult announceHistoricalSegments(Set<DataSegment> segments, @Nullable DataSourceMetadata startMetadata, @Nullable DataSourceMetadata endMetadata) throws IOException
IndexerMetadataStorageCoordinatorannounceHistoricalSegments 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 SegmentPublishResult commitMetadataOnly(String dataSource, DataSourceMetadata startMetadata, DataSourceMetadata endMetadata)
IndexerMetadataStorageCoordinatorIndexerMetadataStorageCoordinator.announceHistoricalSegments(Set), but meant for streaming ingestion tasks for handling
the case where the task ingested no records and created no segments, but still needs to update the metadata
with the progress that the task made.
The metadata should undergo the same validation checks as performed by IndexerMetadataStorageCoordinator.announceHistoricalSegments(java.util.Set<org.apache.druid.timeline.DataSegment>).commitMetadataOnly in interface IndexerMetadataStorageCoordinatordataSource - the 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).public SegmentIdWithShardSpec allocatePendingSegment(String dataSource, String sequenceName, @Nullable String previousSegmentId, org.joda.time.Interval interval, PartialShardSpec partialShardSpec, 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 segmentpartialShardSpec - partialShardSpec containing all necessary information to create a shardSpec for the
new segmentIdmaxVersion - 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 deletePendingSegmentsCreatedInInterval(String dataSource, org.joda.time.Interval deleteInterval)
IndexerMetadataStorageCoordinatorcreated_date field of the pending segments table is checked to find segments to be deleted.
Note that the semantic of the interval (for `created_date`s) is different from the semantic of the interval
parameters in some other methods in this class, such as IndexerMetadataStorageCoordinator.retrieveUsedSegmentsForInterval(java.lang.String, org.joda.time.Interval, org.apache.druid.indexing.overlord.Segments) (where the
interval is about the time column value in rows belonging to the segment).deletePendingSegmentsCreatedInInterval in interface IndexerMetadataStorageCoordinatordataSource - dataSourcedeleteInterval - interval to check the created_date of pendingSegmentspublic int deletePendingSegments(String dataSource)
IndexerMetadataStorageCoordinatordeletePendingSegments in interface IndexerMetadataStorageCoordinatorsimilar to this method but also accepts interval for
segments' `created_date`s@Nullable public DataSourceMetadata retrieveDataSourceMetadata(String dataSource)
retrieveDataSourceMetadata 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<DataSegment> segments)
updateSegmentMetadata in interface IndexerMetadataStorageCoordinatorpublic void deleteSegments(Set<DataSegment> segments)
deleteSegments in interface IndexerMetadataStorageCoordinatorpublic boolean insertDataSourceMetadata(String dataSource, DataSourceMetadata metadata)
IndexerMetadataStorageCoordinatorinsertDataSourceMetadata in interface IndexerMetadataStorageCoordinatordataSource - identifiermetadata - value to setCopyright © 2011–2020 The Apache Software Foundation. All rights reserved.