diff --git a/merger/src/main/java/com/metamx/druid/merger/coordinator/http/IndexerCoordinatorResource.java b/merger/src/main/java/com/metamx/druid/merger/coordinator/http/IndexerCoordinatorResource.java index 8fb4211d7bd..3a3a9b4930a 100644 --- a/merger/src/main/java/com/metamx/druid/merger/coordinator/http/IndexerCoordinatorResource.java +++ b/merger/src/main/java/com/metamx/druid/merger/coordinator/http/IndexerCoordinatorResource.java @@ -140,12 +140,7 @@ public class IndexerCoordinatorResource @Produces("application/json") public Response getTaskStatus(@PathParam("taskid") String taskid) { - final Optional status = taskStorageQueryAdapter.getSameGroupMergedStatus(taskid); - if (!status.isPresent()) { - return Response.status(Response.Status.NOT_FOUND).build(); - } else { - return Response.ok().entity(status.get()).build(); - } + return optionalTaskResponse(taskid, "status", taskStorageQueryAdapter.getSameGroupMergedStatus(taskid)); } @GET @@ -349,6 +344,17 @@ public class IndexerCoordinatorResource } } + public Response optionalTaskResponse(String taskid, String objectType, Optional x) { + final Map results = Maps.newHashMap(); + results.put("task", taskid); + if (x.isPresent()) { + results.put(objectType, x.get()); + return Response.status(Response.Status.OK).entity(results).build(); + } else { + return Response.status(Response.Status.NOT_FOUND).entity(results).build(); + } + } + public Response asLeaderWith(Optional x, Function f) { if (x.isPresent()) {