本文整理了Java中org.elasticsearch.client.RestClientBuilder.setFailureListener
方法的一些代码示例,展示了RestClientBuilder.setFailureListener
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RestClientBuilder.setFailureListener
方法的具体详情如下:
包路径:org.elasticsearch.client.RestClientBuilder
类名称:RestClientBuilder
方法名:setFailureListener
[英]Sets the RestClient.FailureListener to be notified for each request failure
[中]设置RestClient。FailureListener将收到每个请求失败的通知
代码示例来源:origin: apache/storm
/**
* Creates a new {@link RestClient} using given {@link EsConfig}.
*
* @return {@link RestClient} for Elasticsearch connection
*/
public RestClient construct() {
RestClientBuilder builder = RestClient.builder(esConfig.getHttpHosts());
if (esConfig.getMaxRetryTimeoutMillis() != null) {
builder.setMaxRetryTimeoutMillis(esConfig.getMaxRetryTimeoutMillis());
}
if (esConfig.getDefaultHeaders() != null) {
builder.setDefaultHeaders(esConfig.getDefaultHeaders());
}
if (esConfig.getFailureListener() != null) {
builder.setFailureListener(esConfig.getFailureListener());
}
if (esConfig.getHttpClientConfigCallback() != null) {
builder.setHttpClientConfigCallback(esConfig.getHttpClientConfigCallback());
}
if (esConfig.getRequestConfigCallback() != null) {
builder.setRequestConfigCallback(esConfig.getRequestConfigCallback());
}
if (esConfig.getPathPrefix() != null) {
builder.setPathPrefix(esConfig.getPathPrefix());
}
return builder.build();
}
}
代码示例来源:origin: gauravrmazra/gauravbytes
public static RestClient createClientWithDefaultHeaders() {
RestClientBuilder clientBuilder = RestClient.builder(new HttpHost("localhost", 9200, "http"));
Header[] defaultHeaders = new Header[2];
defaultHeaders[0] = new BasicHeader("COMPANY", "GAURAVBYTES");
defaultHeaders[1] = new BasicHeader("OWNER", "Gaurav Rai Mazra");
clientBuilder.setDefaultHeaders(defaultHeaders);
clientBuilder.setFailureListener(failureListener());
return clientBuilder.build();
}
代码示例来源:origin: couchbase/couchbase-elasticsearch-connector
public static RestHighLevelClient newElasticsearchClient(List<HttpHost> hosts, String username, String password, boolean secureConnection, Supplier<KeyStore> trustStore) throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(username, password));
final SSLContext sslContext = !secureConnection ? null :
SSLContexts.custom().loadTrustMaterial(trustStore.get(), null).build();
final RestClientBuilder builder = RestClient.builder(Iterables.toArray(hosts, HttpHost.class))
.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder
.setSSLContext(sslContext)
.setDefaultCredentialsProvider(credentialsProvider))
.setFailureListener(new RestClient.FailureListener() {
@Override
public void onFailure(HttpHost host) {
Metrics.elasticsearchHostOffline().mark();
}
});
return new RestHighLevelClient(builder);
}
代码示例来源:origin: eea/eea.elasticsearch.river.rdf
.setFailureListener(new RestClient.FailureListener(){
@Override
public void onFailure(HttpHost host) {
代码示例来源:origin: delirius325/jmeter-elasticsearch-backend-listener
.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(5000)
.setSocketTimeout((int) timeoutMs))
.setFailureListener(new RestClient.FailureListener() {
@Override
public void onFailure(Node node) {
内容来源于网络,如有侵权,请联系作者删除!