use of org.elasticsearch.client.transport.TransportClient in project sonarqube by SonarSource.
the class EsServerHolder method reset.
private void reset() {
TransportClient client = TransportClient.builder().settings(Settings.builder().put("network.bind_host", "localhost").put("cluster.name", clusterName).build()).build();
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), port));
// wait for node to be ready
client.admin().cluster().prepareHealth().setWaitForGreenStatus().get();
// delete the indices created by previous tests
DeleteIndexResponse response = client.admin().indices().prepareDelete("_all").get();
if (!response.isAcknowledged()) {
throw new IllegalStateException("Fail to delete all indices");
}
client.close();
}
use of org.elasticsearch.client.transport.TransportClient in project MSEC by Tencent.
the class ESHelper method ClusterAdd.
public void ClusterAdd(ArrayList<String> ips) {
Logger logger = Logger.getLogger(ESHelper.class);
TransportClient client = null;
try {
Settings settings = Settings.builder().put("cluster.name", cluster_info.getCluster_name()).put("client.transport.sniff", true).build();
for (String ip : ips) {
if (client == null) {
client = new PreBuiltTransportClient(settings).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(ip), default_client_port));
} else
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(ip), default_client_port));
}
updateStatus(waitforcluster_message);
waitForClusterReady(client, ips, ClusterHealthStatus.YELLOW);
} catch (UnknownHostException e) {
logger.error(e);
updateStatus("[ERROR] Connect failed.");
} catch (IOException e) {
logger.error(e);
updateStatus_waitforcluster("[ERROR] Joining cluster failed.");
} finally {
if (client != null)
client.close();
}
}
use of org.elasticsearch.client.transport.TransportClient in project wonderdog by infochimps-labs.
the class ElasticSearchStreamingRecordReader 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.client.transport.TransportClient 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.client.transport.TransportClient 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));
}
Aggregations