https://cloud.tencent.com/developer/article/1784917

jestClient-ES客户端配置:https://blog.csdn.net/weixin_42685328/article/details/111408562

https://github.com/searchbox-io/Jest

_nodes/_all/http

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public static JestClient getJestClient(ConfigureBean configureBean) {
if (jest == null) {
synchronized (JestESClient.class) {
if (jest == null) {
JestClientFactory factory = new JestClientFactory();
String esHosts = configureBean.getEsHost();
LOG.info("esHost: {}", esHosts);
if (StringUtils.isBlank(esHosts)){
throw new IllegalArgumentException("event.db.host must not be empty");
}

List<String> servers = new ArrayList<>();
String[] hosts = esHosts.split(",");
LOG.info("esHost number: {}", hosts.length);
for (String host : hosts){
servers.add(StringUtils.join("http://", host, ":", configureBean.getEsPort()));
}
factory.setHttpClientConfig(
new HttpClientConfig.Builder(servers)
.discoveryEnabled(true)
.discoveryFrequency(3L, TimeUnit.SECONDS)
.multiThreaded(true)
.defaultMaxTotalConnectionPerRoute(configureBean.getDefaultMaxTotalConnectionPerRoute())
.maxTotalConnection(configureBean.getMaxTotalConnection())
.maxConnectionIdleTime(configureBean.getMaxConnectionIdleTime(), TimeUnit.SECONDS)
.connTimeout(configureBean.getConnTimeout())
.readTimeout(configureBean.getReadTimeout()).build());

jest = factory.getObject();
}
}
}

return jest;
}