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 |
---|---|
SegmentIdentifier |
allocatePendingSegment(String dataSource,
String sequenceName,
String previousSegmentId,
org.joda.time.Interval interval,
String maxVersion)
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 database.
|
SegmentPublishResult |
announceHistoricalSegments(Set<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.
|
void |
deleteSegments(Set<DataSegment> segments) |
DataSourceMetadata |
getDataSourceMetadata(String dataSource)
Read dataSource metadata.
|
List<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<DataSegment> |
getUsedSegmentsForInterval(String dataSource,
org.joda.time.Interval interval)
Get all segments which may include any data in the interval and are flagged as used.
|
List<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 |
resetDataSourceMetadata(String dataSource,
DataSourceMetadata dataSourceMetadata)
Resets dataSourceMetadata entry for 'dataSource' to the one supplied.
|
void |
start() |
protected io.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) |
@Inject public IndexerSQLMetadataStorageCoordinator(com.fasterxml.jackson.databind.ObjectMapper jsonMapper, MetadataStorageTablesConfig dbTables, SQLMetadataConnector connector)
public void start()
public List<DataSegment> getUsedSegmentsForInterval(String dataSource, org.joda.time.Interval interval) throws IOException
IndexerMetadataStorageCoordinator
getUsedSegmentsForInterval
in interface IndexerMetadataStorageCoordinator
dataSource
- The datasource to queryinterval
- The interval for which all applicable and used datasources are requested. Start is inclusive, end is exclusiveIOException
public List<DataSegment> getUsedSegmentsForIntervals(String dataSource, List<org.joda.time.Interval> intervals) throws IOException
IndexerMetadataStorageCoordinator
getUsedSegmentsForIntervals
in interface IndexerMetadataStorageCoordinator
dataSource
- The datasource to queryintervals
- The intervals for which all applicable and used datasources are requested.IOException
public Set<DataSegment> announceHistoricalSegments(Set<DataSegment> segments) throws IOException
announceHistoricalSegments
in interface IndexerMetadataStorageCoordinator
segments
- set of segments to addIOException
public SegmentPublishResult announceHistoricalSegments(Set<DataSegment> segments, DataSourceMetadata startMetadata, DataSourceMetadata endMetadata) throws IOException
announceHistoricalSegments
in interface IndexerMetadataStorageCoordinator
segments
- 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 transactionIOException
public SegmentIdentifier allocatePendingSegment(String dataSource, String sequenceName, String previousSegmentId, org.joda.time.Interval interval, String maxVersion) throws IOException
IndexerMetadataStorageCoordinator
allocatePendingSegment
in interface IndexerMetadataStorageCoordinator
dataSource
- 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.IOException
public DataSourceMetadata getDataSourceMetadata(String dataSource)
getDataSourceMetadata
in interface IndexerMetadataStorageCoordinator
protected io.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)
IOException
public boolean deleteDataSourceMetadata(String dataSource)
IndexerMetadataStorageCoordinator
deleteDataSourceMetadata
in interface IndexerMetadataStorageCoordinator
dataSource
- identifierpublic boolean resetDataSourceMetadata(String dataSource, DataSourceMetadata dataSourceMetadata) throws IOException
IndexerMetadataStorageCoordinator
resetDataSourceMetadata
in interface IndexerMetadataStorageCoordinator
dataSource
- identifierdataSourceMetadata
- value to setIOException
public void updateSegmentMetadata(Set<DataSegment> segments) throws IOException
updateSegmentMetadata
in interface IndexerMetadataStorageCoordinator
IOException
public void deleteSegments(Set<DataSegment> segments) throws IOException
deleteSegments
in interface IndexerMetadataStorageCoordinator
IOException
public List<DataSegment> getUnusedSegmentsForInterval(String dataSource, org.joda.time.Interval interval)
IndexerMetadataStorageCoordinator
getUnusedSegmentsForInterval
in interface IndexerMetadataStorageCoordinator
dataSource
- The datasource the segments belong tointerval
- Filter the data segments to ones that include data in this interval exclusively. Start is inclusive, end is exclusiveCopyright © 2011–2017. All rights reserved.