use of org.elasticsearch.common.transport.InetSocketTransportAddress in project elasticsearch-skywalker by jprante.
the class AbstractNodeTest method createIndices.
@BeforeMethod
public void createIndices() throws Exception {
startNode("1");
NodesInfoRequest nodesInfoRequest = new NodesInfoRequest().transport(true);
NodesInfoResponse response = client("1").admin().cluster().nodesInfo(nodesInfoRequest).actionGet();
InetSocketTransportAddress address = (InetSocketTransportAddress) response.iterator().next().getTransport().getAddress().publishAddress();
addresses.put("1", address);
client("1").admin().indices().create(new CreateIndexRequest(INDEX)).actionGet();
}
use of org.elasticsearch.common.transport.InetSocketTransportAddress in project storm-elastic-search by hmsonline.
the class ElasticSearchBolt method prepare.
@Override
@SuppressWarnings("rawtypes")
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
this.collector = collector;
String elasticSearchHost = (String) stormConf.get(StormElasticSearchConstants.ES_HOST);
Integer elasticSearchPort = ((Long) stormConf.get(StormElasticSearchConstants.ES_PORT)).intValue();
String elasticSearchCluster = (String) stormConf.get(StormElasticSearchConstants.ES_CLUSTER_NAME);
Boolean localMode = (Boolean) stormConf.get(ELASTIC_LOCAL_MODE);
if (localMode != null && localMode) {
client = nodeBuilder().local(true).node().client();
} else {
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", elasticSearchCluster).build();
client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress(elasticSearchHost, elasticSearchPort));
}
}
use of org.elasticsearch.common.transport.InetSocketTransportAddress in project storm-elastic-search by hmsonline.
the class ElasticSearchFunction method prepare.
@SuppressWarnings("rawtypes")
@Override
public void prepare(Map conf, TridentOperationContext context) {
super.prepare(conf, context);
String clusterName = (String) conf.get(StormElasticSearchConstants.ES_CLUSTER_NAME);
String host = (String) conf.get(StormElasticSearchConstants.ES_HOST);
Integer port = (Integer) conf.get(StormElasticSearchConstants.ES_PORT);
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", clusterName).build();
client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress(host, port));
}
use of org.elasticsearch.common.transport.InetSocketTransportAddress in project elasticsearch-jetty by sonian.
the class JettyHttpServerTransport method doStart.
@Override
protected void doStart() throws ElasticsearchException {
PortsRange portsRange = new PortsRange(port);
final AtomicReference<Exception> lastException = new AtomicReference<Exception>();
Log.setLog(loggerWrapper);
portsRange.iterate(new PortsRange.PortCallback() {
@Override
public boolean onPortNumber(int portNumber) {
try {
Server server = null;
XmlConfiguration lastXmlConfiguration = null;
Object[] objs = new Object[jettyConfig.length];
Map<String, String> esProperties = jettySettings(bindHost, portNumber);
for (int i = 0; i < jettyConfig.length; i++) {
String configFile = jettyConfig[i];
URL config = environment.resolveConfig(configFile);
XmlConfiguration xmlConfiguration = new XmlConfiguration(config);
// in the later configurations
if (lastXmlConfiguration != null) {
xmlConfiguration.getIdMap().putAll(lastXmlConfiguration.getIdMap());
} else {
xmlConfiguration.getIdMap().put("ESServerTransport", JettyHttpServerTransport.this);
xmlConfiguration.getIdMap().put("ESClient", client);
}
// Inject elasticsearch properties
xmlConfiguration.getProperties().putAll(esProperties);
objs[i] = xmlConfiguration.configure();
lastXmlConfiguration = xmlConfiguration;
}
// Find jetty Server with id jettyConfigServerId
Object serverObject = lastXmlConfiguration.getIdMap().get(jettyConfigServerId);
if (serverObject != null) {
if (serverObject instanceof Server) {
server = (Server) serverObject;
}
} else {
// For compatibility - if it's not available, find first available jetty Server
for (Object obj : objs) {
if (obj instanceof Server) {
server = (Server) obj;
break;
}
}
}
if (server == null) {
logger.error("Cannot find server with id [{}] in configuration files [{}]", jettyConfigServerId, jettyConfig);
lastException.set(new ElasticsearchException("Cannot find server with id " + jettyConfigServerId));
return true;
}
// Keep it for now for backward compatibility with previous versions of jetty.xml
server.setAttribute(TRANSPORT_ATTRIBUTE, JettyHttpServerTransport.this);
// Start all lifecycle objects configured by xml configurations
for (Object obj : objs) {
if (obj instanceof LifeCycle) {
LifeCycle lifeCycle = (LifeCycle) obj;
if (!lifeCycle.isRunning()) {
lifeCycle.start();
}
}
}
jettyServer = server;
lastException.set(null);
} catch (BindException e) {
lastException.set(e);
return false;
} catch (Exception e) {
logger.error("Jetty Startup Failed ", e);
lastException.set(e);
return true;
}
return true;
}
});
if (lastException.get() != null) {
throw new BindHttpException("Failed to bind to [" + port + "]", lastException.get());
}
InetSocketAddress jettyBoundAddress = findFirstInetConnector(jettyServer);
if (jettyBoundAddress != null) {
InetSocketAddress publishAddress;
try {
publishAddress = new InetSocketAddress(networkService.resolvePublishHostAddress(publishHost), jettyBoundAddress.getPort());
} catch (Exception e) {
throw new BindTransportException("Failed to resolve publish address", e);
}
this.boundAddress = new BoundTransportAddress(new InetSocketTransportAddress(jettyBoundAddress), new InetSocketTransportAddress(publishAddress));
} else {
throw new BindHttpException("Failed to find a jetty connector with Inet transport");
}
}
use of org.elasticsearch.common.transport.InetSocketTransportAddress in project elasticsearch-suggest-plugin by spinscale.
the class RestSuggestActionTest method setPort.
@Before
public void setPort() {
NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setHttp(true).execute().actionGet();
port = ((InetSocketTransportAddress) response.getNodes()[0].getHttp().address().boundAddress()).address().getPort();
}
Aggregations