package com.alibaba.otter.canal.config; import com.alibaba.otter.canal.constants.ModuleEnum; import com.alibaba.otter.canal.custom.CanalLogUtil; import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpHost; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestHighLevelClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * @author kaikai_zheng * @version 1.0.0 * @className ESConfig * @description //ES配置类 * @data 2020-07-13 18:48 */ @Configuration @Slf4j public class ESConfig { private final static String HOST_IP = "47.101.179.162"; private final static int PORT = 9200; private final static String PROTOCAL = "http"; @Bean(destroyMethod = "close") public RestHighLevelClient client() { RestHighLevelClient client = new RestHighLevelClient(RestClient.builder( new HttpHost(HOST_IP, PORT, PROTOCAL) )); if (null != client) { CanalLogUtil.info(ModuleEnum.CANAL_CLIENT.getCode(), "ESConfig connect es success"); } return client; } }