use of org.elasticsearch.common.transport.InetSocketTransportAddress 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.common.transport.InetSocketTransportAddress in project vertigo by KleeGroup.
the class ESTransportSearchServicesPlugin method createClient.
/**
* {@inheritDoc}
*/
@Override
protected Client createClient() {
client = TransportClient.builder().settings(buildNodeSettings()).build();
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.common.transport.InetSocketTransportAddress in project arctic-sea by 52North.
the class KibanaExporter method main.
// CHECKSTYLE:OFF
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.out.printf("Usage: java KibanaExporter.jar %s %s%n", "localhost:9300", "my-cluster-name");
System.exit(0);
}
if (!args[0].contains(":")) {
throw new IllegalArgumentException(String.format("%s not a valid format. Expected <hostname>:<port>.", args[0]));
}
// set ES address
String[] split = args[0].split(":");
InetSocketTransportAddress address = new InetSocketTransportAddress(InetAddress.getByName(split[0]), Integer.parseInt(split[1], 10));
// set cluster name
Builder tcSettings = Settings.settingsBuilder();
tcSettings.put("cluster.name", args[1]);
System.out.println("Connection to " + args[1]);
client = TransportClient.builder().settings(tcSettings).build();
client.addTransportAddress(address);
// search index pattern for needle
searchIndexPattern();
KibanaConfigHolderDto holder = new KibanaConfigHolderDto();
System.out.println("Reading .kibana index");
SearchResponse resp = client.prepareSearch(".kibana").setSize(1000).get();
Arrays.asList(resp.getHits().getHits()).stream().map(KibanaExporter::parseSearchHit).forEach(holder::add);
System.out.println("Reading finished");
ObjectMapper mapper = new ObjectMapper();
// we love pretty things
mapper.enable(SerializationFeature.INDENT_OUTPUT);
File f = new File("kibana_config.json");
try (FileOutputStream out = new FileOutputStream(f, false)) {
mapper.writeValue(out, holder);
}
System.out.println("File outputted to: " + f.getAbsolutePath());
client.close();
}
use of org.elasticsearch.common.transport.InetSocketTransportAddress in project samza by apache.
the class TransportClientFactory method getClient.
@Override
public Client getClient() {
Settings settings = Settings.settingsBuilder().put(clientSettings).build();
TransportAddress address = new InetSocketTransportAddress(new InetSocketAddress(transportHost, transportPort));
return TransportClient.builder().settings(settings).build().addTransportAddress(address);
}
use of org.elasticsearch.common.transport.InetSocketTransportAddress in project jstorm by alibaba.
the class EsConfig method getTransportAddresses.
List<TransportAddress> getTransportAddresses() throws UnknownHostException {
List<TransportAddress> transportAddresses = Lists.newArrayList();
for (String node : nodes) {
String[] hostAndPort = node.split(DELIMITER);
Preconditions.checkArgument(hostAndPort.length == 2, "Incorrect node format");
String host = hostAndPort[0];
int port = Integer.parseInt(hostAndPort[1]);
InetSocketTransportAddress inetSocketTransportAddress = new InetSocketTransportAddress(InetAddress.getByName(host), port);
transportAddresses.add(inetSocketTransportAddress);
}
return transportAddresses;
}
Aggregations