public class SQLMetadataSegmentManager extends Object implements MetadataSegmentManager
| Constructor and Description |
|---|
SQLMetadataSegmentManager(com.fasterxml.jackson.databind.ObjectMapper jsonMapper,
com.google.common.base.Supplier<MetadataSegmentManagerConfig> config,
com.google.common.base.Supplier<MetadataStorageTablesConfig> dbTables,
SQLMetadataConnector connector) |
| Modifier and Type | Method and Description |
|---|---|
Collection<ImmutableDruidDataSource> |
getImmutableDataSourcesWithAllUsedSegments()
Returns a set of
ImmutableDruidDataSource objects containing information about all used segments. |
ImmutableDruidDataSource |
getImmutableDataSourceWithUsedSegments(String dataSourceName)
If there are used segments belonging to the given data source this method returns them as an
ImmutableDruidDataSource object. |
Set<SegmentId> |
getOvershadowedSegments()
Returns a set of overshadowed segment ids.
|
DataSourcesSnapshot |
getSnapshotOfDataSourcesWithAllUsedSegments()
Returns a snapshot of DruidDataSources and overshadowed segments
|
List<org.joda.time.Interval> |
getUnusedSegmentIntervals(String dataSource,
org.joda.time.DateTime maxEndTime,
int limit)
Returns top N unused segment intervals with the end time no later than the specified maxEndTime when ordered by
segment start time, end time.
|
boolean |
isPollingDatabasePeriodically() |
Iterable<DataSegment> |
iterateAllUsedSegments()
Returns an iterable to go over all segments in all data sources.
|
int |
markAsUnusedAllSegmentsInDataSource(String dataSource)
Returns the number of segment entries in the database whose state was changed as the result of this call (that is,
the segments were marked as unused).
|
int |
markAsUnusedSegmentsInInterval(String dataSourceName,
org.joda.time.Interval interval) |
int |
markAsUsedAllNonOvershadowedSegmentsInDataSource(String dataSource)
Returns the number of segment entries in the database whose state was changed as the result of this call (that is,
the segments were marked as used).
|
int |
markAsUsedNonOvershadowedSegments(String dataSource,
Set<String> segmentIds) |
int |
markAsUsedNonOvershadowedSegmentsInInterval(String dataSource,
org.joda.time.Interval interval) |
boolean |
markSegmentAsUnused(String segmentId)
This method does not update
dataSourcesSnapshot, see the comments in doPoll() about
snapshot update. |
boolean |
markSegmentAsUsed(String segmentId)
Returns true if the state of the segment entry is changed in the database as the result of this call (that is, the
segment was marked as used), false otherwise.
|
int |
markSegmentsAsUnused(String dataSourceName,
Set<String> segmentIds) |
void |
poll() |
Set<String> |
retrieveAllDataSourceNames()
Retrieves all data source names for which there are segment in the database, regardless of whether those segments
are used or not.
|
void |
start()
Don't confuse this method with
startPollingDatabasePeriodically(). |
void |
startPollingDatabasePeriodically() |
void |
stop()
Don't confuse this method with
stopPollingDatabasePeriodically(). |
void |
stopPollingDatabasePeriodically() |
@Inject
public SQLMetadataSegmentManager(com.fasterxml.jackson.databind.ObjectMapper jsonMapper,
com.google.common.base.Supplier<MetadataSegmentManagerConfig> config,
com.google.common.base.Supplier<MetadataStorageTablesConfig> dbTables,
SQLMetadataConnector connector)
public void start()
startPollingDatabasePeriodically(). This is a lifecycle starting method to
be executed just once for an instance of SqlSegmentsMetadata.public void stop()
stopPollingDatabasePeriodically(). This is a lifecycle stopping method to
be executed just once for an instance of SqlSegmentsMetadata.public void startPollingDatabasePeriodically()
startPollingDatabasePeriodically in interface MetadataSegmentManagerpublic boolean isPollingDatabasePeriodically()
isPollingDatabasePeriodically in interface MetadataSegmentManagerpublic void stopPollingDatabasePeriodically()
stopPollingDatabasePeriodically in interface MetadataSegmentManagerpublic boolean markSegmentAsUsed(String segmentId)
MetadataSegmentManagermarkSegmentAsUsed in interface MetadataSegmentManagerpublic int markAsUsedAllNonOvershadowedSegmentsInDataSource(String dataSource)
MetadataSegmentManagermarkAsUsedAllNonOvershadowedSegmentsInDataSource in interface MetadataSegmentManagerpublic int markAsUsedNonOvershadowedSegmentsInInterval(String dataSource, org.joda.time.Interval interval)
markAsUsedNonOvershadowedSegmentsInInterval in interface MetadataSegmentManagerpublic int markAsUsedNonOvershadowedSegments(String dataSource, Set<String> segmentIds) throws UnknownSegmentIdException
markAsUsedNonOvershadowedSegments in interface MetadataSegmentManagerUnknownSegmentIdExceptionpublic int markAsUnusedAllSegmentsInDataSource(String dataSource)
MetadataSegmentManagermarkAsUnusedAllSegmentsInDataSource in interface MetadataSegmentManagerpublic boolean markSegmentAsUnused(String segmentId)
dataSourcesSnapshot, see the comments in doPoll() about
snapshot update. The update of the segment's state will be reflected after the next DatabasePoll.markSegmentAsUnused in interface MetadataSegmentManagerpublic int markSegmentsAsUnused(String dataSourceName, Set<String> segmentIds)
markSegmentsAsUnused in interface MetadataSegmentManagerpublic int markAsUnusedSegmentsInInterval(String dataSourceName, org.joda.time.Interval interval)
markAsUnusedSegmentsInInterval in interface MetadataSegmentManager@Nullable public ImmutableDruidDataSource getImmutableDataSourceWithUsedSegments(String dataSourceName)
MetadataSegmentManagerImmutableDruidDataSource object. If there are no used segments belonging to the given data source this method
returns null.getImmutableDataSourceWithUsedSegments in interface MetadataSegmentManagerpublic Collection<ImmutableDruidDataSource> getImmutableDataSourcesWithAllUsedSegments()
MetadataSegmentManagerImmutableDruidDataSource objects containing information about all used segments. ImmutableDruidDataSource objects in the returned collection are unique. If there are no used segments, this method
returns an empty collection.getImmutableDataSourcesWithAllUsedSegments in interface MetadataSegmentManagerpublic Set<SegmentId> getOvershadowedSegments()
MetadataSegmentManagergetOvershadowedSegments in interface MetadataSegmentManagerpublic DataSourcesSnapshot getSnapshotOfDataSourcesWithAllUsedSegments()
MetadataSegmentManagergetSnapshotOfDataSourcesWithAllUsedSegments in interface MetadataSegmentManagerpublic Iterable<DataSegment> iterateAllUsedSegments()
MetadataSegmentManageriterateAllUsedSegments in interface MetadataSegmentManagerpublic Set<String> retrieveAllDataSourceNames()
MetadataSegmentManagerMetadataSegmentManager.getImmutableDataSourcesWithAllUsedSegments() method. This method will include a data source name even if there
are no used segments belonging to it, while MetadataSegmentManager.getImmutableDataSourcesWithAllUsedSegments() won't return
such a data source.retrieveAllDataSourceNames in interface MetadataSegmentManagerpublic void poll()
poll in interface MetadataSegmentManagerpublic List<org.joda.time.Interval> getUnusedSegmentIntervals(String dataSource, org.joda.time.DateTime maxEndTime, int limit)
MetadataSegmentManagergetUnusedSegmentIntervals in interface MetadataSegmentManagerCopyright © 2011–2020 The Apache Software Foundation. All rights reserved.