github-advanced-security[bot] commented on code in PR #17834:
URL: https://github.com/apache/druid/pull/17834#discussion_r2016965186
##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/OverlordCompactionResource.java:
##########
@@ -119,6 +141,106 @@
return Response.ok(new CompactionStatusResponse(snapshots)).build();
}
+ @POST
+ @Path("/config/datasources/{dataSource}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResourceFilters(DatasourceResourceFilter.class)
+ public Response updateDatasourceCompactionConfig(
+ @PathParam("dataSource") String dataSource,
+ DataSourceCompactionConfig newConfig,
+ @Context HttpServletRequest req
+ )
+ {
+ if (isEmpty(dataSource)) {
+ return invalidInputResponse("No DataSource specified");
+ } else if (!dataSource.equals(newConfig.getDataSource())) {
+ return invalidInputResponse(
+ "DataSource in spec[%s] does not match DataSource in path[%s]",
+ newConfig.getDataSource(), dataSource
+ );
+ }
+
+ if (scheduler.isEnabled()) {
+ final Response supervisorResponse =
supervisorResource.updateSupervisorSpec(
+ new CompactionSupervisorSpec(newConfig, false, scheduler),
+ true,
+ req
+ );
+
+ if (supervisorResponse.getStatus() >= 200 &&
supervisorResponse.getStatus() < 300) {
+ return Response.status(supervisorResponse.getStatus()).build();
+ } else {
+ return supervisorResponse;
+ }
+ } else {
+ return
buildResponse(coordinatorClient.updateDatasourceCompactionConfig(newConfig));
+ }
+ }
+
+ @GET
+ @Path("/config/datasources/{dataSource}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ResourceFilters(DatasourceResourceFilter.class)
+ public Response getDatasourceCompactionConfig(
+ @PathParam("dataSource") String dataSource
+ )
+ {
+ if (isEmpty(dataSource)) {
+ return invalidInputResponse("No DataSource Specified");
+ }
+
+ if (scheduler.isEnabled()) {
+ final String supervisorId = getCompactionSupervisorId(dataSource);
+ final Response supervisorResponse =
supervisorResource.specGet(supervisorId);
+
+ if (supervisorResponse.getStatus() >= 200 &&
supervisorResponse.getStatus() < 300) {
+ final Object spec = supervisorResponse.getEntity();
+ if (spec instanceof CompactionSupervisorSpec) {
+ return Response.ok(((CompactionSupervisorSpec)
spec).getSpec()).build();
+ } else {
+ return ServletResourceUtils.buildErrorResponseFrom(
+ InternalServerError.exception(
+ "Supervisor spec for ID[%s] is of unknown type[%s]",
+ supervisorId, spec == null ? null :
spec.getClass().getSimpleName()
+ )
+ );
+ }
+ } else {
+ return supervisorResponse;
+ }
+ } else {
+ return
buildResponse(coordinatorClient.getDatasourceCompactionConfig(dataSource));
+ }
+ }
+
+ @DELETE
+ @Path("/config/datasources/{dataSource}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ResourceFilters(DatasourceResourceFilter.class)
+ public Response deleteCompactionConfig(
+ @PathParam("dataSource") String dataSource,
+ @Context HttpServletRequest req
Review Comment:
## Useless parameter
The parameter 'req' is never used.
[Show more
details](https://github.com/apache/druid/security/code-scanning/8775)
--
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]