Add /readiness to HistoricalResource (#4916)

* Add /loadStatusCode to HistoricalResource

* Address comments

* Fixes
This commit is contained in:
Roman Leventov 2017-10-11 22:35:52 -05:00 committed by Gian Merlino
parent 56fb11ce0b
commit 7a9940d624
2 changed files with 19 additions and 1 deletions

View File

@ -50,4 +50,11 @@ Returns the Druid version, loaded extensions, memory used, total memory and othe
* `/druid/historical/v1/loadstatus`
Returns a flag indicating if all segments in the local cache have been loaded. This can be used to know when a historical node is ready to be queried after a restart.
Returns JSON of the form `{"cacheInitialized":<value>}`, where value is either `true` or `false` indicating if all
segments in the local cache have been loaded. This can be used to know when a historical node is ready
to be queried after a restart.
* `/druid/historical/v1/readiness`
Similar to `/druid/historical/v1/loadstatus`, but instead of returning JSON with a flag, responses 200 OK if segments
in the local cache have been loaded, and 503 SERVICE UNAVAILABLE, if they haven't.

View File

@ -52,4 +52,15 @@ public class HistoricalResource
{
return Response.ok(ImmutableMap.of("cacheInitialized", coordinator.isStarted())).build();
}
@GET
@Path("/readiness")
public Response getReadiness()
{
if (coordinator.isStarted()) {
return Response.ok().build();
} else {
return Response.status(Response.Status.SERVICE_UNAVAILABLE).build();
}
}
}