@Test void checkShouldReturnHealthyWhenElasticSearchClusterHealthStatusIsYellow() { FakeClusterHealthResponse response = new FakeClusterHealthResponse(ClusterHealthStatus.YELLOW); assertThat(healthCheck.toHealthCheckResult(response).isHealthy()).isTrue(); }
@VisibleForTesting Result toHealthCheckResult(ClusterHealthResponse response) { switch (response.getStatus()) { case GREEN: case YELLOW: return Result.healthy(COMPONENT_NAME); case RED: return Result.unhealthy(COMPONENT_NAME, response.getClusterName() + " status is RED"); default: throw new NotImplementedException("Un-handled ElasticSearch cluster status"); } }
ElasticSearchHealthCheck implements HealthCheck { @VisibleForTesting Result toHealthCheckResult(ClusterHealthResponse response) { switch (response.getStatus()) { case GREEN: case YELLOW: return Result.healthy(COMPONENT_NAME); case RED: return Result.unhealthy(COMPONENT_NAME, response.getClusterName() + " status is RED"); default: throw new NotImplementedException("Un-handled ElasticSearch cluster status"); } } }
ElasticSearchHealthCheck implements HealthCheck { @VisibleForTesting Result toHealthCheckResult(ClusterHealthResponse response) { switch (response.getStatus()) { case GREEN: case YELLOW: return Result.healthy(COMPONENT_NAME); case RED: return Result.unhealthy(COMPONENT_NAME, response.getClusterName() + " status is RED"); default: throw new NotImplementedException("Un-handled ElasticSearch cluster status"); } } @Inject  ElasticSearchHealthCheck(ReactorElasticSearchClient client, Set<IndexName> indexNames); }
ElasticSearchHealthCheck implements HealthCheck { @VisibleForTesting Result toHealthCheckResult(ClusterHealthResponse response) { switch (response.getStatus()) { case GREEN: case YELLOW: return Result.healthy(COMPONENT_NAME); case RED: return Result.unhealthy(COMPONENT_NAME, response.getClusterName() + " status is RED"); default: throw new NotImplementedException("Un-handled ElasticSearch cluster status"); } } @Inject  ElasticSearchHealthCheck(ReactorElasticSearchClient client, Set<IndexName> indexNames); @Override ComponentName componentName(); @Override Mono<Result> check(); }
ElasticSearchHealthCheck implements HealthCheck { @VisibleForTesting Result toHealthCheckResult(ClusterHealthResponse response) { switch (response.getStatus()) { case GREEN: case YELLOW: return Result.healthy(COMPONENT_NAME); case RED: return Result.unhealthy(COMPONENT_NAME, response.getClusterName() + " status is RED"); default: throw new NotImplementedException("Un-handled ElasticSearch cluster status"); } } @Inject  ElasticSearchHealthCheck(ReactorElasticSearchClient client, Set<IndexName> indexNames); @Override ComponentName componentName(); @Override Mono<Result> check();  }