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

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

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

ClusterHealthRequestBuilder.setWaitForYellowStatus介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

private void waitForIndexYellow(String index) {
 Client nativeClient = esClient.nativeClient();
 ClusterHealthAction.INSTANCE.newRequestBuilder(nativeClient).setIndices(index).setWaitForYellowStatus().get(TimeValue.timeValueMinutes(10));
}

代码示例来源:origin: thinkaurelius/titan

public ElasticSearchIndex(Configuration config) {
  indexName = config.get(INDEX_NAME);
  useDeprecatedIgnoreUnmapped = config.get(USE_EDEPRECATED_IGNORE_UNMAPPED_OPTION);
  checkExpectedClientVersion();
  final ElasticSearchSetup.Connection c;
  if (!config.has(INTERFACE)) {
    c = legacyConfiguration(config);
  } else {
    c = interfaceConfiguration(config);
  }
  node = c.getNode();
  client = c.getClient();
  maxResultsSize = config.get(INDEX_MAX_RESULT_SET_SIZE);
  log.debug("Configured ES query result set max size to {}", maxResultsSize);
  client.admin().cluster().prepareHealth().setTimeout(config.get(HEALTH_REQUEST_TIMEOUT))
      .setWaitForYellowStatus().execute().actionGet();
  checkForOrCreateIndex(config);
}

代码示例来源:origin: stagemonitor/stagemonitor

adminClient = client.admin();
adminClient.cluster().prepareHealth()
    .setWaitForYellowStatus().execute().actionGet();

代码示例来源:origin: larsga/Duke

.prepareHealth().setWaitForYellowStatus().execute().actionGet();
System.out.println("ElasticSearch Health Check " + actionGet);

代码示例来源:origin: stackoverflow.com

ClusterHealthRequestBuilder healthRequest = txClient.admin().cluster().prepareHealth();
healthRequest.setIndices(newIndexName); // only request health of this index...
healthRequest.setWaitForYellowStatus();
ClusterHealthResponse healthResponse = healthRequest.execute().actionGet();
System.out.printf("status: %s%n", healthResponse.status());
// After that you checking
SearchResponse response = txClient.prepareSearch(some_values).setTypes(some_value)
             .execute().actionGet();

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

public static void waitForAvailable(final Client client,
      final String... indices) {
    final ClusterHealthResponse response = client.admin().cluster()
        .prepareHealth(indices).setWaitForYellowStatus().execute()
        .actionGet();
    final List<String> failures = response.getValidationFailures();
    if (!failures.isEmpty()) {
      throw new ElasticsearchException(
          "Cluster is not available: " + failures.toString());
    }
  }
}

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

public static void waitForAvailable(final Client client,
      final String... indices) {
    final ClusterHealthResponse response = client.admin().cluster()
        .prepareHealth(indices).setWaitForYellowStatus().execute()
        .actionGet();
    final List<String> failures = response.getAllValidationFailures();
    if (!failures.isEmpty()) {
      throw new EsUtilSystemException("Cluster is not available: "
          + failures.toString());
    }
  }
}

代码示例来源:origin: ujmp/universal-java-matrix-package

private synchronized void createIndex() {
  CreateIndexResponse response = client.admin().indices().create(new CreateIndexRequest(index)).actionGet();
  if (!response.isAcknowledged()) {
    throw new RuntimeException("cannot create index " + index);
  }
  client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
}

代码示例来源:origin: ujmp/universal-java-matrix-package

public synchronized void deleteIndex() {
  DeleteIndexResponse response = client.admin().indices().delete(new DeleteIndexRequest(index)).actionGet();
  if (!response.isAcknowledged()) {
    throw new RuntimeException("cannot delete index " + index);
  }
  client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
}

代码示例来源:origin: tlrx/elasticsearch-test

@Override
public void open() {
  // Wait for Yellow status
  client().admin().cluster()
      .prepareHealth()
      .setWaitForYellowStatus()
      .setTimeout(TimeValue.timeValueMinutes(1))
      .execute()
      .actionGet();
}

代码示例来源:origin: com.github.tlrx/elasticsearch-test

@Override
public void open() {
  // Wait for Yellow status
  client().admin().cluster()
      .prepareHealth()
      .setWaitForYellowStatus()
      .setTimeout(TimeValue.timeValueMinutes(1))
      .execute()
      .actionGet();
}

代码示例来源:origin: ru.yandex.qatools.embed/embedded-services

@Override
public void doStart() {
  ImmutableSettings.Builder elasticsearchSettings = ImmutableSettings.settingsBuilder();
  for (String key : settings.keySet()) {
    elasticsearchSettings.put(key, String.valueOf(settings.get(key)));
  }
  this.node = nodeBuilder().local(true).settings(elasticsearchSettings.build()).node();
  node.client().admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet(initTimeout);
}

代码示例来源:origin: yandex-qatools/embedded-services

@Override
public void doStart() {
  ImmutableSettings.Builder elasticsearchSettings = ImmutableSettings.settingsBuilder();
  for (String key : settings.keySet()) {
    elasticsearchSettings.put(key, String.valueOf(settings.get(key)));
  }
  this.node = nodeBuilder().local(true).settings(elasticsearchSettings.build()).node();
  node.client().admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet(initTimeout);
}

代码示例来源:origin: apache/attic-polygene-java

public Client client()
{
  client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
  return client;
}

代码示例来源:origin: org.codehaus.sonar/sonar-search

@Override
public boolean isReady() {
 return node != null && node.client().admin().cluster().prepareHealth()
  .setWaitForYellowStatus()
  .setTimeout(TimeValue.timeValueSeconds(30L))
  .get()
  .getStatus() != ClusterHealthStatus.RED;
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

private void waitForIndexYellow(String index) {
 Client nativeClient = esClient.nativeClient();
 ClusterHealthAction.INSTANCE.newRequestBuilder(nativeClient).setIndices(index).setWaitForYellowStatus().get(TimeValue.timeValueMinutes(10));
}

代码示例来源:origin: com.github.tlrx/elasticsearch-test

@Override
public void open() {
  if (node == null || node.isClosed()) {
    // Build and start the node
    node = NodeBuilder.nodeBuilder().settings(buildNodeSettings()).node();
    // Get a client
    client = node.client();
    // Wait for Yellow status
    client.admin().cluster()
        .prepareHealth()
        .setWaitForYellowStatus()
        .setTimeout(TimeValue.timeValueMinutes(1))
        .execute()
        .actionGet();
  }
}

代码示例来源:origin: org.hawkular.titan/titan-es

public ElasticSearchIndex(Configuration config) {
  indexName = config.get(INDEX_NAME);
  checkExpectedClientVersion();
  final ElasticSearchSetup.Connection c;
  if (!config.has(INTERFACE)) {
    c = legacyConfiguration(config);
  } else {
    c = interfaceConfiguration(config);
  }
  node = c.getNode();
  client = c.getClient();
  maxResultsSize = config.get(INDEX_MAX_RESULT_SET_SIZE);
  log.debug("Configured ES query result set max size to {}", maxResultsSize);
  client.admin().cluster().prepareHealth().setTimeout(config.get(HEALTH_REQUEST_TIMEOUT))
      .setWaitForYellowStatus().execute().actionGet();
  checkForOrCreateIndex(config);
}

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

protected IndexService createIndex(String index, CreateIndexRequestBuilder createIndexRequestBuilder) {
  assertAcked(createIndexRequestBuilder.get());
  // Wait for the index to be allocated so that cluster state updates don't override
  // changes that would have been done locally
  ClusterHealthRequestBuilder builder = client().admin().cluster().prepareHealth(index);
  builder.setWaitForYellowStatus()
    .setWaitForEvents(Priority.LANGUID)
    .setWaitForNoRelocatingShards(true);
  ClusterHealthResponse health = builder.get();
  assertThat(health.getStatus(), lessThanOrEqualTo(ClusterHealthStatus.YELLOW));
  assertThat("Cluster must be a single node cluster", health.getNumberOfDataNodes(), equalTo(1));
  IndicesService instanceFromNode = getInstanceFromNode(IndicesService.class);
  return instanceFromNode.indexServiceSafe(resolveIndex(index));
}

代码示例来源:origin: meltwater/elasticsearch-batch-percolator

public void waitForYellowStatus(Client client) throws ExecutionException, InterruptedException {
    client.admin().cluster().prepareHealth().setWaitForYellowStatus().setTimeout(new TimeValue(10, TimeUnit.SECONDS)).execute().get();
  }
}

相关文章