// 1. Link to client (or cluster)
if (_bLocalMode) {
NodeBuilder nBuilder = NodeBuilder.nodeBuilder().local(true);
if (null == _elasticClient) {
_elasticClient = new CrossVersionClient(nBuilder.node().client());
}
}
else if (bRemote) {
if (null == _elasticClient) {
String sHostname = null;
String sPort = null;
if (null == hostAndPort) {
hostAndPort = new PropertiesManager().getElasticUrl();
}
String[] hostPort = hostAndPort.split("[:/]");
sHostname = hostPort[0];
sPort = hostPort[1];
Builder globalSettings = ImmutableSettings.settingsBuilder();
Settings snode = globalSettings.put("cluster.name", _clusterName).build();
TransportClient tmp = new TransportClient(snode);
_elasticClient = new CrossVersionClient(tmp.addTransportAddress(new InetSocketTransportAddress(sHostname, Integer.parseInt(sPort))));
}
} //TESTED
else { // Create a "no data" cluster
if (null == _elasticClient) {
Builder globalSettings = ImmutableSettings.settingsBuilder();
Settings snode = globalSettings.put("cluster.name", _clusterName).build();
NodeBuilder nBuilder = NodeBuilder.nodeBuilder().settings(snode);
nBuilder.data(false); // Don't store your own data
_elasticClient = new CrossVersionClient(nBuilder.build().start().client());
}
}//TOTEST
_sIndexName = sIndexName;
_sIndexType = sIndexType;