org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse.isTimedOut()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse.isTimedOut()方法的一些代码示例,展示了ClusterHealthResponse.isTimedOut()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClusterHealthResponse.isTimedOut()方法的具体详情如下:
包路径:org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse
类名称:ClusterHealthResponse
方法名:isTimedOut

ClusterHealthResponse.isTimedOut介绍

[英]true if the waitForXXX has timeout out and did not match.
[中]如果waitForXXX超时且不匹配,则为true。

代码示例

代码示例来源:origin: loklak/loklak_server

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;
}

代码示例来源:origin: floragunncom/search-guard

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.");

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public RestStatus status() {
  return isTimedOut() ? RestStatus.REQUEST_TIMEOUT : RestStatus.OK;
}

代码示例来源:origin: floragunncom/search-guard

.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");

代码示例来源:origin: yacy/yacy_grid_mcp

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;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

@Override
public RestStatus status() {
  return isTimedOut() ? RestStatus.REQUEST_TIMEOUT : RestStatus.OK;
}

代码示例来源:origin: harbby/presto-connectors

@Override
public RestStatus status() {
  return isTimedOut() ? RestStatus.REQUEST_TIMEOUT : RestStatus.OK;
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

@Override
public RestStatus status() {
  return isTimedOut() ? RestStatus.REQUEST_TIMEOUT : RestStatus.OK;
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public RestStatus status() {
  return isTimedOut() ? RestStatus.REQUEST_TIMEOUT : RestStatus.OK;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@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;
}

代码示例来源:origin: com.strapdata.elasticsearch.test/framework

public static void assertNoTimeout(ClusterHealthResponse response) {
  assertThat("ClusterHealthResponse has timed out - returned: [" + response + "]", response.isTimedOut(), is(false));
}

代码示例来源:origin: apache/metron

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");
 }
}

代码示例来源:origin: org.neolumin.vertexium/vertexium-elasticsearch-base

@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);
  }
}

代码示例来源:origin: org.securegraph/securegraph-elasticsearch-base

@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);
  }
}

代码示例来源:origin: lumifyio/securegraph

@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);
  }
}

代码示例来源:origin: unipop-graph/unipop

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());
  }
}

代码示例来源:origin: com.strapdata.elasticsearch.test/framework

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());
}

代码示例来源:origin: com.strapdata.elasticsearch.test/framework

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());
  }
}

代码示例来源:origin: com.strapdata.elasticsearch.test/framework

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());
}

代码示例来源:origin: codelibs/elasticsearch-cluster-runner

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();
}

相关文章

微信公众号

最新文章

更多