本文整理了Java中org.elasticsearch.client.transport.TransportClient.<init>()
方法的一些代码示例,展示了TransportClient.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TransportClient.<init>()
方法的具体详情如下:
包路径:org.elasticsearch.client.transport.TransportClient
类名称:TransportClient
方法名:<init>
[英]Creates a new TransportClient with the given settings and plugins
[中]使用给定的设置和插件创建新的TransportClient
代码示例来源:origin: stackoverflow.com
Client client = new TransportClient()
.addTransportAddress(new InetSocketTransportAddress(
"143.79.236.xxx",
9300));
代码示例来源:origin: apache/flume
/**
* 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;
}
代码示例来源:origin: thinkaurelius/titan
@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);
}
},
代码示例来源:origin: apache/usergrid
/**
* 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;
}
代码示例来源:origin: apache/flink
.build();
TransportClient transportClient = new TransportClient(settings);
for (TransportAddress transport: transportAddresses) {
transportClient.addTransportAddress(transport);
代码示例来源:origin: thinkaurelius/titan
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)) {
代码示例来源:origin: lianggzone/springboot-action
@Bean
public Client client() {
TransportClient client = new TransportClient();
TransportAddress address = new InetSocketTransportAddress(hostname, port);
client.addTransportAddress(address);
return client;
}
}
代码示例来源:origin: stackoverflow.com
// on startup
Client client = new TransportClient()
.addTransportAddress(new InetSocketTransportAddress("host1", 9300))
.addTransportAddress(new InetSocketTransportAddress("host2", 9300));
// on shutdown
client.close();
代码示例来源:origin: larsga/Duke
this.client = new TransportClient(settings.build());
代码示例来源:origin: stackoverflow.com
@ApplicationScoped
public class ESClient {
@Produces
@ApplicationScoped
public Client createClient() {
return new TransportClient().addTransportAddress(new InetSocketTransportAddress(IP, 9300));
}
}
代码示例来源:origin: lordofthejars/nosql-unit
private TransportClient getClient() {
if(this.elasticsearchConfiguration.getSettings() == null) {
return new TransportClient();
} else {
return new TransportClient(this.elasticsearchConfiguration.getSettings());
}
}
代码示例来源:origin: lordofthejars/nosql-unit
private TransportClient getClient() {
if(this.elasticsearchConfiguration.getSettings() == null) {
return new TransportClient();
} else {
return new TransportClient(this.elasticsearchConfiguration.getSettings());
}
}
代码示例来源:origin: infochimps-labs/wonderdog
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");
}
代码示例来源:origin: ff4j/ff4j
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;
}
代码示例来源:origin: hmsonline/storm-elastic-search
@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
+ "]");
}
代码示例来源:origin: infochimps-labs/wonderdog
/**
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));
}
代码示例来源:origin: infochimps-labs/wonderdog
/**
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));
}
代码示例来源:origin: ujmp/universal-java-matrix-package
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));
}
}
代码示例来源:origin: com.netflix.raigad/raigad
@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);
}
代码示例来源:origin: pinterest/soundwave
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));
}
内容来源于网络,如有侵权,请联系作者删除!