Client client = new TransportClient() .addTransportAddress(new InetSocketTransportAddress( "143.79.236.xxx", 9300));
/** * Open client to elaticsearch cluster * * @param clusterName */ private void openClient(String clusterName) { logger.info("Using ElasticSearch hostnames: {} ", Arrays.toString(serverAddresses)); Settings settings = ImmutableSettings.settingsBuilder() .put("cluster.name", clusterName).build(); TransportClient transportClient = new TransportClient(settings); for (InetSocketTransportAddress host : serverAddresses) { transportClient.addTransportAddress(host); } if (client != null) { client.close(); } client = transportClient; }
@Override public Connection connect(Configuration config) throws IOException { log.debug("Configuring TransportClient"); ImmutableSettings.Builder settingsBuilder = settingsBuilder(config); if (config.has(ElasticSearchIndex.CLIENT_SNIFF)) { String k = "client.transport.sniff"; settingsBuilder.put(k, config.get(ElasticSearchIndex.CLIENT_SNIFF)); log.debug("Set {}: {}", k, config.get(ElasticSearchIndex.CLIENT_SNIFF)); } TransportClient tc = new TransportClient(settingsBuilder.build()); int defaultPort = config.has(INDEX_PORT) ? config.get(INDEX_PORT) : ElasticSearchIndex.HOST_PORT_DEFAULT; for (String host : config.get(INDEX_HOSTS)) { String[] hostparts = host.split(":"); String hostname = hostparts[0]; int hostport = defaultPort; if (hostparts.length == 2) hostport = Integer.parseInt(hostparts[1]); log.info("Configured remote host: {} : {}", hostname, hostport); tc.addTransportAddress(new InetSocketTransportAddress(hostname, hostport)); } return new Connection(null, tc); } },
/** * Create the transport client * @return */ private Client createTransportClient() { final String clusterName = indexFig.getClusterName(); final int port = indexFig.getPort(); ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder().put( "cluster.name", clusterName ) .put( "client.transport.sniff", true ); String nodeName = indexFig.getNodeName(); if ( "default".equals( nodeName ) ) { // no nodeName was specified, use hostname try { nodeName = InetAddress.getLocalHost().getHostName(); } catch ( UnknownHostException ex ) { nodeName = "client-" + RandomStringUtils.randomAlphabetic( 8 ); logger.warn( "Couldn't get hostname to use as ES node name, using {}", nodeName ); } } settings.put( "node.name", nodeName ); TransportClient transportClient = new TransportClient( settings.build() ); // we will connect to ES on all configured hosts for ( String host : indexFig.getHosts().split( "," ) ) { transportClient.addTransportAddress( new InetSocketTransportAddress( host, port ) ); } return transportClient; }
.build(); TransportClient transportClient = new TransportClient(settings); for (TransportAddress transport: transportAddresses) { transportClient.addTransportAddress(transport);
settings.put("client.transport.sniff", config.get(CLIENT_SNIFF)); settings.put("script.disable_dynamic", false); TransportClient tc = new TransportClient(settings.build()); int defaultPort = config.has(INDEX_PORT)?config.get(INDEX_PORT):HOST_PORT_DEFAULT; for (String host : config.get(INDEX_HOSTS)) {
@Bean public Client client() { TransportClient client = new TransportClient(); TransportAddress address = new InetSocketTransportAddress(hostname, port); client.addTransportAddress(address); return client; } }
// on startup Client client = new TransportClient() .addTransportAddress(new InetSocketTransportAddress("host1", 9300)) .addTransportAddress(new InetSocketTransportAddress("host2", 9300)); // on shutdown client.close();
this.client = new TransportClient(settings.build());
@ApplicationScoped public class ESClient { @Produces @ApplicationScoped public Client createClient() { return new TransportClient().addTransportAddress(new InetSocketTransportAddress(IP, 9300)); } }
private TransportClient getClient() { if(this.elasticsearchConfiguration.getSettings() == null) { return new TransportClient(); } else { return new TransportClient(this.elasticsearchConfiguration.getSettings()); } }
private TransportClient getClient() { if(this.elasticsearchConfiguration.getSettings() == null) { return new TransportClient(); } else { return new TransportClient(this.elasticsearchConfiguration.getSettings()); } }
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"); }
private void initTransportClient() { TransportClient tClient = new TransportClient(); if (!Util.isEmpty(urlSet)) { for (URL url : urlSet) { tClient.addTransportAddress(new InetSocketTransportAddress(url.getHost(), url.getPort())); } } esClient = tClient; }
@SuppressWarnings("rawtypes") public ElasticSearchState(Map config) { LOGGER.debug("Initialize ElasticSearchState"); String clusterName = (String) config.get(StormElasticSearchConstants.ES_CLUSTER_NAME); String host = (String) config.get(StormElasticSearchConstants.ES_HOST); Integer port = (Integer) config.get(StormElasticSearchConstants.ES_PORT); Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", clusterName).build(); client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress(host, port)); LOGGER.debug("Initialization completed with [clusterName=" + clusterName + ", host=" + host + ", port=" + port + "]"); }
/** 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)); }
/** 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)); }
public static TransportClient createTransportClient(String hostname, int port) { return new TransportClient(ImmutableSettings.settingsBuilder() .put("client.transport.ignore_cluster_name", true).build()) .addTransportAddress(new InetSocketTransportAddress(hostname, port)); } }
@Inject protected ElasticSearchShardAllocationManager(IConfiguration config) { Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", config.getAppName()).build(); TransportClient localClient = new TransportClient(settings); localClient.addTransportAddress(new InetSocketTransportAddress(config.getHostIP(),config.getTransportTcpPort())); init(localClient); }
public EsStore(String host, int port) { String clusterName = Configuration.getProperties().getString("es_cluster_name", "soundwave"); Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", clusterName) .put("client.transport.sniff", false).build(); esClient = new TransportClient(settings) .addTransportAddress( new InetSocketTransportAddress(host, port)); }