use of org.elasticsearch.transport.client.PreBuiltTransportClient in project incubator-skywalking by apache.
the class ElasticSearchClient method initialize.
@Override
public void initialize() throws ClientException {
Settings settings = Settings.builder().put("cluster.name", clusterName).put("client.transport.sniff", clusterTransportSniffer).build();
client = new PreBuiltTransportClient(settings);
List<AddressPairs> pairsList = parseClusterNodes(clusterNodes);
for (AddressPairs pairs : pairsList) {
try {
((PreBuiltTransportClient) client).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(pairs.host), pairs.port));
} catch (UnknownHostException e) {
throw new ElasticSearchClientException(e.getMessage(), e);
}
}
this.ready = true;
}
use of org.elasticsearch.transport.client.PreBuiltTransportClient in project topcom-cloud by 545314690.
the class ElasticSearchService method init.
@PostConstruct
public void init() {
try {
Settings settings = Settings.builder().put("cluster.name", EsConf.CLUSTER_NAME).build();
this.client = new PreBuiltTransportClient(settings).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(EsConf.IP), EsConf.PORT));
} catch (UnknownHostException e) {
log.error("es init failed!", e);
}
}
use of org.elasticsearch.transport.client.PreBuiltTransportClient in project vertigo by KleeGroup.
the class ESTransportSearchServicesPlugin method createClient.
/**
* {@inheritDoc}
*/
@Override
protected Client createClient() {
client = new PreBuiltTransportClient(buildNodeSettings());
for (final String serverName : serversNames) {
final String[] serverNameSplit = serverName.split(":");
Assertion.checkArgument(serverNameSplit.length == 2, "La dĂ©claration du serveur doit ĂȘtre au format host:port ({0}", serverName);
final int port = Integer.parseInt(serverNameSplit[1]);
client.addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress(serverNameSplit[0], port)));
}
return client;
}
use of org.elasticsearch.transport.client.PreBuiltTransportClient in project fess-crawler by codelibs.
the class EsClient method createTransportClient.
protected TransportClient createTransportClient() {
final Settings settings = Settings.builder().put("cluster.name", StringUtil.isBlank(clusterName) ? "elasticsearch" : clusterName).build();
final TransportClient transportClient = new PreBuiltTransportClient(settings);
Arrays.stream(addresses).forEach(address -> {
final String[] values = address.split(":");
String hostname;
int port = 9300;
if (values.length == 1) {
hostname = values[0];
} else if (values.length == 2) {
hostname = values[0];
port = Integer.parseInt(values[1]);
} else {
throw new CrawlerSystemException("Invalid address: " + address);
}
try {
transportClient.addTransportAddress(new TransportAddress(InetAddress.getByName(hostname), port));
} catch (final Exception e) {
throw new CrawlerSystemException("Unknown host: " + address);
}
logger.info("Connected to " + hostname + ":" + port);
});
return transportClient;
}
use of org.elasticsearch.transport.client.PreBuiltTransportClient in project bibot by alfintech.
the class ElasticPublisher method initialise.
@PostConstruct
public void initialise() throws IOException {
Settings settings = Settings.builder().put("cluster.name", clusterName).put("node.name", nodeName).build();
client = new PreBuiltTransportClient(settings);
client.addTransportAddress(new TransportAddress(InetAddress.getByName(elasticHost), elasticPort));
}
Aggregations