本文整理了Java中org.elasticsearch.client.RestHighLevelClient.ping
方法的一些代码示例,展示了RestHighLevelClient.ping
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RestHighLevelClient.ping
方法的具体详情如下:
包路径:org.elasticsearch.client.RestHighLevelClient
类名称:RestHighLevelClient
方法名:ping
[英]Pings the remote Elasticsearch cluster and returns true if the ping succeeded, false otherwise
[中]ping远程Elasticsearch集群,如果ping成功,则返回true,否则返回false
代码示例来源:origin: apache/flink
@Override
public RestHighLevelClient createClient(Map<String, String> clientConfig) throws IOException {
RestClientBuilder builder = RestClient.builder(httpHosts.toArray(new HttpHost[httpHosts.size()]));
restClientFactory.configureRestClientBuilder(builder);
RestHighLevelClient rhlClient = new RestHighLevelClient(builder);
if (LOG.isInfoEnabled()) {
LOG.info("Pinging Elasticsearch cluster via hosts {} ...", httpHosts);
}
if (!rhlClient.ping()) {
throw new RuntimeException("There are no reachable Elasticsearch nodes!");
}
if (LOG.isInfoEnabled()) {
LOG.info("Created Elasticsearch RestHighLevelClient connected to {}", httpHosts.toString());
}
return rhlClient;
}
代码示例来源:origin: cognitree/flume-elasticsearch-sink
private boolean checkConnection() throws IOException {
return client.ping(RequestOptions.DEFAULT);
}
}
代码示例来源:origin: org.nuxeo.elasticsearch/nuxeo-elasticsearch-core
protected void checkConnection(RestHighLevelClient client) {
boolean ping = false;
try {
ping = client.ping(RequestOptions.DEFAULT);
} catch (IOException e) {
log.error(e.getMessage(), e);
}
if (!ping) {
throw new IllegalStateException("Fail to ping rest node");
}
}
}
代码示例来源:origin: org.apache.camel/camel-elasticsearch-rest
@Override
protected Result verifyConnectivity(Map<String, Object> parameters) {
ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.CONNECTIVITY);
try {
ElasticsearchConfiguration configuration = setProperties(new ElasticsearchConfiguration(), parameters);
RestClientBuilder clientBuilder = RestClient.builder(configuration.getHostAddressesList().toArray(new HttpHost[0]));
RestHighLevelClient restHighLevelClient = new RestHighLevelClient(clientBuilder);
restHighLevelClient.ping();
} catch (IOException e) {
ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage())
.detail("elasticsearch_rest_exception_message", e.getMessage()).detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName())
.detail(VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE, e);
builder.error(errorBuilder.build());
} catch (Exception e) {
builder.error(ResultErrorBuilder.withException(e).build());
}
return builder.build();
}
}
代码示例来源:origin: org.apache.camel/camel-elasticsearch-rest
message.setBody(restHighLevelClient.msearch(searchRequest, RequestOptions.DEFAULT).getResponses());
} else if (operation == ElasticsearchOperation.Ping) {
message.setBody(restHighLevelClient.ping(RequestOptions.DEFAULT));
} else if (operation == ElasticsearchOperation.Info) {
message.setBody(restHighLevelClient.info(RequestOptions.DEFAULT));
内容来源于网络,如有侵权,请联系作者删除!