All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.flood.log.services.impl.ElasticsearchServiceImpl.aj Maven / Gradle / Ivy

The newest version!
package cn.flood.log.services.impl;

import cn.flood.log.model.Audit;
import cn.flood.log.services.IAuditService;
import lombok.extern.slf4j.Slf4j;

/**
 * TODO
 */
@Slf4j
//@ConditionalOnProperty(name = "spring.audit-log.log-type", havingValue = "es")
//@ConditionalOnClass(RestHighLevelClient.class)
public class ElasticsearchServiceImpl implements IAuditService {

//    private final ElasticsearchRestTemplate searchRestTemplate;
//
//    public ElasticsearchServiceImpl(@Autowired(required = false) LogElasticsearchProperties elasticsearchProperties,
//                                    @Autowired(required = false) LogRestClientPoolProperties poolProperties,
//                                    RestHighLevelClient restHighLevelClient){
//        if(elasticsearchProperties != null &&  StringUtils.isNotEmpty(elasticsearchProperties.getHostNames())){
//            String[] hostNames = elasticsearchProperties.getHostNames().split(",");
//            HttpHost[] httpHostList = new HttpHost[hostNames.length];
//            for(int i=0; i {
//                requestConfigBuilder.setConnectTimeout(poolProperties.getConnectTimeOut())
//                        .setSocketTimeout(poolProperties.getSocketTimeOut())
//                        .setConnectionRequestTimeout(poolProperties.getConnectionRequestTimeOut());
//                return requestConfigBuilder;
//            });
//            /**
//             * 异步httpclient连接数配置
//             */
//            if (org.springframework.util.StringUtils.hasText(elasticsearchProperties.getUsername()) && org.springframework.util.StringUtils.hasText(elasticsearchProperties.getPassword())) {
//                CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
//                credentialsProvider.setCredentials(AuthScope.ANY,
//                        new UsernamePasswordCredentials(elasticsearchProperties.getUsername(), elasticsearchProperties.getPassword()));
//                restClientBuilder.setHttpClientConfigCallback(httpAsyncClientBuilder ->
//                        httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider).
//                                setMaxConnTotal(poolProperties.getMaxConnectNum()).
//                                setMaxConnPerRoute(poolProperties.getMaxConnectPerRoute())
//                );
//            }
//            restHighLevelClient = new RestHighLevelClient(restClientBuilder);
//        }
//        this.searchRestTemplate = new ElasticsearchRestTemplate(restHighLevelClient);
//    }
//
//    @Async
    @Override
    public void save(Audit audit) {
        //es插入
//        restHighLevelClient.
    }
//
//    @PostConstruct
    public void init() {
        //初始化es表结果
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy