private void waitForIndexYellow(String index) { Client nativeClient = esClient.nativeClient(); ClusterHealthAction.INSTANCE.newRequestBuilder(nativeClient).setIndices(index).setWaitForYellowStatus().get(TimeValue.timeValueMinutes(10)); }
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); }
adminClient = client.admin(); adminClient.cluster().prepareHealth() .setWaitForYellowStatus().execute().actionGet();
.prepareHealth().setWaitForYellowStatus().execute().actionGet(); System.out.println("ElasticSearch Health Check " + actionGet);
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();
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()); } } }
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()); } } }
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(); }
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(); }
@Override public void open() { // Wait for Yellow status client().admin().cluster() .prepareHealth() .setWaitForYellowStatus() .setTimeout(TimeValue.timeValueMinutes(1)) .execute() .actionGet(); }
@Override public void open() { // Wait for Yellow status client().admin().cluster() .prepareHealth() .setWaitForYellowStatus() .setTimeout(TimeValue.timeValueMinutes(1)) .execute() .actionGet(); }
@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); }
@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); }
public Client client() { client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet(); return client; }
@Override public boolean isReady() { return node != null && node.client().admin().cluster().prepareHealth() .setWaitForYellowStatus() .setTimeout(TimeValue.timeValueSeconds(30L)) .get() .getStatus() != ClusterHealthStatus.RED; }
private void waitForIndexYellow(String index) { Client nativeClient = esClient.nativeClient(); ClusterHealthAction.INSTANCE.newRequestBuilder(nativeClient).setIndices(index).setWaitForYellowStatus().get(TimeValue.timeValueMinutes(10)); }
@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(); } }
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); }
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)); }
public void waitForYellowStatus(Client client) throws ExecutionException, InterruptedException { client.admin().cluster().prepareHealth().setWaitForYellowStatus().setTimeout(new TimeValue(10, TimeUnit.SECONDS)).execute().get(); } }