kfaraz commented on code in PR #18028:
URL: https://github.com/apache/druid/pull/18028#discussion_r2122453279
##########
server/src/main/java/org/apache/druid/metadata/SegmentsMetadataManagerConfig.java:
##########
@@ -39,14 +40,24 @@ public class SegmentsMetadataManagerConfig
@JsonProperty
private final SegmentMetadataCache.UsageMode useIncrementalCache;
+ @JsonProperty
+ private final UnusedSegmentKillerConfig killUnused;
+
@JsonCreator
public SegmentsMetadataManagerConfig(
@JsonProperty("pollDuration") Period pollDuration,
- @JsonProperty("useIncrementalCache") SegmentMetadataCache.UsageMode
useIncrementalCache
+ @JsonProperty("useIncrementalCache") SegmentMetadataCache.UsageMode
useIncrementalCache,
+ @JsonProperty("killUnused") UnusedSegmentKillerConfig killUnused
)
{
this.pollDuration = Configs.valueOrDefault(pollDuration,
Period.minutes(1));
this.useIncrementalCache = Configs.valueOrDefault(useIncrementalCache,
SegmentMetadataCache.UsageMode.NEVER);
+ this.killUnused = Configs.valueOrDefault(killUnused, new
UnusedSegmentKillerConfig(null, null));
+ if (this.killUnused.isEnabled() && this.useIncrementalCache ==
SegmentMetadataCache.UsageMode.NEVER) {
+ throw InvalidInput.exception(
Review Comment:
Updated.
##########
server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataQuery.java:
##########
@@ -286,6 +287,37 @@ public List<DataSegmentPlus>
iterateAllUnusedSegmentsForDatasource(
}
}
+ /**
+ * Retrieves unused segments that are fully contained within the given
interval.
+ *
+ * @param interval Returned segments must be fully contained within
this
+ * interval
+ * @param versions Optional list of segment versions. If passed as
null,
+ * all segment versions are eligible.
+ * @param limit Maximum number of segments to return. If passed as
null,
+ * all segments are returned.
+ * @param maxUpdatedTime Returned segments must have a {@code
used_status_last_updated}
+ * which is either null or earlier than this value.
+ */
+ public List<DataSegment> findUnusedSegments(
+ String dataSource,
+ Interval interval,
+ @Nullable List<String> versions,
+ @Nullable Integer limit,
+ @Nullable DateTime maxUpdatedTime
+ )
+ {
+ try (
+ final CloseableIterator<DataSegment> iterator =
+ retrieveUnusedSegments(dataSource, List.of(interval), versions,
limit, null, null, maxUpdatedTime)
+ ) {
+ return ImmutableList.copyOf(iterator);
+ }
+ catch (IOException e) {
+ throw DruidException.defensive(e, "Error while reading unused segments");
+ }
Review Comment:
Fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]