本文整理了Java中org.elasticsearch.client.transport.TransportClient.addTransportAddresses()
方法的一些代码示例,展示了TransportClient.addTransportAddresses()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TransportClient.addTransportAddresses()
方法的具体详情如下:
包路径:org.elasticsearch.client.transport.TransportClient
类名称:TransportClient
方法名:addTransportAddresses
[英]Adds a list of transport addresses that will be used to connect to.
The Node this transport address represents will be used if its possible to connect to it. If it is unavailable, it will be automatically connected to once it is up.
In order to get the list of all the current connected nodes, please see #connectedNodes().
[中]添加将用于连接到的传输地址列表。
如果可能,将使用此传输地址所代表的节点连接到该节点。如果不可用,一旦启动,它将自动连接到。
要获取当前连接的所有节点的列表,请参阅#connectedNodes()。
代码示例来源:origin: Aconex/scrutineer
private void addTransportClients(ScrutineerCommandLineOptions options) {
TransportAddress[] transportAddresses = options.elasticSearchHosts.toArray(new TransportAddress[0]);
client.addTransportAddresses(transportAddresses);
}
代码示例来源:origin: souyunku/SpringBootExamples
@Bean
public TransportClient init() {
TransportClient transportClient = null;
try {
// 配置信息
Settings esSetting = Settings.builder()
.put("cluster.name", clusterName)
.put("client.transport.sniff", true)//增加嗅探机制,找到ES集群
.put("thread_pool.search.size", Integer.parseInt(poolSize))//增加线程池个数,暂时设为5
.build();
transportClient = new PreBuiltTransportClient(esSetting);
InetSocketTransportAddress inetSocketTransportAddress = new InetSocketTransportAddress(InetAddress.getByName(hostName), Integer.valueOf(port));
transportClient.addTransportAddresses(inetSocketTransportAddress);
} catch (Exception e) {
LOGGER.error("elasticsearch TransportClient create error!!!", e);
}
return transportClient;
}
代码示例来源:origin: dufyun/learn-tech-collection
@Bean
public TransportClient transportClient() {
LOGGER.info("初始化开始。。。。。");
TransportClient client = null;
try {
TransportAddress transportAddress = new InetSocketTransportAddress(InetAddress.getByName(hostName),
Integer.valueOf(transport));
// 配置信息
Settings esSetting = Settings.builder()
.put("cluster.name",clusterName)
.build();
//配置信息Settings自定义,下面设置为EMPTY
client = new PreBuiltTransportClient(esSetting);
client.addTransportAddresses(transportAddress);
} catch (Exception e) {
LOGGER.error("elasticsearch TransportClient create error!!!", e);
}
return client;
}
}
代码示例来源:origin: xuxueli/xxl-search
instance = TransportClient.builder().settings(settings).build().addTransportAddresses(transportAddresses);
代码示例来源:origin: rmagen/elastic-gremlin
public static TransportClient createTransportClient(String clusterName, InetSocketTransportAddress... addresses) {
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", clusterName)
.put("client.transport.sniff", true).build();
TransportClient transportClient = new TransportClient(settings).addTransportAddresses(addresses);
return transportClient;
}
代码示例来源:origin: apache/jena
tc.addTransportAddresses(addresses.toArray(socketAddresses));
client = tc;
LOGGER.debug("Successfully initialized the client");
代码示例来源:origin: dropwizard/dropwizard-elasticsearch
} else {
final TransportAddress[] addresses = TransportAddressHelper.fromHostAndPorts(config.getServers());
this.client = TransportClient.builder().settings(settings).build().addTransportAddresses(addresses);
代码示例来源:origin: javanna/elasticshell
protected ShellNativeClient newTransportClient(TransportAddress... addresses) {
Settings settings = ImmutableSettings.settingsBuilder().put("client.transport.ignore_cluster_name", true).build();
org.elasticsearch.client.transport.TransportClient client = new TransportClient(settings).addTransportAddresses(addresses);
//if no connected node we can already close the (useless) client
if (client.connectedNodes().size() == 0) {
client.close();
return null;
}
AbstractClient<TransportClient, JsonInput, JsonOutput> shellClient = clientWrapper.wrapEsTransportClient(client);
resourceRegistry.registerResource(shellClient);
ShellNativeClient shellNativeClient = clientWrapper.wrapShellClient(shellClient);
clientScopeSynchronizerRunner.startSynchronizer(shellNativeClient);
return shellNativeClient;
}
}
内容来源于网络,如有侵权,请联系作者删除!