kfaraz commented on code in PR #16768:
URL: https://github.com/apache/druid/pull/16768#discussion_r1728379137
##########
server/src/main/java/org/apache/druid/server/http/CompactionResource.java:
##########
@@ -100,4 +114,31 @@ public Response getCompactionSnapshotForDataSource(
}
return Response.ok(ImmutableMap.of("latestStatus", snapshots)).build();
}
+
+ @POST
+ @Path("/simulate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response simulateClusterCompactionConfigUpdate(
+ ClusterCompactionConfig updatePayload
+ )
+ {
+ if (compactionSupervisorsConfig.isEnabled()) {
+ return buildErrorResponseWhenRunningAsSupervisor();
+ }
+
+ return Response.ok().entity(
+ coordinator.simulateRunWithConfigUpdate(updatePayload)
+ ).build();
+ }
+
+ private Response buildErrorResponseWhenRunningAsSupervisor()
+ {
+ return Response.status(Response.Status.SERVICE_UNAVAILABLE).entity(
+ ImmutableMap.of(
+ "error",
+ "Compaction has been disabled on the Coordinator."
+ + " Use Overlord APIs to fetch compaction status."
+ )
+ ).build();
+ }
Review Comment:
If we just log a warning, we might return stale information from the
coordinator.
Returning 302 would have sufficed if the path was the same for the two
resources, but one path has prefix `/druid/coordinator/v1/compaction` and the
other has `/druid/v1/indexer/compaction`.
The Druid clients `DruidLeaderClient` and `ServiceClientImpl` handle
redirects but only update the service location and not the path.
Another option could be to just not do anything at the router, and simply
use `OverlordClient` on the coordinator side and forward requests to the
overlord if compaction supervisors are enabled. Let me know what you think.
--
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]