Commit 8531a376 authored by suhuiguang's avatar suhuiguang

style(cm): es初始请求

1.注释修改
parent 3da02830
...@@ -31,8 +31,7 @@ public class ElasticSearchClientConfig { ...@@ -31,8 +31,7 @@ public class ElasticSearchClientConfig {
@Bean(destroyMethod = "close") @Bean(destroyMethod = "close")
public RestHighLevelClient restHighLevelClient() { public RestHighLevelClient restHighLevelClient() {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
new UsernamePasswordCredentials(username, password));
try { try {
HttpHost[] httpHosts = Arrays.stream(uris.split(",")).map(HttpHost::create).toArray(HttpHost[]::new); HttpHost[] httpHosts = Arrays.stream(uris.split(",")).map(HttpHost::create).toArray(HttpHost[]::new);
...@@ -50,10 +49,9 @@ public class ElasticSearchClientConfig { ...@@ -50,10 +49,9 @@ public class ElasticSearchClientConfig {
}); });
// 请求级参数配置 // 请求级参数配置
builder.setRequestConfigCallback(requestConfigBuilder -> { builder.setRequestConfigCallback(requestConfigBuilder -> {
// 连接超时(默认为1秒) return requestConfigBuilder
return requestConfigBuilder.setConnectTimeout(5000 * 1000) .setConnectTimeout(5000 * 1000) // 连接超时毫秒
// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟 .setSocketTimeout(6000 * 1000); // 读取超时毫秒
.setSocketTimeout(6000 * 1000);
}); });
return new RestHighLevelClient(builder); return new RestHighLevelClient(builder);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment