use of org.qi4j.index.elasticsearch.ElasticSearchClusterConfiguration in project qi4j-sdk by Qi4j.
the class ESClusterSupport method activateElasticSearch.
@Override
protected void activateElasticSearch() throws Exception {
configuration.refresh();
ElasticSearchClusterConfiguration config = configuration.get();
String clusterName = config.clusterName().get() == null ? DEFAULT_CLUSTER_NAME : config.clusterName().get();
index = config.index().get() == null ? DEFAULT_INDEX_NAME : config.index().get();
indexNonAggregatedAssociations = config.indexNonAggregatedAssociations().get();
String[] nodes = config.nodes().get() == null ? new String[] { "localhost:9300" } : config.nodes().get().split(",");
boolean clusterSniff = config.clusterSniff().get();
boolean ignoreClusterName = config.ignoreClusterName().get();
String pingTimeout = config.pingTimeout().get() == null ? "5s" : config.pingTimeout().get();
String samplerInterval = config.samplerInterval().get() == null ? "5s" : config.samplerInterval().get();
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", clusterName).put("client.transport.sniff", clusterSniff).put("client.transport.ignore_cluster_name", ignoreClusterName).put("client.transport.ping_timeout", pingTimeout).put("client.transport.nodes_sampler_interval", samplerInterval).build();
TransportClient transportClient = new TransportClient(settings);
for (String node : nodes) {
String[] split = node.split(":");
String host = split[0];
int port = Integer.valueOf(split[1]);
transportClient.addTransportAddress(new InetSocketTransportAddress(host, port));
}
client = transportClient;
}
Aggregations