diff --git a/server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java b/server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java index c886af6a6d9..bc4a1ddb50d 100644 --- a/server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java +++ b/server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java @@ -50,6 +50,7 @@ import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.java.util.common.parsers.CloseableIterator; import org.apache.druid.segment.SegmentUtils; import org.apache.druid.segment.realtime.appenderator.SegmentIdWithShardSpec; +import org.apache.druid.server.http.DataSegmentPlus; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.Partitions; import org.apache.druid.timeline.SegmentTimeline; @@ -2035,6 +2036,8 @@ public class IndexerSQLMetadataStorageCoordinator implements IndexerMetadataStor return Collections.emptySet(); } + final String datasource = replaceSegments.iterator().next().getDataSource(); + // For each replace interval, find the number of core partitions and total partitions final Map intervalToNumCorePartitions = new HashMap<>(); final Map intervalToCurrentPartitionNum = new HashMap<>(); @@ -2055,7 +2058,7 @@ public class IndexerSQLMetadataStorageCoordinator implements IndexerMetadataStor final Map upgradeSegmentToLockVersion = getAppendSegmentsCommittedDuringTask(handle, taskId); final List segmentsToUpgrade - = retrieveSegmentsById(handle, upgradeSegmentToLockVersion.keySet()); + = retrieveSegmentsById(handle, datasource, upgradeSegmentToLockVersion.keySet()); if (segmentsToUpgrade.isEmpty()) { return Collections.emptySet(); @@ -2242,30 +2245,17 @@ public class IndexerSQLMetadataStorageCoordinator implements IndexerMetadataStor } } - private List retrieveSegmentsById(Handle handle, Set segmentIds) + private List retrieveSegmentsById(Handle handle, String datasource, Set segmentIds) { if (segmentIds.isEmpty()) { return Collections.emptyList(); } - final String segmentIdCsv = segmentIds.stream() - .map(id -> "'" + id + "'") - .collect(Collectors.joining(",")); - ResultIterator resultIterator = handle - .createQuery( - StringUtils.format( - "SELECT payload FROM %s WHERE id in (%s)", - dbTables.getSegmentsTable(), segmentIdCsv - ) - ) - .setFetchSize(connector.getStreamingFetchSize()) - .map( - (index, r, ctx) -> - JacksonUtils.readValue(jsonMapper, r.getBytes(1), DataSegment.class) - ) - .iterator(); - - return Lists.newArrayList(resultIterator); + return SqlSegmentsMetadataQuery.forHandle(handle, connector, dbTables, jsonMapper) + .retrieveSegmentsById(datasource, segmentIds) + .stream() + .map(DataSegmentPlus::getDataSegment) + .collect(Collectors.toList()); } private String buildSqlToInsertSegments() diff --git a/server/src/main/java/org/apache/druid/metadata/SegmentsMetadataManager.java b/server/src/main/java/org/apache/druid/metadata/SegmentsMetadataManager.java index a8ac35d2c67..540eba990f2 100644 --- a/server/src/main/java/org/apache/druid/metadata/SegmentsMetadataManager.java +++ b/server/src/main/java/org/apache/druid/metadata/SegmentsMetadataManager.java @@ -55,8 +55,17 @@ public interface SegmentsMetadataManager int markAsUsedNonOvershadowedSegmentsInInterval(String dataSource, Interval interval); - int markAsUsedNonOvershadowedSegments(String dataSource, Set segmentIds) - throws UnknownSegmentIdsException; + /** + * 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. + * + * @return Number of segments updated + * @throws org.apache.druid.error.DruidException of category INVALID_INPUT if + * any of the given segment IDs + * do not exist in the metadata store. + */ + int markAsUsedNonOvershadowedSegments(String dataSource, Set segmentIds); /** * Returns true if the state of the segment entry is changed in the database as the result of this call (that is, the diff --git a/server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataManager.java b/server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataManager.java index 028f73ee42a..4a268a2257d 100644 --- a/server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataManager.java +++ b/server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataManager.java @@ -35,6 +35,8 @@ import com.google.errorprone.annotations.concurrent.GuardedBy; import com.google.inject.Inject; import org.apache.druid.client.DataSourcesSnapshot; import org.apache.druid.client.ImmutableDruidDataSource; +import org.apache.druid.error.DruidException; +import org.apache.druid.error.InvalidInput; import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.Intervals; @@ -718,7 +720,6 @@ public class SqlSegmentsMetadataManager implements SegmentsMetadataManager @Override public int markAsUsedNonOvershadowedSegments(final String dataSource, final Set segmentIds) - throws UnknownSegmentIdsException { try { Pair, SegmentTimeline> unusedSegmentsAndTimeline = connector @@ -744,8 +745,8 @@ public class SqlSegmentsMetadataManager implements SegmentsMetadataManager } catch (Exception e) { Throwable rootCause = Throwables.getRootCause(e); - if (rootCause instanceof UnknownSegmentIdsException) { - throw (UnknownSegmentIdsException) rootCause; + if (rootCause instanceof DruidException) { + throw (DruidException) rootCause; } else { throw e; } @@ -756,58 +757,30 @@ public class SqlSegmentsMetadataManager implements SegmentsMetadataManager final String dataSource, final Set segmentIds, final Handle handle - ) throws UnknownSegmentIdsException + ) { - List unknownSegmentIds = new ArrayList<>(); - List segments = segmentIds - .stream() - .map( - segmentId -> { - Iterator segmentResultIterator = handle - .createQuery( - StringUtils.format( - "SELECT used, payload FROM %1$s WHERE dataSource = :dataSource AND id = :id", - getSegmentsTable() - ) - ) - .bind("dataSource", dataSource) - .bind("id", segmentId) - .map((int index, ResultSet resultSet, StatementContext context) -> { - try { - if (!resultSet.getBoolean("used")) { - return jsonMapper.readValue(resultSet.getBytes("payload"), DataSegment.class); - } else { - // We emit nulls for used segments. They are filtered out below in this method. - return null; - } - } - catch (IOException e) { - throw new RuntimeException(e); - } - }) - .iterator(); - if (!segmentResultIterator.hasNext()) { - unknownSegmentIds.add(segmentId); - return null; - } else { - @Nullable DataSegment segment = segmentResultIterator.next(); - if (segmentResultIterator.hasNext()) { - log.error( - "There is more than one row corresponding to segment id [%s] in data source [%s] in the database", - segmentId, - dataSource - ); - } - return segment; - } - } - ) - .filter(Objects::nonNull) // Filter nulls corresponding to used segments. - .collect(Collectors.toList()); - if (!unknownSegmentIds.isEmpty()) { - throw new UnknownSegmentIdsException(unknownSegmentIds); + final List retrievedSegments = SqlSegmentsMetadataQuery + .forHandle(handle, connector, dbTables.get(), jsonMapper) + .retrieveSegmentsById(dataSource, segmentIds); + + final Set unknownSegmentIds = new HashSet<>(segmentIds); + final List unusedSegments = new ArrayList<>(); + for (DataSegmentPlus entry : retrievedSegments) { + final DataSegment segment = entry.getDataSegment(); + unknownSegmentIds.remove(segment.getId().toString()); + if (Boolean.FALSE.equals(entry.getUsed())) { + unusedSegments.add(segment); + } } - return segments; + + if (!unknownSegmentIds.isEmpty()) { + throw InvalidInput.exception( + "Could not find segment IDs[%s] for datasource[%s]", + unknownSegmentIds, dataSource + ); + } + + return unusedSegments; } private CloseableIterator retrieveUsedSegmentsOverlappingIntervals( diff --git a/server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataQuery.java b/server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataQuery.java index 82213897514..29465cd665b 100644 --- a/server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataQuery.java +++ b/server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataQuery.java @@ -44,13 +44,13 @@ import org.skife.jdbi.v2.Query; import org.skife.jdbi.v2.ResultIterator; import javax.annotation.Nullable; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; /** @@ -227,6 +227,49 @@ public class SqlSegmentsMetadataQuery ); } + public List retrieveSegmentsById(String datasource, Set segmentIds) + { + final List> partitionedSegmentIds + = Lists.partition(new ArrayList<>(segmentIds), 100); + + final List fetchedSegments = new ArrayList<>(segmentIds.size()); + for (List partition : partitionedSegmentIds) { + fetchedSegments.addAll(retrieveSegmentBatchById(datasource, partition)); + } + return fetchedSegments; + } + + private List retrieveSegmentBatchById(String datasource, List segmentIds) + { + if (segmentIds.isEmpty()) { + return Collections.emptyList(); + } + + final String segmentIdCsv = segmentIds.stream() + .map(id -> "'" + id + "'") + .collect(Collectors.joining(",")); + ResultIterator resultIterator = handle + .createQuery( + StringUtils.format( + "SELECT payload, used FROM %s WHERE dataSource = :dataSource AND id IN (%s)", + dbTables.getSegmentsTable(), segmentIdCsv + ) + ) + .bind("dataSource", datasource) + .setFetchSize(connector.getStreamingFetchSize()) + .map( + (index, r, ctx) -> new DataSegmentPlus( + JacksonUtils.readValue(jsonMapper, r.getBytes(1), DataSegment.class), + null, + null, + r.getBoolean(2) + ) + ) + .iterator(); + + return Lists.newArrayList(resultIterator); + } + /** * Marks the provided segments as either used or unused. * @@ -335,7 +378,6 @@ public class SqlSegmentsMetadataQuery */ public DataSegment retrieveUsedSegmentForId(String id) { - final String query = "SELECT payload FROM %s WHERE used = true AND id = :id"; final Query> sql = handle @@ -358,7 +400,6 @@ public class SqlSegmentsMetadataQuery */ public DataSegment retrieveSegmentForId(String id) { - final String query = "SELECT payload FROM %s WHERE id = :id"; final Query> sql = handle @@ -707,7 +748,8 @@ public class SqlSegmentsMetadataQuery return sql.map((index, r, ctx) -> new DataSegmentPlus( JacksonUtils.readValue(jsonMapper, r.getBytes(1), DataSegment.class), DateTimes.of(r.getString(2)), - DateTimes.of(r.getString(3)) + DateTimes.of(r.getString(3)), + null )) .iterator(); } diff --git a/server/src/main/java/org/apache/druid/metadata/UnknownSegmentIdsException.java b/server/src/main/java/org/apache/druid/metadata/UnknownSegmentIdsException.java deleted file mode 100644 index 2c7e3996cba..00000000000 --- a/server/src/main/java/org/apache/druid/metadata/UnknownSegmentIdsException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.druid.metadata; - -import java.util.Collection; - -/** - * Exception thrown by {@link SegmentsMetadataManager} when a segment id is unknown. - * - * @deprecated Usages of this exception will be replaced by the new - * {@link org.apache.druid.error.DruidException} in a future release. - */ -@Deprecated -public class UnknownSegmentIdsException extends Exception -{ - private final Collection unknownSegmentIds; - - UnknownSegmentIdsException(Collection segmentIds) - { - super("Cannot find segment ids " + segmentIds); - this.unknownSegmentIds = segmentIds; - } - - public Collection getUnknownSegmentIds() - { - return unknownSegmentIds; - } -} diff --git a/server/src/main/java/org/apache/druid/server/http/DataSegmentPlus.java b/server/src/main/java/org/apache/druid/server/http/DataSegmentPlus.java index 2a0d7fc05ea..f433957a8c0 100644 --- a/server/src/main/java/org/apache/druid/server/http/DataSegmentPlus.java +++ b/server/src/main/java/org/apache/druid/server/http/DataSegmentPlus.java @@ -31,10 +31,14 @@ import java.util.Objects; /** * Encapsulates a {@link DataSegment} and additional metadata about it: - * {@link DataSegmentPlus#createdDate}: The time when the segment was created - * {@link DataSegmentPlus#usedStatusLastUpdatedDate}: The time when the segments used status was last updated + *
    + *
  • {@link DataSegmentPlus#used} - Boolean flag representing if the segment is used.
  • + *
  • {@link DataSegmentPlus#createdDate} - The time when the segment was created.
  • + *
  • {@link DataSegmentPlus#usedStatusLastUpdatedDate} - The time when the segments + * used status was last updated.
  • + *
*

- * The class closesly resembles the row structure of the {@link MetadataStorageTablesConfig#getSegmentsTable()} + * This class closely resembles the row structure of the {@link MetadataStorageTablesConfig#getSegmentsTable()}. *

*/ @UnstableApi @@ -44,19 +48,23 @@ public class DataSegmentPlus private final DateTime createdDate; @Nullable private final DateTime usedStatusLastUpdatedDate; + private final Boolean used; @JsonCreator public DataSegmentPlus( @JsonProperty("dataSegment") final DataSegment dataSegment, - @JsonProperty("createdDate") final DateTime createdDate, - @JsonProperty("usedStatusLastUpdatedDate") @Nullable final DateTime usedStatusLastUpdatedDate + @JsonProperty("createdDate") @Nullable final DateTime createdDate, + @JsonProperty("usedStatusLastUpdatedDate") @Nullable final DateTime usedStatusLastUpdatedDate, + @JsonProperty("used") @Nullable final Boolean used ) { this.dataSegment = dataSegment; this.createdDate = createdDate; this.usedStatusLastUpdatedDate = usedStatusLastUpdatedDate; + this.used = used; } + @Nullable @JsonProperty public DateTime getCreatedDate() { @@ -76,6 +84,13 @@ public class DataSegmentPlus return dataSegment; } + @Nullable + @JsonProperty + public Boolean getUsed() + { + return used; + } + @Override public boolean equals(Object o) { @@ -88,7 +103,8 @@ public class DataSegmentPlus DataSegmentPlus that = (DataSegmentPlus) o; return Objects.equals(dataSegment, that.getDataSegment()) && Objects.equals(createdDate, that.getCreatedDate()) - && Objects.equals(usedStatusLastUpdatedDate, that.getUsedStatusLastUpdatedDate()); + && Objects.equals(usedStatusLastUpdatedDate, that.getUsedStatusLastUpdatedDate()) + && Objects.equals(used, that.getUsed()); } @Override @@ -97,7 +113,8 @@ public class DataSegmentPlus return Objects.hash( dataSegment, createdDate, - usedStatusLastUpdatedDate + usedStatusLastUpdatedDate, + used ); } @@ -108,6 +125,7 @@ public class DataSegmentPlus "createdDate=" + getCreatedDate() + ", usedStatusLastUpdatedDate=" + getUsedStatusLastUpdatedDate() + ", dataSegment=" + getDataSegment() + + ", used=" + getUsed() + '}'; } } diff --git a/server/src/main/java/org/apache/druid/server/http/DataSourcesResource.java b/server/src/main/java/org/apache/druid/server/http/DataSourcesResource.java index bfc6ce03b07..b83bda21dcd 100644 --- a/server/src/main/java/org/apache/druid/server/http/DataSourcesResource.java +++ b/server/src/main/java/org/apache/druid/server/http/DataSourcesResource.java @@ -39,6 +39,9 @@ import org.apache.druid.client.ImmutableDruidDataSource; import org.apache.druid.client.ImmutableSegmentLoadInfo; import org.apache.druid.client.SegmentLoadInfo; import org.apache.druid.common.guava.FutureUtils; +import org.apache.druid.error.DruidException; +import org.apache.druid.error.ErrorResponse; +import org.apache.druid.error.InvalidInput; import org.apache.druid.guice.annotations.PublicApi; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.Intervals; @@ -49,7 +52,6 @@ import org.apache.druid.java.util.common.guava.FunctionalIterable; import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.metadata.MetadataRuleManager; import org.apache.druid.metadata.SegmentsMetadataManager; -import org.apache.druid.metadata.UnknownSegmentIdsException; import org.apache.druid.query.SegmentDescriptor; import org.apache.druid.query.TableDataSource; import org.apache.druid.rpc.indexing.OverlordClient; @@ -184,7 +186,7 @@ public class DataSourcesResource private interface SegmentUpdateOperation { - int perform() throws UnknownSegmentIdsException; + int perform(); } @POST @@ -193,8 +195,8 @@ public class DataSourcesResource @ResourceFilters(DatasourceResourceFilter.class) public Response markAsUsedAllNonOvershadowedSegments(@PathParam("dataSourceName") final String dataSourceName) { - SegmentUpdateOperation operation = () -> segmentsMetadataManager.markAsUsedAllNonOvershadowedSegmentsInDataSource( - dataSourceName); + SegmentUpdateOperation operation = () -> segmentsMetadataManager + .markAsUsedAllNonOvershadowedSegmentsInDataSource(dataSourceName); return performSegmentUpdate(dataSourceName, operation); } @@ -213,6 +215,21 @@ public class DataSourcesResource return segmentsMetadataManager.markAsUsedNonOvershadowedSegmentsInInterval(dataSourceName, interval); } else { final Set segmentIds = payload.getSegmentIds(); + if (segmentIds == null || segmentIds.isEmpty()) { + return 0; + } + + // Validate segmentIds + final List invalidSegmentIds = new ArrayList<>(); + for (String segmentId : segmentIds) { + if (SegmentId.iteratePossibleParsingsWithDataSource(dataSourceName, segmentId).isEmpty()) { + invalidSegmentIds.add(segmentId); + } + } + if (!invalidSegmentIds.isEmpty()) { + throw InvalidInput.exception("Could not parse invalid segment IDs[%s]", invalidSegmentIds); + } + return segmentsMetadataManager.markAsUsedNonOvershadowedSegments(dataSourceName, segmentIds); } }; @@ -298,11 +315,10 @@ public class DataSourcesResource int numChangedSegments = operation.perform(); return Response.ok(ImmutableMap.of("numChangedSegments", numChangedSegments)).build(); } - catch (UnknownSegmentIdsException e) { - log.warn("Could not find segmentIds[%s]", e.getUnknownSegmentIds()); + catch (DruidException e) { return Response - .status(Response.Status.NOT_FOUND) - .entity(ImmutableMap.of("message", e.getMessage())) + .status(e.getStatusCode()) + .entity(new ErrorResponse(e)) .build(); } catch (Exception e) { diff --git a/server/src/test/java/org/apache/druid/metadata/SqlSegmentsMetadataManagerTest.java b/server/src/test/java/org/apache/druid/metadata/SqlSegmentsMetadataManagerTest.java index 85e5021f6c6..7e491325110 100644 --- a/server/src/test/java/org/apache/druid/metadata/SqlSegmentsMetadataManagerTest.java +++ b/server/src/test/java/org/apache/druid/metadata/SqlSegmentsMetadataManagerTest.java @@ -28,6 +28,8 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import org.apache.druid.client.DataSourcesSnapshot; import org.apache.druid.client.ImmutableDruidDataSource; +import org.apache.druid.error.DruidException; +import org.apache.druid.error.DruidExceptionMatcher; import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.StringUtils; @@ -38,6 +40,7 @@ import org.apache.druid.server.metrics.NoopServiceEmitter; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.SegmentId; import org.apache.druid.timeline.partition.NoneShardSpec; +import org.hamcrest.MatcherAssert; import org.joda.time.DateTime; import org.joda.time.Duration; import org.joda.time.Interval; @@ -602,9 +605,14 @@ public class SqlSegmentsMetadataManagerTest ImmutableSet.copyOf(sqlSegmentsMetadataManager.iterateAllUsedSegments()) ); - Assert.assertThrows( - UnknownSegmentIdsException.class, - () -> sqlSegmentsMetadataManager.markAsUsedNonOvershadowedSegments("wrongDataSource", segmentIds) + MatcherAssert.assertThat( + Assert.assertThrows( + DruidException.class, + () -> sqlSegmentsMetadataManager.markAsUsedNonOvershadowedSegments("wrongDataSource", segmentIds) + ), + DruidExceptionMatcher + .invalidInput() + .expectMessageContains("Could not find segment IDs") ); } @@ -627,9 +635,14 @@ public class SqlSegmentsMetadataManagerTest ImmutableSet.copyOf(sqlSegmentsMetadataManager.iterateAllUsedSegments()) ); - Assert.assertThrows( - UnknownSegmentIdsException.class, - () -> sqlSegmentsMetadataManager.markAsUsedNonOvershadowedSegments(DS.KOALA, segmentIds) + MatcherAssert.assertThat( + Assert.assertThrows( + DruidException.class, + () -> sqlSegmentsMetadataManager.markAsUsedNonOvershadowedSegments(DS.KOALA, segmentIds) + ), + DruidExceptionMatcher + .invalidInput() + .expectMessageContains("Could not find segment IDs") ); } diff --git a/server/src/test/java/org/apache/druid/server/http/DataSegmentPlusTest.java b/server/src/test/java/org/apache/druid/server/http/DataSegmentPlusTest.java index f2c9a68a8d5..157affe85a8 100644 --- a/server/src/test/java/org/apache/druid/server/http/DataSegmentPlusTest.java +++ b/server/src/test/java/org/apache/druid/server/http/DataSegmentPlusTest.java @@ -97,7 +97,8 @@ public class DataSegmentPlusTest 1 ), createdDate, - usedStatusLastUpdatedDate + usedStatusLastUpdatedDate, + null ); final Map objectMap = MAPPER.readValue( @@ -105,7 +106,7 @@ public class DataSegmentPlusTest JacksonUtils.TYPE_REFERENCE_MAP_STRING_OBJECT ); - Assert.assertEquals(3, objectMap.size()); + Assert.assertEquals(4, objectMap.size()); final Map segmentObjectMap = MAPPER.readValue( MAPPER.writeValueAsString(segmentPlus.getDataSegment()), JacksonUtils.TYPE_REFERENCE_MAP_STRING_OBJECT diff --git a/server/src/test/java/org/apache/druid/server/http/DataSourcesResourceTest.java b/server/src/test/java/org/apache/druid/server/http/DataSourcesResourceTest.java index 79184fdf327..69fe23a75b5 100644 --- a/server/src/test/java/org/apache/druid/server/http/DataSourcesResourceTest.java +++ b/server/src/test/java/org/apache/druid/server/http/DataSourcesResourceTest.java @@ -39,7 +39,6 @@ import org.apache.druid.error.DruidExceptionMatcher; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.metadata.MetadataRuleManager; import org.apache.druid.metadata.SegmentsMetadataManager; -import org.apache.druid.metadata.UnknownSegmentIdsException; import org.apache.druid.query.SegmentDescriptor; import org.apache.druid.query.TableDataSource; import org.apache.druid.rpc.indexing.OverlordClient; @@ -775,7 +774,7 @@ public class DataSourcesResourceTest } @Test - public void testMarkAsUsedNonOvershadowedSegmentsSet() throws UnknownSegmentIdsException + public void testMarkAsUsedNonOvershadowedSegmentsSet() { DruidDataSource dataSource = new DruidDataSource("datasource1", new HashMap<>()); Set segmentIds = ImmutableSet.of(dataSegmentList.get(1).getId().toString()); diff --git a/server/src/test/java/org/apache/druid/server/http/MetadataResourceTest.java b/server/src/test/java/org/apache/druid/server/http/MetadataResourceTest.java index fa99a411d36..c76da048295 100644 --- a/server/src/test/java/org/apache/druid/server/http/MetadataResourceTest.java +++ b/server/src/test/java/org/apache/druid/server/http/MetadataResourceTest.java @@ -77,7 +77,7 @@ public class MetadataResourceTest .toArray(new DataSegment[0]); private final List segmentsPlus = Arrays.stream(segments) - .map(s -> new DataSegmentPlus(s, DateTimes.nowUtc(), DateTimes.nowUtc())) + .map(s -> new DataSegmentPlus(s, DateTimes.nowUtc(), DateTimes.nowUtc(), null)) .collect(Collectors.toList()); private HttpServletRequest request; private SegmentsMetadataManager segmentsMetadataManager;