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_r221383521
########## 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( Review comment: I think this is too much stuff for a ternary assignment, ``` Response.Status status; String errMsg; if (spec.isPresent()) { ... ``` would be easier to follow and wouldn't double check `spec.isPresent` ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org