use of org.elasticsearch.common.transport.InetSocketTransportAddress in project crate by crate.
the class PostgresNetty method bindAddress.
private InetSocketTransportAddress bindAddress(final InetAddress hostAddress) {
PortsRange portsRange = new PortsRange(port);
final AtomicReference<Exception> lastException = new AtomicReference<>();
final AtomicReference<InetSocketAddress> boundSocket = new AtomicReference<>();
boolean success = portsRange.iterate(new PortsRange.PortCallback() {
@Override
public boolean onPortNumber(int portNumber) {
try {
synchronized (serverChannels) {
Channel channel = bootstrap.bind(new InetSocketAddress(hostAddress, portNumber));
serverChannels.add(channel);
boundSocket.set((InetSocketAddress) channel.getLocalAddress());
}
} catch (Exception e) {
lastException.set(e);
return false;
}
return true;
}
});
if (!success) {
throw new BindPostgresException("Failed to bind to [" + port + "]", lastException.get());
}
if (logger.isDebugEnabled()) {
logger.debug("Bound psql to address {{}}", NetworkAddress.format(boundSocket.get()));
}
return new InetSocketTransportAddress(boundSocket.get());
}
use of org.elasticsearch.common.transport.InetSocketTransportAddress in project wonderdog by infochimps-labs.
the class ElasticSearchStreamingInputFormat method startTransportClient.
//
// == Connecting to Elasticsearch and Querying ==
//
private void startTransportClient(JobConf conf) {
this.client = new TransportClient();
Map<String, String> settings = parsedSettings(conf);
String host = hostname(settings);
if (host.toString().length() == 0) {
System.exit(1);
}
LOG.info("Attempting to connect to Elasticsearch node at " + host + ":9300");
this.client = new TransportClient().addTransportAddress(new InetSocketTransportAddress(host, 9300));
LOG.info("Connected to Elasticsearch cluster");
}
use of org.elasticsearch.common.transport.InetSocketTransportAddress in project wonderdog by infochimps-labs.
the class ElasticSearchStreamingRecordWriter method buildTransportClient.
/**
Build a transport client that will connect to some
Elasticsearch node.
*/
private Client buildTransportClient() {
LOG.info("Connecting transport client to " + transportHost + ":" + Integer.toString(transportPort));
Settings settings = ImmutableSettings.settingsBuilder().put("client.transport.ignore_cluster_name", "true").build();
return new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress(transportHost, transportPort));
}
use of org.elasticsearch.common.transport.InetSocketTransportAddress in project elasticsearch-jdbc by jprante.
the class NodeTestUtils method findNodeAddresses.
protected void findNodeAddresses() {
NodesInfoRequest nodesInfoRequest = new NodesInfoRequest().transport(true);
NodesInfoResponse response = client("1").admin().cluster().nodesInfo(nodesInfoRequest).actionGet();
Iterator<NodeInfo> it = response.iterator();
hosts = new LinkedList<>();
hosts = new LinkedList<>();
while (it.hasNext()) {
NodeInfo nodeInfo = it.next();
TransportInfo transportInfo = nodeInfo.getTransport();
TransportAddress address = transportInfo.getAddress().publishAddress();
if (address instanceof InetSocketTransportAddress) {
InetSocketTransportAddress inetSocketTransportAddress = (InetSocketTransportAddress) address;
hosts.add(inetSocketTransportAddress.address().getHostName() + ":" + inetSocketTransportAddress.address().getPort());
}
}
}
use of org.elasticsearch.common.transport.InetSocketTransportAddress in project camel by apache.
the class ElasticsearchClusterBaseTest method cleanUpOnce.
@BeforeClass
public static void cleanUpOnce() throws Exception {
deleteDirectory("target/testcluster/");
clusterName = "es-cl-run-" + System.currentTimeMillis();
// create runner instance
runner = new ElasticsearchClusterRunner();
// create ES nodes
runner.onBuild(new ElasticsearchClusterRunner.Builder() {
@Override
public void build(final int number, final Builder settingsBuilder) {
settingsBuilder.put("http.cors.enabled", true);
settingsBuilder.put("http.cors.allow-origin", "*");
}
}).build(newConfigs().clusterName(clusterName).numOfNode(3).basePath("target/testcluster/").useLogger());
// wait for green status
runner.ensureGreen();
client = new PreBuiltTransportClient(getSettings()).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9301));
}
Aggregations