mirror of https://github.com/apache/druid.git
IndexerCoordinatorResource: Return 404 with proper json for status not found
This commit is contained in:
parent
1a2135a0ea
commit
407e413a90
|
@ -140,12 +140,7 @@ public class IndexerCoordinatorResource
|
||||||
@Produces("application/json")
|
@Produces("application/json")
|
||||||
public Response getTaskStatus(@PathParam("taskid") String taskid)
|
public Response getTaskStatus(@PathParam("taskid") String taskid)
|
||||||
{
|
{
|
||||||
final Optional<TaskStatus> status = taskStorageQueryAdapter.getSameGroupMergedStatus(taskid);
|
return optionalTaskResponse(taskid, "status", taskStorageQueryAdapter.getSameGroupMergedStatus(taskid));
|
||||||
if (!status.isPresent()) {
|
|
||||||
return Response.status(Response.Status.NOT_FOUND).build();
|
|
||||||
} else {
|
|
||||||
return Response.ok().entity(status.get()).build();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
|
@ -349,6 +344,17 @@ public class IndexerCoordinatorResource
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T> Response optionalTaskResponse(String taskid, String objectType, Optional<T> x) {
|
||||||
|
final Map<String, Object> 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 <T> Response asLeaderWith(Optional<T> x, Function<T, Response> f)
|
public <T> Response asLeaderWith(Optional<T> x, Function<T, Response> f)
|
||||||
{
|
{
|
||||||
if (x.isPresent()) {
|
if (x.isPresent()) {
|
||||||
|
|
Loading…
Reference in New Issue