clintropolis commented on a change in pull request #6272: Add
suspend|resume|terminate all supervisors endpoints.
URL: https://github.com/apache/incubator-druid/pull/6272#discussion_r221384075
##########
File path:
indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorResource.java
##########
@@ -378,23 +407,31 @@ private Response specSuspendOrResume(final String id,
boolean suspend)
{
return asLeaderWithSupervisorManager(
manager -> {
- Optional<SupervisorSpec> spec = manager.getSupervisorSpec(id);
- if (!spec.isPresent()) {
- return Response.status(Response.Status.NOT_FOUND)
- .entity(ImmutableMap.of("error",
StringUtils.format("[%s] does not exist", id)))
- .build();
- }
-
- if (spec.get().isSuspended() == suspend) {
- final String errMsg =
- StringUtils.format("[%s] is already %s", id, suspend ?
"suspended" : "running");
- return Response.status(Response.Status.BAD_REQUEST)
+ if (manager.suspendOrResumeSupervisor(id, suspend)) {
+ Optional<SupervisorSpec> spec = manager.getSupervisorSpec(id);
+ return Response.ok(spec.get()).build();
+ } else {
+ Optional<SupervisorSpec> spec = manager.getSupervisorSpec(id);
+ final Response.Status status = spec.isPresent() ?
Response.Status.BAD_REQUEST : Response.Status.NOT_FOUND;
+ final String errMsg = spec.isPresent() ? StringUtils.format(
+ "[%s] is already %s",
+ id,
+ suspend ? "suspended" : "running"
+ ) : StringUtils.format("[%s] does not exist", id);
+ return Response.status(status)
.entity(ImmutableMap.of("error", errMsg))
.build();
}
- manager.suspendOrResumeSupervisor(id, suspend);
- spec = manager.getSupervisorSpec(id);
- return Response.ok(spec.get()).build();
+ }
+ );
+ }
+
+ private Response suspendOrResumeAll(boolean suspend)
+ {
+ return asLeaderWithSupervisorManager(
+ manager -> {
+ manager.suspendOrResumeAllSupervisors(suspend);
+ return Response.ok(ImmutableMap.of("status", "success")).build();
Review comment:
It seems like it could be useful to return the list of spec ids which
successfully had a state change for this method and terminate all, but I don't
feel strongly about it
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]