Interface IndexerMetadataStorageCoordinator
- All Known Implementing Classes:
IndexerSQLMetadataStorageCoordinator
-
Method Summary
Modifier and TypeMethodDescriptionallocatePendingSegment(String dataSource, org.joda.time.Interval interval, boolean skipSegmentLineageCheck, SegmentCreateRequest createRequest) Allocate a new pending segment in the pending segments table.allocatePendingSegments(String dataSource, org.joda.time.Interval interval, boolean skipSegmentLineageCheck, List<SegmentCreateRequest> requests, boolean reduceMetadataIO) Allocates pending segments for the given requests in the pending segments table.commitAppendSegments(Set<DataSegment> appendSegments, Map<DataSegment, ReplaceTaskLock> appendSegmentToReplaceLock, String taskAllocatorId, SegmentSchemaMapping segmentSchemaMapping) Commits segments and corresponding schema created by an APPEND task.commitAppendSegmentsAndMetadata(Set<DataSegment> appendSegments, Map<DataSegment, ReplaceTaskLock> appendSegmentToReplaceLock, String supervisorId, DataSourceMetadata startMetadata, DataSourceMetadata endMetadata, String taskAllocatorId, SegmentSchemaMapping segmentSchemaMapping) Commits segments created by an APPEND task.commitMetadataOnly(String supervisorId, String dataSource, DataSourceMetadata startMetadata, DataSourceMetadata endMetadata) Similar tocommitSegments(java.util.Set<org.apache.druid.timeline.DataSegment>, org.apache.druid.segment.SegmentSchemaMapping), 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.commitReplaceSegments(Set<DataSegment> replaceSegments, Set<ReplaceTaskLock> locksHeldByReplaceTask, SegmentSchemaMapping segmentSchemaMapping) Commits segments and corresponding schema created by a REPLACE task.commitSegments(Set<DataSegment> segments, SegmentSchemaMapping segmentSchemaMapping) Attempts to insert a set of segments and corresponding schema to the metadata storage.commitSegmentsAndMetadata(Set<DataSegment> segments, String supervisorId, DataSourceMetadata startMetadata, DataSourceMetadata endMetadata, SegmentSchemaMapping segmentSchemaMapping) Attempts to insert a set of segments and corresponding schema to the metadata storage.booleandeleteDataSourceMetadata(String supervisorId) Removes entry forsupervisorIdfrom the dataSource metadata table.intdeletePendingSegments(String dataSource) Delete all pending segments belonging to the given data source from the pending segments table.intdeletePendingSegmentsCreatedInInterval(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.intdeletePendingSegmentsForTaskAllocatorId(String datasource, String taskAllocatorId) Delete pending segment for a give task group after all the tasks belonging to it have completed.intdeleteSegments(Set<DataSegment> segments) Deletes unused segments from the metadata store.intdeleteUpgradeSegmentsForTask(String taskId) Delete entries from the upgrade segments table after the corresponding replace task has endedgetPendingSegments(String datasource, org.joda.time.Interval interval) Fetches all the pending segments of the datasource that overlap with a given interval.getSegmentTimelineForAllocation(String dataSource, org.joda.time.Interval interval, boolean skipSegmentPayloadFetchForAllocation) Return a segment timeline of all used segments including overshadowed ones for a given datasource and interval if skipSegmentPayloadFetchForAllocation is set to true, do not fetch all the segment payloads for allocation Instead fetch all the ids and numCorePartitions using exactly one segment per version per interval return a dummy DataSegment for each id that holds only the SegmentId and a NumberedShardSpec with numCorePartitionsList<org.joda.time.Interval>getUnusedSegmentIntervals(String dataSource, org.joda.time.DateTime minStartTime, org.joda.time.DateTime maxEndTime, int limit, org.joda.time.DateTime maxUsedStatusLastUpdatedTime) Returns a list of up tolimitunused segment intervals for the specified datasource.booleaninsertDataSourceMetadata(String supervisorId, DataSourceMetadata dataSourceMetadata) InsertDataSourceMetadataentry forsupervisorId.iterateAllUnusedSegmentsForDatasource(String datasource, org.joda.time.Interval interval, Integer limit, String lastSegmentId, SortOrder sortOrder) Returns a list of unused segments and their associated metadata for a given datasource over an optional interval.intmarkAllNonOvershadowedSegmentsAsUsed(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).intmarkAllSegmentsAsUnused(String dataSource) Marks all the segments in given datasource as unused.intmarkNonOvershadowedSegmentsAsUsed(String dataSource, Set<SegmentId> segmentIds) Marks the given segment IDs as "used" only if there are not already overshadowed by other used segments.intmarkNonOvershadowedSegmentsAsUsed(String dataSource, org.joda.time.Interval interval, List<String> versions) Marks non-overshadowed unused segments for the given interval and optional list of versions as used.booleanmarkSegmentAsUnused(SegmentId segmentId) Marks the segment as unused.booleanmarkSegmentAsUsed(SegmentId 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.intmarkSegmentsAsUnused(String dataSource, Set<SegmentId> segmentIds) Marks the given segments as unused.intmarkSegmentsWithinIntervalAsUnused(String dataSource, org.joda.time.Interval interval, List<String> versions) Marks segments that are fully contained in the given interval as unused.intremoveDataSourceMetadataOlderThan(long timestamp, @NotNull Set<String> excludeSupervisorIds) Remove supervisors' datasource metadata created before the given timestamp and not in given excludeSupervisorIds set.booleanresetDataSourceMetadata(String supervisorId, DataSourceMetadata dataSourceMetadata) ResetsDataSourceMetadataentry forsupervisorIdto the one supplied.retrieveAllUsedSegments(String dataSource, Segments visibility) Retrieves all published used segments for the given data source.retrieveDataSourceMetadata(String supervisorId) RetrievesDataSourceMetadataentry forsupervisorIdfrom the metadata store.retrieveSegmentForId(SegmentId segmentId) Retrieve the segment for a given id from the metadata store.retrieveSegmentsById(String dataSource, Set<String> segmentIds) Retrieves segments for the given IDs, regardless of their visibility (visible, overshadowed or unused).List<org.joda.time.Interval>retrieveUnusedSegmentIntervals(String dataSource, int limit) Retrieves intervals of the specified datasource that contain any unused segments.default List<DataSegment>retrieveUnusedSegmentsForInterval(String dataSource, org.joda.time.Interval interval, Integer limit, org.joda.time.DateTime maxUsedStatusLastUpdatedTime) Retrieve all published segments which include ONLY data within the given interval and are marked as unused from the metadata store.retrieveUnusedSegmentsForInterval(String dataSource, org.joda.time.Interval interval, List<String> versions, Integer limit, org.joda.time.DateTime maxUsedStatusLastUpdatedTime) Retrieve all published segments which include ONLY data within the given interval and are marked as unused from the metadata store.retrieveUnusedSegmentsWithExactInterval(String dataSource, org.joda.time.Interval interval, org.joda.time.DateTime maxUpdatedTime, int limit) Retrieves unused segments from the metadata store that match the given interval exactly.retrieveUpgradedFromSegmentIds(String dataSource, Set<String> segmentIds) Map from a segment ID to the segment ID from which it was upgraded There should be no entry in the map for an original non-upgraded segmentretrieveUpgradedToSegmentIds(String dataSource, Set<String> segmentIds) Map from a segment ID to a set containing 1) all segment IDs that were upgraded from it AND are still present in the metadata store 2) the segment ID itself if and only if it is still present in the metadata storeretrieveUsedSegmentForId(SegmentId segmentId) retrieveUsedSegmentsAndCreatedDates(String dataSource, List<org.joda.time.Interval> intervals) Retrieve all published segments which are marked as used and the created_date of these segments belonging to the given data source and list of intervals from the metadata store.default Set<DataSegment>retrieveUsedSegmentsForInterval(String dataSource, org.joda.time.Interval interval, Segments visibility) Retrieves all published segments that have partial or complete overlap with the given interval and are marked as used.retrieveUsedSegmentsForIntervals(String dataSource, List<org.joda.time.Interval> intervals, Segments visibility) Retrieves all published segments that have partial or complete overlap with the given intervals and are marked as used.voidupdateSegmentMetadata(Set<DataSegment> segments) static voidvalidateDataSourceMetadata(String supervisorId, DataSourceMetadata startMetadata, DataSourceMetadata endMetadata) Validates the given supervisorId and given metadata to ensure that start/end metadata non-null implies supervisor ID is non-null.
-
Method Details
-
retrieveAllDatasourceNames
- Returns:
- Set of all datasource names for which there are used or unused segments present in the metadata store.
-
retrieveUsedSegmentsForInterval
default Set<DataSegment> retrieveUsedSegmentsForInterval(String dataSource, org.joda.time.Interval interval, Segments visibility) Retrieves all published segments that have partial or complete overlap with the given interval and are marked as used. -
retrieveAllUsedSegments
Retrieves all published used segments for the given data source. -
retrieveUsedSegmentsAndCreatedDates
Collection<Pair<DataSegment,String>> retrieveUsedSegmentsAndCreatedDates(String dataSource, List<org.joda.time.Interval> intervals) Retrieve all published segments which are marked as used and the created_date of these segments belonging to the given data source and list of intervals from the metadata store.Unlike other similar methods in this interface, this method doesn't accept a
Segments"visibility" parameter. The returned collection may include overshadowed segments and their created_dates, as ifSegments.INCLUDING_OVERSHADOWEDwas passed. It's the responsibility of the caller to filter out overshadowed ones if needed.- Parameters:
dataSource- The data source to queryintervals- The list of interval to query- Returns:
- The DataSegments and the related created_date of segments
-
retrieveUsedSegmentsForIntervals
Set<DataSegment> retrieveUsedSegmentsForIntervals(String dataSource, List<org.joda.time.Interval> intervals, Segments visibility) Retrieves all published segments that have partial or complete overlap with the given intervals and are marked as used. -
retrieveUnusedSegmentsForInterval
default List<DataSegment> retrieveUnusedSegmentsForInterval(String dataSource, org.joda.time.Interval interval, @Nullable Integer limit, @Nullable org.joda.time.DateTime maxUsedStatusLastUpdatedTime) Retrieve all published segments which include ONLY data within the given interval and are marked as unused from the metadata store.- Parameters:
dataSource- The data source the segments belong tointerval- Filter the data segments to ones that include data in this interval exclusively.limit- The maximum number of unused segments to retreive. If null, no limit is applied.maxUsedStatusLastUpdatedTime- The maximumused_status_last_updatedtime. Any unused segment inintervalwithused_status_last_updatedno later than this time will be included in the kill task. Segments withoutused_status_last_updatedtime (due to an upgrade from legacy Druid) will havemaxUsedStatusLastUpdatedTimeignored- Returns:
- DataSegments which include ONLY data within the requested interval and are marked as unused. Segments NOT returned here may include data in the interval
-
retrieveUnusedSegmentsForInterval
List<DataSegment> retrieveUnusedSegmentsForInterval(String dataSource, org.joda.time.Interval interval, @Nullable List<String> versions, @Nullable Integer limit, @Nullable org.joda.time.DateTime maxUsedStatusLastUpdatedTime) Retrieve all published segments which include ONLY data within the given interval and are marked as unused from the metadata store.- Parameters:
dataSource- The data source the segments belong tointerval- Filter the data segments to ones that include data in this interval exclusively.versions- An optional list of segment versions to retrieve in the giveninterval. If unspecified, all versions of unused segments in theintervalmust be retrieved. If an empty list is passed, no segments are retrieved.limit- The maximum number of unused segments to retreive. If null, no limit is applied.maxUsedStatusLastUpdatedTime- The maximumused_status_last_updatedtime. Any unused segment inintervalwithused_status_last_updatedno later than this time will be included in the kill task. Segments withoutused_status_last_updatedtime (due to an upgrade from legacy Druid) will havemaxUsedStatusLastUpdatedTimeignored- Returns:
- DataSegments which include ONLY data within the requested interval and are marked as unused. Segments NOT returned here may include data in the interval
-
retrieveUnusedSegmentsWithExactInterval
List<DataSegment> retrieveUnusedSegmentsWithExactInterval(String dataSource, org.joda.time.Interval interval, org.joda.time.DateTime maxUpdatedTime, int limit) Retrieves unused segments from the metadata store that match the given interval exactly. There is no guarantee on the order of segments in the list or on whether the limited list contains the highest or lowest segment IDs in the interval.- Parameters:
interval- Returned segments must exactly match this interval.maxUpdatedTime- Returned segments must have aused_status_last_updatedwhich is either null or earlier than this value.limit- Maximum number of segments to return.- Returns:
- Unsorted list of unused segments that match the given parameters.
-
retrieveSegmentsById
Retrieves segments for the given IDs, regardless of their visibility (visible, overshadowed or unused). -
markSegmentAsUnused
Marks the segment as unused.- Returns:
- true if the segment was updated, false otherwise
-
markSegmentsAsUnused
Marks the given segments as unused.- Returns:
- Number of segments updated
-
markAllSegmentsAsUnused
Marks all the segments in given datasource as unused.- Returns:
- Number of updated segments
-
markSegmentsWithinIntervalAsUnused
int markSegmentsWithinIntervalAsUnused(String dataSource, org.joda.time.Interval interval, @Nullable List<String> versions) Marks segments that are fully contained in the given interval as unused.- Parameters:
versions- Optional list of segment versions eligible for update. If this list is passed as null, all segment versions are eligible for updated. If passed as empty, no segment is updated.- Returns:
- Number of segments updated
-
commitSegments
Set<DataSegment> commitSegments(Set<DataSegment> segments, @Nullable SegmentSchemaMapping segmentSchemaMapping) Attempts to insert a set of segments and corresponding schema to the metadata storage. Returns the set of segments actually added (segments with identifiers already in the metadata storage will not be added).- Parameters:
segments- set of segments to addsegmentSchemaMapping- segment schema information to add- Returns:
- set of segments actually added
-
allocatePendingSegments
Map<SegmentCreateRequest,SegmentIdWithShardSpec> allocatePendingSegments(String dataSource, org.joda.time.Interval interval, boolean skipSegmentLineageCheck, List<SegmentCreateRequest> requests, boolean reduceMetadataIO) Allocates pending segments for the given requests in the pending segments table. The segment id allocated for a request will not be given out again unless a request is made with the sameSegmentCreateRequest.- Parameters:
dataSource- dataSource for which to allocate a segmentinterval- interval for which to allocate a segmentskipSegmentLineageCheck- if true, perform lineage validation using previousSegmentId for this sequence. Should be set to false if replica tasks would index events in same orderrequests- Requests for which to allocate segments. All the requests must share the same partition space.reduceMetadataIO- If true, try to use the segment ids instead of fetching every segment payload from the metadata store- Returns:
- Map from request to allocated segment id. The map does not contain entries for failed requests.
-
getSegmentTimelineForAllocation
SegmentTimeline getSegmentTimelineForAllocation(String dataSource, org.joda.time.Interval interval, boolean skipSegmentPayloadFetchForAllocation) Return a segment timeline of all used segments including overshadowed ones for a given datasource and interval if skipSegmentPayloadFetchForAllocation is set to true, do not fetch all the segment payloads for allocation Instead fetch all the ids and numCorePartitions using exactly one segment per version per interval return a dummy DataSegment for each id that holds only the SegmentId and a NumberedShardSpec with numCorePartitions -
allocatePendingSegment
@Nullable SegmentIdWithShardSpec allocatePendingSegment(String dataSource, org.joda.time.Interval interval, boolean skipSegmentLineageCheck, SegmentCreateRequest createRequest) Allocate a new pending segment in the pending segments table. This segment identifier will never be given out again, unless another call is made with the same dataSource, sequenceName, and previousSegmentId. The sequenceName and previousSegmentId parameters are meant to make it easy for two independent ingestion tasks to produce the same series of segments. Note that a segment sequence may include segments with a variety of different intervals and versions.- Parameters:
dataSource- dataSource for which to allocate a segmentinterval- interval for which to allocate a segmentskipSegmentLineageCheck- if true, perform lineage validation using previousSegmentId for this sequence. Should be set to false if replica tasks would index events in same order- Returns:
- the pending segment identifier, or null if it was impossible to allocate a new segment
-
deletePendingSegmentsCreatedInInterval
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. Thecreated_datefield 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
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).- Parameters:
dataSource- dataSourcedeleteInterval- interval to check thecreated_dateof pendingSegments- Returns:
- number of deleted pending segments
-
deletePendingSegments
Delete all pending segments belonging to the given data source from the pending segments table.- Returns:
- number of deleted pending segments
- See Also:
-
commitSegmentsAndMetadata
SegmentPublishResult commitSegmentsAndMetadata(Set<DataSegment> segments, @Nullable String supervisorId, @Nullable DataSourceMetadata startMetadata, @Nullable DataSourceMetadata endMetadata, @Nullable SegmentSchemaMapping segmentSchemaMapping) Attempts to insert a set of segments and corresponding schema to the metadata storage. Returns the set of segments actually added (segments with identifiers already in the metadata storage will not be added). If startMetadata and endMetadata are set, this insertion will be atomic with a compare-and-swap on dataSource commit metadata.If segmentsToDrop is not null and not empty, this insertion will be atomic with a insert-and-drop on inserting and dropping .
- Parameters:
supervisorId- supervisorID which is committing the segments. Cannot be null ifstartMetadataandendMetadataare both non-null.segments- set of segments to add, must all be from the same dataSourcestartMetadata- dataSource metadata pre-insert must match this startMetadata according toDataSourceMetadata.matches(DataSourceMetadata). If null, this insert will not involve a metadata transactionendMetadata- dataSource metadata post-insert will have this endMetadata merged in withDataSourceMetadata.plus(DataSourceMetadata). If null, this insert will not involve a metadata transactionsegmentSchemaMapping- segment schema information to persist.- Returns:
- segment publish result indicating transaction success or failure, and set of segments actually published. This method must only return a failure code if it is sure that the transaction did not happen. If it is not sure, it must throw an exception instead.
- Throws:
IllegalArgumentException- if startMetadata and endMetadata are not either both null or both non-nullRuntimeException- if the state of metadata storage after this call is unknown
-
commitAppendSegments
SegmentPublishResult commitAppendSegments(Set<DataSegment> appendSegments, Map<DataSegment, ReplaceTaskLock> appendSegmentToReplaceLock, String taskAllocatorId, @Nullable SegmentSchemaMapping segmentSchemaMapping) Commits segments and corresponding schema created by an APPEND task. This method also handles segment upgrade scenarios that may result from concurrent append and replace.- If a REPLACE task committed a segment that overlaps with any of the appendSegments while this APPEND task was in progress, the appendSegments are upgraded to the version of the replace segment.
- If an appendSegment is covered by a currently active REPLACE lock, then an entry is created for it in the upgrade_segments table, so that when the REPLACE task finishes, it can upgrade the appendSegment as required.
- Parameters:
appendSegments- All segments created by an APPEND task that must be committed in a single transaction.appendSegmentToReplaceLock- Map from append segment to the currently active REPLACE lock (if any) covering ittaskAllocatorId- allocator id of the task committing the segments to be appendedsegmentSchemaMapping- schema of append segments
-
commitAppendSegmentsAndMetadata
SegmentPublishResult commitAppendSegmentsAndMetadata(Set<DataSegment> appendSegments, Map<DataSegment, ReplaceTaskLock> appendSegmentToReplaceLock, @Nullable String supervisorId, DataSourceMetadata startMetadata, DataSourceMetadata endMetadata, String taskAllocatorId, @Nullable SegmentSchemaMapping segmentSchemaMapping) Commits segments created by an APPEND task. This method also handles segment upgrade scenarios that may result from concurrent append and replace. Also commits start and endDataSourceMetadata.- See Also:
-
commitAppendSegments(java.util.Set<org.apache.druid.timeline.DataSegment>, java.util.Map<org.apache.druid.timeline.DataSegment, org.apache.druid.metadata.ReplaceTaskLock>, java.lang.String, org.apache.druid.segment.SegmentSchemaMapping)commitSegmentsAndMetadata(java.util.Set<org.apache.druid.timeline.DataSegment>, java.lang.String, org.apache.druid.indexing.overlord.DataSourceMetadata, org.apache.druid.indexing.overlord.DataSourceMetadata, org.apache.druid.segment.SegmentSchemaMapping)
-
commitReplaceSegments
SegmentPublishResult commitReplaceSegments(Set<DataSegment> replaceSegments, Set<ReplaceTaskLock> locksHeldByReplaceTask, @Nullable SegmentSchemaMapping segmentSchemaMapping) Commits segments and corresponding schema created by a REPLACE task. This method also handles the segment upgrade scenarios that may result from concurrent append and replace.- If an APPEND task committed a segment to an interval locked by this task,
the append segment is upgraded to the version of the corresponding lock.
This is done with the help of entries created in the upgrade_segments table
in
commitAppendSegments(java.util.Set<org.apache.druid.timeline.DataSegment>, java.util.Map<org.apache.druid.timeline.DataSegment, org.apache.druid.metadata.ReplaceTaskLock>, java.lang.String, org.apache.druid.segment.SegmentSchemaMapping)
- Parameters:
replaceSegments- All segments created by a REPLACE task that must be committed in a single transaction.locksHeldByReplaceTask- All active non-revoked REPLACE locks held by the tasksegmentSchemaMapping- Segment schema to add.
- If an APPEND task committed a segment to an interval locked by this task,
the append segment is upgraded to the version of the corresponding lock.
This is done with the help of entries created in the upgrade_segments table
in
-
retrieveDataSourceMetadata
RetrievesDataSourceMetadataentry forsupervisorIdfrom the metadata store. Returns null if there is no metadata. -
deleteDataSourceMetadata
Removes entry forsupervisorIdfrom the dataSource metadata table.- Parameters:
supervisorId- identifier- Returns:
- true if the entry was deleted, false otherwise
-
resetDataSourceMetadata
boolean resetDataSourceMetadata(String supervisorId, DataSourceMetadata dataSourceMetadata) throws IOException ResetsDataSourceMetadataentry forsupervisorIdto the one supplied.- Parameters:
supervisorId- identifierdataSourceMetadata- value to set- Returns:
- true if the entry was reset, false otherwise
- Throws:
IOException
-
insertDataSourceMetadata
InsertDataSourceMetadataentry forsupervisorId.- Parameters:
supervisorId- identifierdataSourceMetadata- value to set- Returns:
- true if the entry was inserted, false otherwise
-
removeDataSourceMetadataOlderThan
int removeDataSourceMetadataOlderThan(long timestamp, @NotNull @NotNull Set<String> excludeSupervisorIds) Remove supervisors' datasource metadata created before the given timestamp and not in given excludeSupervisorIds set.- Parameters:
timestamp- timestamp in millisecondsexcludeSupervisorIds- set of supervisor ids to exclude from removal- Returns:
- number of datasource metadata removed
-
commitMetadataOnly
SegmentPublishResult commitMetadataOnly(String supervisorId, String dataSource, DataSourceMetadata startMetadata, DataSourceMetadata endMetadata) Similar tocommitSegments(java.util.Set<org.apache.druid.timeline.DataSegment>, org.apache.druid.segment.SegmentSchemaMapping), 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
commitSegments(java.util.Set<org.apache.druid.timeline.DataSegment>, org.apache.druid.segment.SegmentSchemaMapping).- Parameters:
supervisorId- the supervisorIddataSource- the dataSourcestartMetadata- dataSource metadata pre-insert must match this startMetadata according toDataSourceMetadata.matches(DataSourceMetadata).endMetadata- dataSource metadata post-insert will have this endMetadata merged in withDataSourceMetadata.plus(DataSourceMetadata).- Returns:
- segment publish result indicating transaction success or failure. This method must only return a failure code if it is sure that the transaction did not happen. If it is not sure, it must throw an exception instead.
- Throws:
IllegalArgumentException- if either startMetadata and endMetadata are nullRuntimeException- if the state of metadata storage after this call is unknown
-
updateSegmentMetadata
-
deleteSegments
Deletes unused segments from the metadata store.- Returns:
- Number of segments actually deleted.
-
retrieveSegmentForId
Retrieve the segment for a given id from the metadata store. Return null if no such segment exists
The retrieval also considers the set of unused segments in the metadata store. Unused segments could be deleted by a kill task at any time and might lead to unexpected behaviour. This option exists mainly to provide a consistent view of the metadata, for example, in calls from MSQ controller and worker and would generally not be required. -
retrieveUsedSegmentForId
-
deleteUpgradeSegmentsForTask
Delete entries from the upgrade segments table after the corresponding replace task has ended- Parameters:
taskId- - id of the task with replace locks- Returns:
- number of deleted entries from the metadata store
-
deletePendingSegmentsForTaskAllocatorId
Delete pending segment for a give task group after all the tasks belonging to it have completed.- Parameters:
datasource- datasource of the tasktaskAllocatorId- task id / task group / replica group for an appending task- Returns:
- number of pending segments deleted from the metadata store
-
getPendingSegments
Fetches all the pending segments of the datasource that overlap with a given interval.- Parameters:
datasource- datasource to be queriedinterval- interval with which segments overlap- Returns:
- List of pending segment records
-
retrieveUpgradedFromSegmentIds
Map from a segment ID to the segment ID from which it was upgraded There should be no entry in the map for an original non-upgraded segment- Parameters:
dataSource- data sourcesegmentIds- ids of segments
-
retrieveUpgradedToSegmentIds
Map from a segment ID to a set containing 1) all segment IDs that were upgraded from it AND are still present in the metadata store 2) the segment ID itself if and only if it is still present in the metadata store- Parameters:
dataSource- data sourcesegmentIds- ids of the first segments which had the corresponding load spec
-
iterateAllUnusedSegmentsForDatasource
List<DataSegmentPlus> iterateAllUnusedSegmentsForDatasource(String datasource, @Nullable org.joda.time.Interval interval, @Nullable Integer limit, @Nullable String lastSegmentId, @Nullable SortOrder sortOrder) Returns a list of unused segments and their associated metadata for a given datasource over an optional interval. The order in which segments are iterated is from earliest start-time, with ties being broken with earliest end-time first. Note: the iteration may not be as trivially cheap as for example, iteration over an ArrayList. Try (to some reasonable extent) to organize the code so that it iterates the returned iterable only once rather than several times.- Parameters:
datasource- the name of the datasource.interval- an optional interval to search over. If none is specified,Intervals.ETERNITYlimit- an optional maximum number of results to return. If none is specified, the results are not limited.lastSegmentId- an optional last segment id from which to search for results. All segments returned are > this segment lexigraphically if sortOrder is null orSortOrder.ASC, or < this segment lexigraphically if sortOrder isSortOrder.DESC. If none is specified, no such filter is used.sortOrder- an optional order with which to return the matching segments by id, start time, end time. If none is specified, the order of the results is not guarenteed.
-
getUnusedSegmentIntervals
List<org.joda.time.Interval> getUnusedSegmentIntervals(String dataSource, @Nullable org.joda.time.DateTime minStartTime, org.joda.time.DateTime maxEndTime, int limit, org.joda.time.DateTime maxUsedStatusLastUpdatedTime) Returns a list of up tolimitunused segment intervals for the specified datasource. Segments are filtered based on the following criteria:- The start time of the segment must be no earlier than the specified
minStartTime(if not null).- The end time of the segment must be no later than the specified
maxEndTime.- The
used_status_last_updatedtime of the segment must be no later thanmaxUsedStatusLastUpdatedTime. Segments that have noused_status_last_updatedtime (due to an upgrade from legacy Druid) will havemaxUsedStatusLastUpdatedTimeignored.- Returns:
- list of intervals ordered by segment start time and then by end time. Note that the list may contain duplicate intervals.
- The start time of the segment must be no earlier than the specified
-
retrieveUnusedSegmentIntervals
Retrieves intervals of the specified datasource that contain any unused segments. There is no guarantee on the order of intervals in the list or on whether the limited list contains the earliest or latest intervals of the datasource.- Returns:
- Unsorted list of unused segment intervals containing upto
limitentries.
-
markAllNonOvershadowedSegmentsAsUsed
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). If the call results in a database error, an exception is relayed to the caller.- Returns:
- Number of segments updated in the metadata store
-
markNonOvershadowedSegmentsAsUsed
int markNonOvershadowedSegmentsAsUsed(String dataSource, org.joda.time.Interval interval, @Nullable List<String> versions) Marks non-overshadowed unused segments for the given interval and optional list of versions as used. If versions are not specified, all versions of non-overshadowed unused segments in the interval will be marked as used. If an empty list of versions is passed, no segments are marked as used.- Returns:
- Number of segments updated in the metadata store
-
markNonOvershadowedSegmentsAsUsed
Marks the given segment IDs as "used" only if there are not already overshadowed by other used segments. Qualifying segment IDs that are already marked as "used" are not updated.- Returns:
- Number of segments updated
- Throws:
DruidException- of category INVALID_INPUT if any of the given segment IDs do not exist in the metadata store.
-
markSegmentAsUsed
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. If the call results in a database error, an exception is relayed to the caller. -
validateDataSourceMetadata
static void validateDataSourceMetadata(@Nullable String supervisorId, @Nullable DataSourceMetadata startMetadata, @Nullable DataSourceMetadata endMetadata) Validates the given supervisorId and given metadata to ensure that start/end metadata non-null implies supervisor ID is non-null.
-