本文整理了Java中org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder.execute()
方法的一些代码示例,展示了ClusterHealthRequestBuilder.execute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClusterHealthRequestBuilder.execute()
方法的具体详情如下:
包路径:org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder
类名称:ClusterHealthRequestBuilder
方法名:execute
暂无
代码示例来源: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: SonarSource/sonarqube
@Override
public ClusterHealthResponse get() {
Profiler profiler = Profiler.createIfTrace(EsClient.LOGGER).start();
try {
return super.execute().actionGet();
} catch (Exception e) {
throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
} finally {
if (profiler.isTraceEnabled()) {
profiler.stopTrace(toString());
}
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void execute_should_throw_an_unsupported_operation_exception() {
try {
es.client().prepareHealth().execute();
fail();
} catch (Exception e) {
assertThat(e).isInstanceOf(UnsupportedOperationException.class).hasMessage("execute() should not be called as it's used for asynchronous");
}
}
代码示例来源:origin: Netflix/conductor
@Override
public void setup() throws Exception {
elasticSearchClient.admin()
.cluster()
.prepareHealth()
.setWaitForGreenStatus()
.execute()
.get();
try {
initIndex();
updateLogIndexName();
Executors.newScheduledThreadPool(1)
.scheduleAtFixedRate(() -> updateLogIndexName(), 0, 1, TimeUnit.HOURS);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
//1. Create the required index
addIndex(indexName);
//2. Add Mappings for the workflow document type
addMappingToIndex(indexName, WORKFLOW_DOC_TYPE, "/mappings_docType_workflow.json");
//3. Add Mappings for task document type
addMappingToIndex(indexName, TASK_DOC_TYPE, "/mappings_docType_task.json");
}
代码示例来源: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: Netflix/conductor
@BeforeClass
public static void startServer() throws Exception {
System.setProperty(ElasticSearchConfiguration.EMBEDDED_PORT_PROPERTY_NAME, "9203");
System.setProperty(ElasticSearchConfiguration.ELASTIC_SEARCH_URL_PROPERTY_NAME, "localhost:9303");
configuration = new SystemPropertiesElasticSearchConfiguration();
String host = configuration.getEmbeddedHost();
int port = configuration.getEmbeddedPort();
String clusterName = configuration.getEmbeddedClusterName();
embeddedElasticSearch = new EmbeddedElasticSearchV5(clusterName, host, port);
embeddedElasticSearch.start();
ElasticSearchTransportClientProvider transportClientProvider =
new ElasticSearchTransportClientProvider(configuration);
elasticSearchClient = transportClientProvider.get();
elasticSearchClient.admin()
.cluster()
.prepareHealth()
.setWaitForGreenStatus()
.execute()
.get();
ObjectMapper objectMapper = new ObjectMapper();
indexDAO = new ElasticSearchDAOV5(elasticSearchClient, configuration, objectMapper);
}
代码示例来源:origin: floragunncom/search-guard
log.debug("waiting for cluster state {} and {} nodes", status.name(), expectedNodeCount);
final ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth()
.setWaitForStatus(status).setTimeout(timeout).setMasterNodeTimeout(timeout).setWaitForNodes("" + expectedNodeCount).execute()
.actionGet();
if (healthResponse.isTimedOut()) {
代码示例来源: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: larsga/Duke
.prepareHealth().setWaitForYellowStatus().execute().actionGet();
System.out.println("ElasticSearch Health Check " + actionGet);
代码示例来源:origin: io.fabric8.insight/insight-elasticsearch-factory
@Override
public ClusterHealthResponse getClusterHealth(String clusterName) {
Set<Node> nodeSet = nodesClusterMap.get(clusterName);
if (nodeSet != null) {
for (Node node : nodeSet) {
ClusterAdminClient client = node.client().admin().cluster();
ClusterHealthResponse response = client.prepareHealth().execute().actionGet();
return response;
}
}
return null;
}
代码示例来源: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: 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: awslabs/amazon-kinesis-connectors
private void printClusterStatus() {
ClusterHealthRequestBuilder healthRequestBuilder = elasticsearchClient.admin().cluster().prepareHealth();
ClusterHealthResponse response = healthRequestBuilder.execute().actionGet();
if (response.getStatus().equals(ClusterHealthStatus.RED)) {
LOG.error("Cluster health is RED. Indexing ability will be limited");
} else if (response.getStatus().equals(ClusterHealthStatus.YELLOW)) {
LOG.warn("Cluster health is YELLOW.");
} else if (response.getStatus().equals(ClusterHealthStatus.GREEN)) {
LOG.info("Cluster health is GREEN.");
}
}
}
代码示例来源: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: com.amazonaws/amazon-kinesis-connectors
private void printClusterStatus() {
ClusterHealthRequestBuilder healthRequestBuilder = elasticsearchClient.admin().cluster().prepareHealth();
ClusterHealthResponse response = healthRequestBuilder.execute().actionGet();
if (response.getStatus().equals(ClusterHealthStatus.RED)) {
LOG.error("Cluster health is RED. Indexing ability will be limited");
} else if (response.getStatus().equals(ClusterHealthStatus.YELLOW)) {
LOG.warn("Cluster health is YELLOW.");
} else if (response.getStatus().equals(ClusterHealthStatus.GREEN)) {
LOG.info("Cluster health is GREEN.");
}
}
}
代码示例来源:origin: io.zipkin.java/zipkin-storage-elasticsearch
@Override protected void ensureClusterReady(String catchAll) {
ClusterHealthResponse health = getUnchecked(client
.admin().cluster().prepareHealth(catchAll).execute());
checkState(health.getStatus() != ClusterHealthStatus.RED, "Health status is RED");
}
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!