|
@@ -1,45 +0,0 @@
|
|
|
-package com.persagy.apm.alarmservice.common.configuration;
|
|
|
-
|
|
|
-import org.apache.http.HttpHost;
|
|
|
-import org.elasticsearch.client.RestClient;
|
|
|
-import org.elasticsearch.client.RestHighLevelClient;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.context.annotation.Bean;
|
|
|
-import org.springframework.context.annotation.Configuration;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author 易涛
|
|
|
- * @version 1.0
|
|
|
- * @date 2021/9/7 18:05
|
|
|
- */
|
|
|
-@Configuration
|
|
|
-public class ElasticSearchConfig {
|
|
|
-
|
|
|
- @Value("${elasticsearch.host}")
|
|
|
- private String host;
|
|
|
-
|
|
|
- @Value("${energy.es.port}")
|
|
|
- private int port;
|
|
|
-
|
|
|
- @Value("${elasticsearch.connectTimeout:15000}")
|
|
|
- private int connectTimeout;
|
|
|
-
|
|
|
- @Value("${elasticsearch.socketTimeout:15000}")
|
|
|
- private int socketTimeout;
|
|
|
-
|
|
|
- @Value("${elasticsearch.connectionRequestTimeout:15000}")
|
|
|
- private int connectionRequestTimeout;
|
|
|
-
|
|
|
- @Bean(destroyMethod = "close",name = "client")
|
|
|
- public RestHighLevelClient restHighLevelClient() {
|
|
|
- return new RestHighLevelClient(
|
|
|
- RestClient.builder(
|
|
|
- new HttpHost(host, port, "http")
|
|
|
- ).setRequestConfigCallback(requestConfigBuilder->requestConfigBuilder
|
|
|
- .setConnectTimeout(connectTimeout)
|
|
|
- .setSocketTimeout(socketTimeout)
|
|
|
- .setConnectionRequestTimeout(connectionRequestTimeout))
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
-}
|