diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/OverlordResource.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/OverlordResource.java index c3dd6ac52a65..e0280945bf74 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/OverlordResource.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/OverlordResource.java @@ -232,7 +232,7 @@ public Response taskPost( auditManager.doAudit( AuditEvent.builder() .key(task.getDataSource()) - .type("submit.ingestion.task") + .type("ingestion.batch") .payload(new TaskIdentifier(task.getId(), task.getGroupId(), task.getType())) .auditInfo(new AuditInfo(author, comment, req.getRemoteAddr())) .build() diff --git a/processing/src/main/java/org/apache/druid/audit/AuditManager.java b/processing/src/main/java/org/apache/druid/audit/AuditManager.java index 487a9c9d3e76..abc232346519 100644 --- a/processing/src/main/java/org/apache/druid/audit/AuditManager.java +++ b/processing/src/main/java/org/apache/druid/audit/AuditManager.java @@ -41,8 +41,8 @@ public interface AuditManager * audited changes. Only SQL-based implementations need to implement this method, * other implementations call {@link #doAudit} by default. * - * @param AuditEvent - * @param handle JDBI Handle representing connection to the database + * @param event Event to audit + * @param handle JDBI Handle representing connection to the database */ default void doAudit(AuditEvent event, Handle handle) throws IOException { @@ -53,10 +53,7 @@ default void doAudit(AuditEvent event, Handle handle) throws IOException * Fetches audit entries made for the given key, type and interval. Implementations * that do not maintain an audit history should return an empty list. * - * @param key - * @param type - * @param interval - * @return list of AuditEntries satisfying the passed parameters + * @return List of recorded audit events satisfying the passed parameters. */ List fetchAuditHistory(String key, String type, Interval interval); @@ -65,26 +62,21 @@ default void doAudit(AuditEvent event, Handle handle) throws IOException * * @param type Type of audit entry * @param interval Eligible interval for audit time - * @return List of audit entries satisfying the passed parameters. + * @return List of recorded audit events satisfying the passed parameters. */ List fetchAuditHistory(String type, Interval interval); /** * Provides last N entries of audit history for given key, type * - * @param key - * @param type - * @param limit - * @return list of AuditEntries satisfying the passed parameters + * @return list of recorded audit events satisfying the passed parameters */ List fetchAuditHistory(String key, String type, int limit); /** * Provides last N entries of audit history for given type * - * @param type type of AuditEvent - * @param limit - * @return list of AuditEntries satisfying the passed parameters + * @return List of recorded audit events satisfying the passed parameters. */ List fetchAuditHistory(String type, int limit); @@ -92,7 +84,7 @@ default void doAudit(AuditEvent event, Handle handle) throws IOException * Remove audit logs created older than the given timestamp. * * @param timestamp timestamp in milliseconds - * @return number of audit logs removed + * @return Number of audit logs removed */ int removeAuditLogsOlderThan(long timestamp); } diff --git a/processing/src/test/java/org/apache/druid/common/config/JacksonConfigManagerTest.java b/processing/src/test/java/org/apache/druid/common/config/JacksonConfigManagerTest.java index 33e0e4cd324f..876d2e89a3e4 100644 --- a/processing/src/test/java/org/apache/druid/common/config/JacksonConfigManagerTest.java +++ b/processing/src/test/java/org/apache/druid/common/config/JacksonConfigManagerTest.java @@ -71,7 +71,7 @@ public void testSet() jacksonConfigManager.set(key, val, auditInfo); - ArgumentCaptor auditCapture = ArgumentCaptor.forClass(AuditEvent.Builder.class); + ArgumentCaptor auditCapture = ArgumentCaptor.forClass(AuditEvent.class); Mockito.verify(mockAuditManager).doAudit(auditCapture.capture()); Assert.assertNotNull(auditCapture.getValue()); } diff --git a/server/src/main/java/org/apache/druid/server/audit/AuditSerdeHelper.java b/server/src/main/java/org/apache/druid/server/audit/AuditSerdeHelper.java index 728c1d5d3ecf..8e4c414c412a 100644 --- a/server/src/main/java/org/apache/druid/server/audit/AuditSerdeHelper.java +++ b/server/src/main/java/org/apache/druid/server/audit/AuditSerdeHelper.java @@ -26,12 +26,12 @@ import org.apache.druid.error.InvalidInput; import org.apache.druid.guice.annotations.Json; import org.apache.druid.guice.annotations.JsonNonNull; -import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.java.util.common.logger.Logger; import java.io.IOException; -public class AuditSerdeHelper implements AuditEvent.PayloadDeserializer +public class AuditSerdeHelper { /** * Default message stored instead of the actual audit payload if the audit @@ -39,6 +39,9 @@ public class AuditSerdeHelper implements AuditEvent.PayloadDeserializer */ private static final String PAYLOAD_TRUNCATED_MSG = "Payload truncated as it exceeds 'druid.audit.manager.maxPayloadSizeBytes'"; + private static final String SERIALIZE_ERROR_MSG = + "Error serializing payload"; + private static final Logger log = new Logger(AuditSerdeHelper.class); private final ObjectMapper jsonMapper; private final ObjectMapper jsonMapperSkipNulls; @@ -72,7 +75,6 @@ public AuditRecord processAuditEvent(AuditEvent event) ); } - @Override public T deserializePayloadFromString(String serializedPayload, Class clazz) { if (serializedPayload == null || serializedPayload.isEmpty()) { @@ -105,7 +107,9 @@ private String serializePayloadToString(Object payload) : jsonMapper.writeValueAsString(payload); } catch (IOException e) { - throw new ISE(e, "Could not serialize audit payload[%s]", payload); + // Do not throw exception, only log error + log.error(e, "Could not serialize audit payload[%s]", payload); + return SERIALIZE_ERROR_MSG; } } 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 79237f507a54..46c521200a83 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 @@ -30,6 +30,9 @@ import com.sun.jersey.spi.container.ResourceFilters; import it.unimi.dsi.fastutil.objects.Object2LongMap; import org.apache.commons.lang.StringUtils; +import org.apache.druid.audit.AuditEvent; +import org.apache.druid.audit.AuditInfo; +import org.apache.druid.audit.AuditManager; import org.apache.druid.client.CoordinatorServerView; import org.apache.druid.client.DruidDataSource; import org.apache.druid.client.DruidServer; @@ -70,7 +73,9 @@ import javax.servlet.http.HttpServletRequest; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -110,6 +115,7 @@ public class DataSourcesResource private final OverlordClient overlordClient; private final AuthorizerMapper authorizerMapper; private final DruidCoordinator coordinator; + private final AuditManager auditManager; @Inject public DataSourcesResource( @@ -118,7 +124,8 @@ public DataSourcesResource( MetadataRuleManager metadataRuleManager, @Nullable OverlordClient overlordClient, AuthorizerMapper authorizerMapper, - DruidCoordinator coordinator + DruidCoordinator coordinator, + AuditManager auditManager ) { this.serverInventoryView = serverInventoryView; @@ -127,6 +134,7 @@ public DataSourcesResource( this.overlordClient = overlordClient; this.authorizerMapper = authorizerMapper; this.coordinator = coordinator; + this.auditManager = auditManager; } @GET @@ -220,13 +228,19 @@ public Response markAsUsedNonOvershadowedSegments( @Consumes(MediaType.APPLICATION_JSON) public Response markSegmentsAsUnused( @PathParam("dataSourceName") final String dataSourceName, - final MarkDataSourceSegmentsPayload payload + final MarkDataSourceSegmentsPayload payload, + @HeaderParam(AuditManager.X_DRUID_AUTHOR) @DefaultValue("") final String author, + @HeaderParam(AuditManager.X_DRUID_COMMENT) @DefaultValue("") final String comment, + @Context final HttpServletRequest req ) { MarkSegments markSegments = () -> { final Interval interval = payload.getInterval(); + final int numUpdatedSegments; + final Object auditPayload; if (interval != null) { - return segmentsMetadataManager.markAsUnusedSegmentsInInterval(dataSourceName, interval); + numUpdatedSegments = segmentsMetadataManager.markAsUnusedSegmentsInInterval(dataSourceName, interval); + auditPayload = Collections.singletonMap("interval", interval); } else { final Set segmentIds = payload.getSegmentIds() @@ -236,12 +250,24 @@ public Response markSegmentsAsUnused( .collect(Collectors.toSet()); // Note: segments for the "wrong" datasource are ignored. - return segmentsMetadataManager.markSegmentsAsUnused( + numUpdatedSegments = segmentsMetadataManager.markSegmentsAsUnused( segmentIds.stream() .filter(segmentId -> segmentId.getDataSource().equals(dataSourceName)) .collect(Collectors.toSet()) ); + auditPayload = Collections.singletonMap("segmentIds", segmentIds); + } + if (author != null && !author.isEmpty()) { + auditManager.doAudit( + AuditEvent.builder() + .key(dataSourceName) + .type("segments.markUnused") + .payload(auditPayload) + .auditInfo(new AuditInfo(author, comment, req.getRemoteAddr())) + .build() + ); } + return numUpdatedSegments; }; return doMarkSegmentsWithPayload("markSegmentsAsUnused", dataSourceName, payload, markSegments); } @@ -312,7 +338,8 @@ private static Response doMarkSegments(String method, String dataSourceName, Mar public Response markAsUnusedAllSegmentsOrKillUnusedSegmentsInInterval( @PathParam("dataSourceName") final String dataSourceName, @QueryParam("kill") final String kill, - @QueryParam("interval") final String interval + @QueryParam("interval") final String interval, + @Context HttpServletRequest req ) { if (overlordClient == null) { @@ -321,7 +348,7 @@ public Response markAsUnusedAllSegmentsOrKillUnusedSegmentsInInterval( boolean killSegments = kill != null && Boolean.valueOf(kill); if (killSegments) { - return killUnusedSegmentsInInterval(dataSourceName, interval); + return killUnusedSegmentsInInterval(dataSourceName, interval, null, null, req); } else { MarkSegments markSegments = () -> segmentsMetadataManager.markAsUnusedAllSegmentsInDataSource(dataSourceName); return doMarkSegments("markAsUnusedAllSegments", dataSourceName, markSegments); @@ -334,7 +361,10 @@ public Response markAsUnusedAllSegmentsOrKillUnusedSegmentsInInterval( @Produces(MediaType.APPLICATION_JSON) public Response killUnusedSegmentsInInterval( @PathParam("dataSourceName") final String dataSourceName, - @PathParam("interval") final String interval + @PathParam("interval") final String interval, + @HeaderParam(AuditManager.X_DRUID_AUTHOR) @DefaultValue("") final String author, + @HeaderParam(AuditManager.X_DRUID_COMMENT) @DefaultValue("") final String comment, + @Context final HttpServletRequest req ) { if (overlordClient == null) { @@ -345,7 +375,18 @@ public Response killUnusedSegmentsInInterval( } final Interval theInterval = Intervals.of(interval.replace('_', '/')); try { - FutureUtils.getUnchecked(overlordClient.runKillTask("api-issued", dataSourceName, theInterval, null), true); + final String killTaskId = FutureUtils.getUnchecked( + overlordClient.runKillTask("api-issued", dataSourceName, theInterval, null), + true + ); + auditManager.doAudit( + AuditEvent.builder() + .key(dataSourceName) + .type("segments.killTask") + .payload(ImmutableMap.of("killTaskId", killTaskId, "interval", theInterval)) + .auditInfo(new AuditInfo(author, comment, req.getRemoteAddr())) + .build() + ); return Response.ok().build(); } catch (Exception e) { 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 c33fffc80830..2413f96577ad 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 @@ -181,7 +181,7 @@ public void testGetFullQueryableDataSources() EasyMock.replay(inventoryView, server, request); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, null, null, null, AuthTestUtils.TEST_AUTHORIZER_MAPPER, null); + new DataSourcesResource(inventoryView, null, null, null, AuthTestUtils.TEST_AUTHORIZER_MAPPER, null, null); Response response = dataSourcesResource.getQueryableDataSources("full", null, request); Set result = (Set) response.getEntity(); Assert.assertEquals(200, response.getStatus()); @@ -255,7 +255,9 @@ public Access authorize(AuthenticationResult authenticationResult1, Resource res } }; - DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, null, null, null, authMapper, null); + DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, null, null, null, authMapper, null, + null + ); Response response = dataSourcesResource.getQueryableDataSources("full", null, request); Set result = (Set) response.getEntity(); @@ -294,7 +296,7 @@ public void testGetSimpleQueryableDataSources() EasyMock.replay(inventoryView, server, request); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, null, null, null, AuthTestUtils.TEST_AUTHORIZER_MAPPER, null); + new DataSourcesResource(inventoryView, null, null, null, AuthTestUtils.TEST_AUTHORIZER_MAPPER, null, null); Response response = dataSourcesResource.getQueryableDataSources(null, "simple", request); Assert.assertEquals(200, response.getStatus()); List> results = (List>) response.getEntity(); @@ -318,7 +320,7 @@ public void testFullGetTheDataSource() EasyMock.replay(inventoryView, server); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, null, null, null, null, null); + new DataSourcesResource(inventoryView, null, null, null, null, null, null); Response response = dataSourcesResource.getDataSource("datasource1", "full"); ImmutableDruidDataSource result = (ImmutableDruidDataSource) response.getEntity(); Assert.assertEquals(200, response.getStatus()); @@ -334,7 +336,7 @@ public void testNullGetTheDataSource() EasyMock.replay(inventoryView, server); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, null, null, null, null, null); + new DataSourcesResource(inventoryView, null, null, null, null, null, null); Assert.assertEquals(204, dataSourcesResource.getDataSource("none", null).getStatus()); EasyMock.verify(inventoryView, server); } @@ -352,7 +354,7 @@ public void testSimpleGetTheDataSource() EasyMock.replay(inventoryView, server); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, null, null, null, null, null); + new DataSourcesResource(inventoryView, null, null, null, null, null, null); Response response = dataSourcesResource.getDataSource("datasource1", null); Assert.assertEquals(200, response.getStatus()); Map> result = (Map>) response.getEntity(); @@ -385,7 +387,7 @@ public void testSimpleGetTheDataSourceManyTiers() EasyMock.expect(inventoryView.getInventory()).andReturn(ImmutableList.of(server, server2, server3)).atLeastOnce(); EasyMock.replay(inventoryView, server, server2, server3); - DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, null, null, null, null, null); + DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, null, null, null, null, null, null); Response response = dataSourcesResource.getDataSource("datasource1", null); Assert.assertEquals(200, response.getStatus()); Map> result = (Map>) response.getEntity(); @@ -423,7 +425,7 @@ public void testSimpleGetTheDataSourceWithReplicatedSegments() EasyMock.replay(inventoryView); - DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, null, null, null, null, null); + DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, null, null, null, null, null, null); Response response = dataSourcesResource.getDataSource("datasource1", null); Assert.assertEquals(200, response.getStatus()); Map> result1 = (Map>) response.getEntity(); @@ -468,7 +470,7 @@ public void testGetSegmentDataSourceIntervals() expectedIntervals.add(Intervals.of("2010-01-22T00:00:00.000Z/2010-01-23T00:00:00.000Z")); expectedIntervals.add(Intervals.of("2010-01-01T00:00:00.000Z/2010-01-02T00:00:00.000Z")); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, null, null, null, null, null); + new DataSourcesResource(inventoryView, null, null, null, null, null, null); Response response = dataSourcesResource.getIntervalsWithServedSegmentsOrAllServedSegmentsPerIntervals( "invalidDataSource", @@ -528,7 +530,7 @@ public void testGetServedSegmentsInIntervalInDataSource() EasyMock.replay(inventoryView); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, null, null, null, null, null); + new DataSourcesResource(inventoryView, null, null, null, null, null, null); Response response = dataSourcesResource.getServedSegmentsInInterval( "invalidDataSource", "2010-01-01/P1D", @@ -598,8 +600,8 @@ public void testKillSegmentsInIntervalInDataSource() EasyMock.replay(overlordClient, server); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, null, null, overlordClient, null, null); - Response response = dataSourcesResource.killUnusedSegmentsInInterval("datasource1", interval); + new DataSourcesResource(inventoryView, null, null, overlordClient, null, null, null); + Response response = dataSourcesResource.killUnusedSegmentsInInterval("datasource1", interval, null, null, request); Assert.assertEquals(200, response.getStatus()); Assert.assertNull(response.getEntity()); @@ -612,10 +614,10 @@ public void testMarkAsUnusedAllSegmentsInDataSource() OverlordClient overlordClient = EasyMock.createStrictMock(OverlordClient.class); EasyMock.replay(overlordClient, server); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, null, null, overlordClient, null, null); + new DataSourcesResource(inventoryView, null, null, overlordClient, null, null, null); try { Response response = - dataSourcesResource.markAsUnusedAllSegmentsOrKillUnusedSegmentsInInterval("datasource", "true", "???"); + dataSourcesResource.markAsUnusedAllSegmentsOrKillUnusedSegmentsInInterval("datasource", "true", "???", request); // 400 (Bad Request) or an IllegalArgumentException is expected. Assert.assertEquals(400, response.getStatus()); Assert.assertNotNull(response.getEntity()); @@ -635,7 +637,7 @@ public void testIsHandOffComplete() Rule loadRule = new IntervalLoadRule(Intervals.of("2013-01-02T00:00:00Z/2013-01-03T00:00:00Z"), null, null); Rule dropRule = new IntervalDropRule(Intervals.of("2013-01-01T00:00:00Z/2013-01-02T00:00:00Z")); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, null, databaseRuleManager, null, null, null); + new DataSourcesResource(inventoryView, null, databaseRuleManager, null, null, null, null); // test dropped EasyMock.expect(databaseRuleManager.getRulesWithDefault("dataSource1")) @@ -704,7 +706,9 @@ public void testMarkSegmentAsUsed() EasyMock.expect(segmentsMetadataManager.markSegmentAsUsed(segment.getId().toString())).andReturn(true).once(); EasyMock.replay(segmentsMetadataManager); - DataSourcesResource dataSourcesResource = new DataSourcesResource(null, segmentsMetadataManager, null, null, null, null); + DataSourcesResource dataSourcesResource = new DataSourcesResource(null, segmentsMetadataManager, null, null, null, null, + null + ); Response response = dataSourcesResource.markSegmentAsUsed(segment.getDataSource(), segment.getId().toString()); Assert.assertEquals(200, response.getStatus()); @@ -718,7 +722,9 @@ public void testMarkSegmentAsUsedNoChange() EasyMock.expect(segmentsMetadataManager.markSegmentAsUsed(segment.getId().toString())).andReturn(false).once(); EasyMock.replay(segmentsMetadataManager); - DataSourcesResource dataSourcesResource = new DataSourcesResource(null, segmentsMetadataManager, null, null, null, null); + DataSourcesResource dataSourcesResource = new DataSourcesResource(null, segmentsMetadataManager, null, null, null, null, + null + ); Response response = dataSourcesResource.markSegmentAsUsed(segment.getDataSource(), segment.getId().toString()); Assert.assertEquals(200, response.getStatus()); @@ -739,7 +745,7 @@ public void testMarkAsUsedNonOvershadowedSegmentsInterval() EasyMock.replay(segmentsMetadataManager, inventoryView, server); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); Response response = dataSourcesResource.markAsUsedNonOvershadowedSegments( "datasource1", @@ -762,7 +768,7 @@ public void testMarkAsUsedNonOvershadowedSegmentsIntervalNoneUpdated() EasyMock.replay(segmentsMetadataManager, inventoryView, server); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); Response response = dataSourcesResource.markAsUsedNonOvershadowedSegments( "datasource1", @@ -785,7 +791,7 @@ public void testMarkAsUsedNonOvershadowedSegmentsSet() throws UnknownSegmentIdsE EasyMock.replay(segmentsMetadataManager, inventoryView, server); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); Response response = dataSourcesResource.markAsUsedNonOvershadowedSegments( "datasource1", @@ -808,7 +814,7 @@ public void testMarkAsUsedNonOvershadowedSegmentsIntervalException() EasyMock.replay(segmentsMetadataManager, inventoryView, server); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); Response response = dataSourcesResource.markAsUsedNonOvershadowedSegments( "datasource1", @@ -826,7 +832,7 @@ public void testMarkAsUsedNonOvershadowedSegmentsNoDataSource() EasyMock.replay(segmentsMetadataManager, inventoryView, server); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); Response response = dataSourcesResource.markAsUsedNonOvershadowedSegments( "datasource1", @@ -840,7 +846,7 @@ public void testMarkAsUsedNonOvershadowedSegmentsNoDataSource() public void testMarkAsUsedNonOvershadowedSegmentsInvalidPayloadNoArguments() { DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); Response response = dataSourcesResource.markAsUsedNonOvershadowedSegments( "datasource1", @@ -853,7 +859,7 @@ public void testMarkAsUsedNonOvershadowedSegmentsInvalidPayloadNoArguments() public void testMarkAsUsedNonOvershadowedSegmentsInvalidPayloadBothArguments() { DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); Response response = dataSourcesResource.markAsUsedNonOvershadowedSegments( "datasource1", @@ -866,7 +872,7 @@ public void testMarkAsUsedNonOvershadowedSegmentsInvalidPayloadBothArguments() public void testMarkAsUsedNonOvershadowedSegmentsInvalidPayloadEmptyArray() { DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); Response response = dataSourcesResource.markAsUsedNonOvershadowedSegments( "datasource1", @@ -879,7 +885,7 @@ public void testMarkAsUsedNonOvershadowedSegmentsInvalidPayloadEmptyArray() public void testMarkAsUsedNonOvershadowedSegmentsNoPayload() { DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); Response response = dataSourcesResource.markAsUsedNonOvershadowedSegments("datasource1", null); Assert.assertEquals(400, response.getStatus()); @@ -1039,8 +1045,8 @@ public void testMarkSegmentsAsUnused() ); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); - Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); + Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload, "", "", request); Assert.assertEquals(200, response.getStatus()); Assert.assertEquals(ImmutableMap.of("numChangedSegments", 1), response.getEntity()); EasyMock.verify(segmentsMetadataManager, inventoryView, server); @@ -1070,8 +1076,8 @@ public void testMarkSegmentsAsUnusedNoChanges() ); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); - Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); + Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload, "", "", request); Assert.assertEquals(200, response.getStatus()); Assert.assertEquals(ImmutableMap.of("numChangedSegments", 0), response.getEntity()); EasyMock.verify(segmentsMetadataManager, inventoryView, server); @@ -1103,8 +1109,8 @@ public void testMarkSegmentsAsUnusedException() ); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); - Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); + Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload, "", "", request); Assert.assertEquals(500, response.getStatus()); Assert.assertNotNull(response.getEntity()); EasyMock.verify(segmentsMetadataManager, inventoryView, server); @@ -1125,8 +1131,8 @@ public void testMarkAsUnusedSegmentsInInterval() new DataSourcesResource.MarkDataSourceSegmentsPayload(theInterval, null); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); - Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); + Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload, "", "", request); Assert.assertEquals(200, response.getStatus()); Assert.assertEquals(ImmutableMap.of("numChangedSegments", 1), response.getEntity()); EasyMock.verify(segmentsMetadataManager, inventoryView, server); @@ -1148,8 +1154,8 @@ public void testMarkAsUnusedSegmentsInIntervalNoChanges() new DataSourcesResource.MarkDataSourceSegmentsPayload(theInterval, null); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); - Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); + Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload, "", "", request); Assert.assertEquals(200, response.getStatus()); Assert.assertEquals(ImmutableMap.of("numChangedSegments", 0), response.getEntity()); EasyMock.verify(segmentsMetadataManager, inventoryView, server); @@ -1172,8 +1178,8 @@ public void testMarkAsUnusedSegmentsInIntervalException() new DataSourcesResource.MarkDataSourceSegmentsPayload(theInterval, null); DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); - Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); + Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload, "", "", request); Assert.assertEquals(500, response.getStatus()); Assert.assertNotNull(response.getEntity()); EasyMock.verify(segmentsMetadataManager, inventoryView, server); @@ -1183,9 +1189,9 @@ public void testMarkAsUnusedSegmentsInIntervalException() public void testMarkSegmentsAsUnusedNullPayload() { DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); - Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", null); + Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", null, "", "", request); Assert.assertEquals(400, response.getStatus()); Assert.assertNotNull(response.getEntity()); Assert.assertEquals( @@ -1198,12 +1204,12 @@ public void testMarkSegmentsAsUnusedNullPayload() public void testMarkSegmentsAsUnusedInvalidPayload() { DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); final DataSourcesResource.MarkDataSourceSegmentsPayload payload = new DataSourcesResource.MarkDataSourceSegmentsPayload(null, null); - Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload); + Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload, "", "", request); Assert.assertEquals(400, response.getStatus()); Assert.assertNotNull(response.getEntity()); } @@ -1212,12 +1218,12 @@ public void testMarkSegmentsAsUnusedInvalidPayload() public void testMarkSegmentsAsUnusedInvalidPayloadBothArguments() { DataSourcesResource dataSourcesResource = - new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); final DataSourcesResource.MarkDataSourceSegmentsPayload payload = new DataSourcesResource.MarkDataSourceSegmentsPayload(Intervals.of("2010-01-01/P1D"), ImmutableSet.of()); - Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload); + Response response = dataSourcesResource.markSegmentsAsUnused("datasource1", payload, "", "", request); Assert.assertEquals(400, response.getStatus()); Assert.assertNotNull(response.getEntity()); } @@ -1225,7 +1231,9 @@ public void testMarkSegmentsAsUnusedInvalidPayloadBothArguments() @Test public void testGetDatasourceLoadstatusForceMetadataRefreshNull() { - DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, + null + ); Response response = dataSourcesResource.getDatasourceLoadstatus("datasource1", null, null, null, null, null); Assert.assertEquals(400, response.getStatus()); } @@ -1246,6 +1254,7 @@ public void testGetDatasourceLoadstatusNoSegmentForInterval() null, null, null, + null, null ); Response response = dataSourcesResource.getDatasourceLoadstatus("datasource1", true, null, null, null, null); @@ -1305,7 +1314,9 @@ public void testGetDatasourceLoadstatusDefault() EasyMock.expect(inventoryView.getLoadInfoForAllSegments()).andReturn(completedLoadInfoMap).once(); EasyMock.replay(segmentsMetadataManager, inventoryView); - DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, + null + ); Response response = dataSourcesResource.getDatasourceLoadstatus("datasource1", true, null, null, null, null); Assert.assertEquals(200, response.getStatus()); Assert.assertNotNull(response.getEntity()); @@ -1321,7 +1332,7 @@ public void testGetDatasourceLoadstatusDefault() EasyMock.expect(inventoryView.getLoadInfoForAllSegments()).andReturn(halfLoadedInfoMap).once(); EasyMock.replay(segmentsMetadataManager, inventoryView); - dataSourcesResource = new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + dataSourcesResource = new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); response = dataSourcesResource.getDatasourceLoadstatus("datasource1", true, null, null, null, null); Assert.assertEquals(200, response.getStatus()); Assert.assertNotNull(response.getEntity()); @@ -1384,7 +1395,9 @@ public void testGetDatasourceLoadstatusSimple() EasyMock.expect(inventoryView.getLoadInfoForAllSegments()).andReturn(completedLoadInfoMap).once(); EasyMock.replay(segmentsMetadataManager, inventoryView); - DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, + null + ); Response response = dataSourcesResource.getDatasourceLoadstatus("datasource1", true, null, "simple", null, null); Assert.assertEquals(200, response.getStatus()); Assert.assertNotNull(response.getEntity()); @@ -1400,7 +1413,7 @@ public void testGetDatasourceLoadstatusSimple() EasyMock.expect(inventoryView.getLoadInfoForAllSegments()).andReturn(halfLoadedInfoMap).once(); EasyMock.replay(segmentsMetadataManager, inventoryView); - dataSourcesResource = new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null); + dataSourcesResource = new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, null, null); response = dataSourcesResource.getDatasourceLoadstatus("datasource1", true, null, "simple", null, null); Assert.assertEquals(200, response.getStatus()); Assert.assertNotNull(response.getEntity()); @@ -1455,7 +1468,9 @@ public void testGetDatasourceLoadstatusFull() EasyMock.replay(segmentsMetadataManager, druidCoordinator); - DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, druidCoordinator); + DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, druidCoordinator, + null + ); Response response = dataSourcesResource.getDatasourceLoadstatus("datasource1", true, null, null, "full", null); Assert.assertEquals(200, response.getStatus()); Assert.assertNotNull(response.getEntity()); @@ -1512,7 +1527,9 @@ public void testGetDatasourceLoadstatusFullAndComputeUsingClusterView() EasyMock.replay(segmentsMetadataManager, druidCoordinator); - DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, druidCoordinator); + DataSourcesResource dataSourcesResource = new DataSourcesResource(inventoryView, segmentsMetadataManager, null, null, null, druidCoordinator, + null + ); Response response = dataSourcesResource.getDatasourceLoadstatus("datasource1", true, null, null, "full", "computeUsingClusterView"); Assert.assertEquals(200, response.getStatus()); Assert.assertNotNull(response.getEntity());