private boolean waitForStatus(ClusterHealthStatus status) { ClusterHealthRequestBuilder healthRequest = client.admin().cluster().prepareHealth(); healthRequest.setTimeout(TIMEOUT); healthRequest.setWaitForStatus(status); ClusterHealthResponse response = (ClusterHealthResponse) healthRequest.execute().actionGet(); return !response.isTimedOut(); }
@Override public ClusterHealthResponse getClusterHealthResponse(long timeout) { Client client = getClient(); AdminClient adminClient = client.admin(); ClusterAdminClient clusterAdminClient = adminClient.cluster(); ClusterHealthRequestBuilder clusterHealthRequestBuilder = clusterAdminClient.prepareHealth(); clusterHealthRequestBuilder.setTimeout(TimeValue.timeValueMillis(timeout)); clusterHealthRequestBuilder.setWaitForYellowStatus(); Future<ClusterHealthResponse> future = clusterHealthRequestBuilder.execute(); try { return future.get(); } catch (Exception e) { throw new IllegalStateException(e); } }