@Override public ClusterHealthStatus getClusterHealthStatus() { return getTransportClient().admin().cluster() .health(new ClusterHealthRequest().waitForStatus(ClusterHealthStatus.YELLOW).timeout(timeValueSeconds(30))) .actionGet().getStatus(); }
public ClusterHealthRequestBuilder setWaitForStatus(ClusterHealthStatus waitForStatus) { request.waitForStatus(waitForStatus); return this; }
public ClusterHealthRequest waitForYellowStatus() { return waitForStatus(ClusterHealthStatus.YELLOW); }
public ClusterHealthRequest waitForGreenStatus() { return waitForStatus(ClusterHealthStatus.GREEN); }
static int prepareResponse(final ClusterHealthRequest request, final ClusterHealthResponse response, final ClusterState clusterState, final IndexNameExpressionResolver indexNameExpressionResolver) { int waitForCounter = 0; if (request.waitForStatus() != null && response.getStatus().value() <= request.waitForStatus().value()) { waitForCounter++;
public ClusterHealthRequestBuilder setWaitForStatus(ClusterHealthStatus waitForStatus) { request.waitForStatus(waitForStatus); return this; }
public ClusterHealthRequestBuilder setWaitForStatus(ClusterHealthStatus waitForStatus) { request.waitForStatus(waitForStatus); return this; }
public ClusterHealthRequestBuilder setWaitForStatus(ClusterHealthStatus waitForStatus) { request.waitForStatus(waitForStatus); return this; }
public ClusterHealthRequestBuilder setWaitForStatus(ClusterHealthStatus waitForStatus) { request.waitForStatus(waitForStatus); return this; }
public ClusterHealthRequest waitForGreenStatus() { return waitForStatus(ClusterHealthStatus.GREEN); }
public ClusterHealthRequest waitForYellowStatus() { return waitForStatus(ClusterHealthStatus.YELLOW); }
public ClusterHealthRequest waitForYellowStatus() { return waitForStatus(ClusterHealthStatus.YELLOW); }
public ClusterHealthRequest waitForGreenStatus() { return waitForStatus(ClusterHealthStatus.GREEN); }
public ClusterHealthRequest waitForYellowStatus() { return waitForStatus(ClusterHealthStatus.YELLOW); }
private void executeHealth(final ClusterHealthRequest request, final ActionListener<ClusterHealthResponse> listener) { int waitFor = 0; if (request.waitForStatus() != null) { waitFor++;
@Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { ClusterHealthRequest clusterHealthRequest = clusterHealthRequest(Strings.splitStringByCommaToArray(request.param("index"))); clusterHealthRequest.local(request.paramAsBoolean("local", clusterHealthRequest.local())); clusterHealthRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterHealthRequest.masterNodeTimeout())); clusterHealthRequest.timeout(request.paramAsTime("timeout", clusterHealthRequest.timeout())); String waitForStatus = request.param("wait_for_status"); if (waitForStatus != null) { clusterHealthRequest.waitForStatus(ClusterHealthStatus.valueOf(waitForStatus.toUpperCase(Locale.ROOT))); } clusterHealthRequest.waitForNoRelocatingShards( request.paramAsBoolean("wait_for_no_relocating_shards", clusterHealthRequest.waitForNoRelocatingShards())); clusterHealthRequest.waitForNoInitializingShards( request.paramAsBoolean("wait_for_no_initializing_shards", clusterHealthRequest.waitForNoRelocatingShards())); if (request.hasParam("wait_for_relocating_shards")) { // wait_for_relocating_shards has been removed in favor of wait_for_no_relocating_shards throw new IllegalArgumentException("wait_for_relocating_shards has been removed, " + "use wait_for_no_relocating_shards [true/false] instead"); } String waitForActiveShards = request.param("wait_for_active_shards"); if (waitForActiveShards != null) { clusterHealthRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards)); } clusterHealthRequest.waitForNodes(request.param("wait_for_nodes", clusterHealthRequest.waitForNodes())); if (request.param("wait_for_events") != null) { clusterHealthRequest.waitForEvents(Priority.valueOf(request.param("wait_for_events").toUpperCase(Locale.ROOT))); } return channel -> client.admin().cluster().health(clusterHealthRequest, new RestStatusToXContentListener<>(channel)); }
public static void waitForCluster(Client client, ClusterHealthStatus statusThreshold, String timeout) throws UnableToStartException { try { ClusterHealthResponse healthResponse = (ClusterHealthResponse) client .execute(ClusterHealthAction.INSTANCE, new ClusterHealthRequest().waitForStatus(statusThreshold).timeout(timeout)) .actionGet(); if (healthResponse != null && healthResponse.isTimedOut()) { throw new UnableToStartException("cluster state is " + healthResponse.getStatus().name() + " and not " + statusThreshold.name() + ", from here on, everything will fail!"); } } catch (ElasticsearchTimeoutException e) { throw new UnableToStartException( "timeout, cluster does not respond to health request, cowardly refusing to continue with operations"); } }
@Override public ActionFuture<ClusterHealthResponse> execute(final ClusterAdminClient admin) { return admin.health(Requests.clusterHealthRequest().waitForStatus( ClusterHealthStatus.YELLOW)); } });
@Override public boolean isSearchEngineReady() { ClusterHealthStatus status = new ClusterHealthRequestBuilder(client, ClusterHealthAction.INSTANCE) .setIndices(configuration.getIndexName()) .setTimeout(new TimeValue(configuration.getTimeoutMillis(), TimeUnit.MILLISECONDS)) .request() .waitForStatus(); return status != ClusterHealthStatus.RED; }
@Override public ClusterHealthStatus getClusterHealthStatus(TransportClient transportClient) { return transportClient.admin().cluster() .health(new ClusterHealthRequest().waitForStatus(ClusterHealthStatus.YELLOW).timeout(timeValueSeconds(30))) .actionGet().getStatus(); } }