Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package com.nova.stats.platform.are.batch.base;
import com.nova.stats.platform.are.batch.common.GlobalConfigurations;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
public class ElasticsearchRestClient {
private static String host = (String) GlobalConfigurations.ElasticsearchConfigurations.finishedCallParameters
.getParameter(GlobalConfigurations.ElasticsearchConfigurations.ConfigurationFields.IP);
private static String port = (String) GlobalConfigurations.ElasticsearchConfigurations.finishedCallParameters
.getParameter(GlobalConfigurations.ElasticsearchConfigurations.ConfigurationFields.PORT).toString();
private static class ElasticsearchRestClientLazyHolder {
static final RestClient INSTANCE = RestClient.builder(new HttpHost(host, Integer.valueOf(port), "http"))
.setRequestConfigCallback(requestConfigBuilder ->
requestConfigBuilder.setConnectTimeout(5000).setSocketTimeout(100000))
.setMaxRetryTimeoutMillis(100000)
.build();
}
public static RestClient getClient() {
return ElasticsearchRestClientLazyHolder.INSTANCE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment