Skip to content

Instantly share code, notes, and snippets.

@arony
Created April 17, 2018 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arony/c161dd1f4d4e1cbd34491a0255f50744 to your computer and use it in GitHub Desktop.
Save arony/c161dd1f4d4e1cbd34491a0255f50744 to your computer and use it in GitHub Desktop.
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