.setStatus(Health.Status.RED)
.addCause("Elasticsearch status is RED")
.build();
- private static final Health RED_HEALTH_EXCEPTION_OCCURED = newHealthCheckBuilder()
+ private static final Health RED_HEALTH_UNAVAILABLE = newHealthCheckBuilder()
.setStatus(Health.Status.RED)
.addCause("Elasticsearch status is RED (unavailable)")
.build();
Health checkEsStatus() {
try {
ClusterHealthStatus esStatus = esClient.prepareClusterStats().get().getStatus();
+ if (esStatus == null) {
+ return RED_HEALTH_UNAVAILABLE;
+ }
switch (esStatus) {
case GREEN:
return Health.GREEN;
}
} catch (Exception e) {
LOG.error("Failed to query ES status", e);
- return RED_HEALTH_EXCEPTION_OCCURED;
+ return RED_HEALTH_UNAVAILABLE;
}
}
}
@Test
public void check_ignores_NodeHealth_arg_and_returns_RED_with_cause_if_an_exception_occurs_checking_ES_cluster_status() {
EsClient esClient = Mockito.mock(EsClient.class);
- when(esClient.prepareClusterStats()).thenThrow(new RuntimeException("Faking an exception occuring while using the EsClient"));
+ when(esClient.prepareClusterStats()).thenThrow(new RuntimeException("Faking an exception occurring while using the EsClient"));
Health health = new EsStatusNodeCheck(esClient).check();