org.elasticsearch.client.RestClientBuilder.RequestConfigCallback Java Examples
The following examples show how to use
org.elasticsearch.client.RestClientBuilder.RequestConfigCallback.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticSearchClientFactory.java From ache with Apache License 2.0 | 6 votes |
public static RestClient createClient(ElasticSearchConfig config) { HttpHost[] httpHosts = parseHostAddresses(config.getRestApiHosts()); RestClient client = RestClient.builder(httpHosts) .setRequestConfigCallback(new RequestConfigCallback() { @Override public Builder customizeRequestConfig( Builder requestConfigBuilder) { return requestConfigBuilder .setConnectTimeout(config.getRestConnectTimeout()) .setSocketTimeout(config.getRestSocketTimeout()); } }) .setMaxRetryTimeoutMillis(config.getRestMaxRetryTimeoutMillis()) .build(); logger.info("Initialized Elasticsearch REST client for: " + Arrays.toString(httpHosts)); return client; }
Example #2
Source File: CommonService.java From pacbot with Apache License 2.0 | 5 votes |
private RestClient getRestClient() { if (restClient == null) { String esHost = config.getElasticSearch().getDevIngestHost(); int esPort = config.getElasticSearch().getDevIngestPort(); RestClientBuilder builder = RestClient.builder(new HttpHost(esHost, esPort)); RequestConfigCallback requestConfigCallback = requestConfigBuilder -> requestConfigBuilder .setConnectionRequestTimeout(0); builder.setRequestConfigCallback(requestConfigCallback); restClient = builder.build(); } return restClient; }