public boolean wait_ready(long maxtimemillis, ClusterHealthStatus status) { // wait for yellow status long start = System.currentTimeMillis(); boolean is_ready; do { // wait for yellow status ClusterHealthResponse health = elasticsearchClient.admin().cluster().prepareHealth().setWaitForStatus(status).execute().actionGet(); is_ready = !health.isTimedOut(); if (!is_ready && System.currentTimeMillis() - start > maxtimemillis) return false; } while (!is_ready); return is_ready; }
final boolean timedOut = chr.isTimedOut(); ClusterHealthResponse chrsg = tc.admin().cluster().health(new ClusterHealthRequest(index)).actionGet(); if (chrsg.isTimedOut()) { System.out.println("ERR: Timed out while waiting for "+index+" index state.");
@Override public RestStatus status() { return isTimedOut() ? RestStatus.REQUEST_TIMEOUT : RestStatus.OK; }
.setWaitForStatus(status).setTimeout(timeout).setMasterNodeTimeout(timeout).setWaitForNodes("" + expectedNodeCount).execute() .actionGet(); if (healthResponse.isTimedOut()) { throw new IOException("cluster state is " + healthResponse.getStatus().name() + " with " + healthResponse.getNumberOfNodes() + " nodes");
public boolean wait_ready(long maxtimemillis, ClusterHealthStatus status) { // wait for yellow status long start = System.currentTimeMillis(); boolean is_ready; do { // wait for yellow status ClusterHealthResponse health = elasticsearchClient.admin().cluster().prepareHealth().setWaitForStatus(status).execute().actionGet(); is_ready = !health.isTimedOut(); if (!is_ready && System.currentTimeMillis() - start > maxtimemillis) return false; } while (!is_ready); return is_ready; }
@Override public RestStatus status() { return isTimedOut() ? RestStatus.REQUEST_TIMEOUT : RestStatus.OK; }
@Override public RestStatus status() { return isTimedOut() ? RestStatus.REQUEST_TIMEOUT : RestStatus.OK; }
@Override public RestStatus status() { return isTimedOut() ? RestStatus.REQUEST_TIMEOUT : RestStatus.OK; }
@Override public RestStatus status() { return isTimedOut() ? RestStatus.REQUEST_TIMEOUT : RestStatus.OK; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field(CLUSTER_NAME, getClusterName()); builder.field(STATUS, getStatus().name().toLowerCase(Locale.ROOT)); builder.field(TIMED_OUT, isTimedOut()); builder.field(NUMBER_OF_NODES, getNumberOfNodes()); builder.field(NUMBER_OF_DATA_NODES, getNumberOfDataNodes()); builder.field(ACTIVE_PRIMARY_SHARDS, getActivePrimaryShards()); builder.field(ACTIVE_SHARDS, getActiveShards()); builder.field(RELOCATING_SHARDS, getRelocatingShards()); builder.field(INITIALIZING_SHARDS, getInitializingShards()); builder.field(UNASSIGNED_SHARDS, getUnassignedShards()); builder.field(DELAYED_UNASSIGNED_SHARDS, getDelayedUnassignedShards()); builder.field(NUMBER_OF_PENDING_TASKS, getNumberOfPendingTasks()); builder.field(NUMBER_OF_IN_FLIGHT_FETCH, getNumberOfInFlightFetch()); builder.humanReadableField(TASK_MAX_WAIT_TIME_IN_QUEUE_IN_MILLIS, TASK_MAX_WAIT_TIME_IN_QUEUE, getTaskMaxWaitingTime()); builder.percentageField(ACTIVE_SHARDS_PERCENT_AS_NUMBER, ACTIVE_SHARDS_PERCENT, getActiveShardsPercent()); String level = params.param("level", "cluster"); boolean outputIndices = "indices".equals(level) || "shards".equals(level); if (outputIndices) { builder.startObject(INDICES); for (ClusterIndexHealth indexHealth : clusterStateHealth.getIndices().values()) { indexHealth.toXContent(builder, params); } builder.endObject(); } builder.endObject(); return builder; }
public static void assertNoTimeout(ClusterHealthResponse response) { assertThat("ClusterHealthResponse has timed out - returned: [" + response + "]", response.isTimedOut(), is(false)); }
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"); } }
@SuppressWarnings("unused") protected void createIndex(String indexName, boolean storeSourceData) throws IOException { CreateIndexResponse createResponse = client.admin().indices().prepareCreate(indexName).execute().actionGet(); LOGGER.debug(createResponse.toString()); ClusterHealthResponse health = client.admin().cluster().prepareHealth(indexName) .setWaitForGreenStatus() .execute().actionGet(); LOGGER.debug("Index status: " + health.toString()); if (health.isTimedOut()) { LOGGER.warn("timed out waiting for green index status, for index: " + indexName); } }
@SuppressWarnings("unused") protected void createIndex(String indexName, boolean storeSourceData) throws IOException { CreateIndexResponse createResponse = client.admin().indices().prepareCreate(indexName).execute().actionGet(); LOGGER.debug(createResponse.toString()); ClusterHealthResponse health = client.admin().cluster().prepareHealth(indexName) .setWaitForGreenStatus() .execute().actionGet(); LOGGER.debug("Index status: " + health.toString()); if (health.isTimedOut()) { LOGGER.warn("timed out waiting for green index status, for index: " + indexName); } }
@SuppressWarnings("unused") protected void createIndex(String indexName, boolean storeSourceData) throws IOException { CreateIndexResponse createResponse = client.admin().indices().prepareCreate(indexName).execute().actionGet(); LOGGER.debug(createResponse.toString()); ClusterHealthResponse health = client.admin().cluster().prepareHealth(indexName) .setWaitForGreenStatus() .execute().actionGet(); LOGGER.debug("Index status: " + health.toString()); if (health.isTimedOut()) { LOGGER.warn("timed out waiting for green index status, for index: " + indexName); } }
public void checkHealth() { final ClusterHealthRequest clusterHealthRequest = new ClusterHealthRequest().timeout(TimeValue.timeValueSeconds(10)).waitForYellowStatus(); final ClusterHealthResponse clusterHealth = client.admin().cluster().health(clusterHealthRequest).actionGet(); if (clusterHealth.isTimedOut()) { System.out.println(clusterHealth.getStatus() + " status returned from cluster '" + client.admin().cluster().toString()); } }
protected void ensureNodeCount(InternalTestCluster cluster) { assertFalse("cluster failed to form after disruption was healed", cluster.client().admin().cluster().prepareHealth() .setWaitForNodes(String.valueOf(cluster.size())) .setWaitForNoRelocatingShards(true) .get().isTimedOut()); }
protected void ensureNodeCount(InternalTestCluster cluster) { assertFalse("cluster failed to form after disruption was healed", cluster.client().admin().cluster().prepareHealth() .setWaitForNodes(String.valueOf(cluster.size())) .setWaitForNoRelocatingShards(true) .get().isTimedOut()); } }
protected void startNode(long seed) throws Exception { ElassandraDaemon.instance.node(RandomizedContext.current().runWithPrivateRandomness(seed, this::newNode)); // we must wait for the node to actually be up and running. otherwise the node might have started, // elected itself master but might not yet have removed the // SERVICE_UNAVAILABLE/1/state not recovered / initialized block ClusterAdminClient clusterAdminClient = client().admin().cluster(); ClusterHealthRequestBuilder builder = clusterAdminClient.prepareHealth(); ClusterHealthResponse clusterHealthResponse = builder.setWaitForGreenStatus().get(); assertFalse(clusterHealthResponse.isTimedOut()); }
public ClusterHealthStatus waitForRelocation() { final ClusterHealthRequest request = Requests.clusterHealthRequest() .waitForNoRelocatingShards(true); final ClusterHealthResponse actionGet = client().admin().cluster() .health(request).actionGet(); if (actionGet.isTimedOut()) { onFailure("waitForRelocation timed out, cluster state:\n" + "\n" + client().admin().cluster().prepareState().get().getState() + "\n" + client().admin().cluster() .preparePendingClusterTasks().get(), actionGet); } return actionGet.getStatus(); }