From 721345d9a27d1cba0035270f1bcf1b8bc0090021 Mon Sep 17 00:00:00 2001 From: Andrei Piankouski Date: Mon, 12 Feb 2024 15:57:19 +0300 Subject: [PATCH] EPMRPP-82701 || Update Search configs and naming --- .../rabbit/BackgroundProcessingConfiguration.java | 2 +- ...rchClient.java => EmptySearchEngineClient.java} | 4 ++-- ...icSearchClient.java => SearchEngineClient.java} | 4 ++-- ...chClient.java => SimpleSearchEngineClient.java} | 14 +++++++------- .../reportportal/jobs/clean/CleanLaunchJob.java | 14 +++++++------- .../epam/reportportal/jobs/clean/CleanLogJob.java | 14 +++++++------- .../jobs/processing/SaveLogMessageJob.java | 2 +- .../com/epam/reportportal/log/LogProcessing.java | 12 ++++++------ src/main/resources/application.yml | 2 +- 9 files changed, 34 insertions(+), 34 deletions(-) rename src/main/java/com/epam/reportportal/elastic/{EmptyElasticSearchClient.java => EmptySearchEngineClient.java} (78%) rename src/main/java/com/epam/reportportal/elastic/{ElasticSearchClient.java => SearchEngineClient.java} (78%) rename src/main/java/com/epam/reportportal/elastic/{SimpleElasticSearchClient.java => SimpleSearchEngineClient.java} (89%) diff --git a/src/main/java/com/epam/reportportal/config/rabbit/BackgroundProcessingConfiguration.java b/src/main/java/com/epam/reportportal/config/rabbit/BackgroundProcessingConfiguration.java index 2e05a11..079052d 100644 --- a/src/main/java/com/epam/reportportal/config/rabbit/BackgroundProcessingConfiguration.java +++ b/src/main/java/com/epam/reportportal/config/rabbit/BackgroundProcessingConfiguration.java @@ -15,7 +15,7 @@ * @author Maksim Antonov */ @Configuration -@ConditionalOnProperty(prefix = "rp.elasticsearch", name = "host") +@ConditionalOnProperty(prefix = "rp.searchengine", name = "host") public class BackgroundProcessingConfiguration { public static final String LOG_MESSAGE_SAVING_QUEUE_NAME = "log_message_saving"; diff --git a/src/main/java/com/epam/reportportal/elastic/EmptyElasticSearchClient.java b/src/main/java/com/epam/reportportal/elastic/EmptySearchEngineClient.java similarity index 78% rename from src/main/java/com/epam/reportportal/elastic/EmptyElasticSearchClient.java rename to src/main/java/com/epam/reportportal/elastic/EmptySearchEngineClient.java index 11bc6ab..779fa38 100644 --- a/src/main/java/com/epam/reportportal/elastic/EmptyElasticSearchClient.java +++ b/src/main/java/com/epam/reportportal/elastic/EmptySearchEngineClient.java @@ -5,12 +5,12 @@ import org.springframework.stereotype.Service; /** - * Empty client to work with Elasticsearch. + * Empty client to work with Search engine. * * @author Maksim Antonov */ @Service -public class EmptyElasticSearchClient implements ElasticSearchClient { +public class EmptySearchEngineClient implements SearchEngineClient { @Override public void save(List logMessageList) { diff --git a/src/main/java/com/epam/reportportal/elastic/ElasticSearchClient.java b/src/main/java/com/epam/reportportal/elastic/SearchEngineClient.java similarity index 78% rename from src/main/java/com/epam/reportportal/elastic/ElasticSearchClient.java rename to src/main/java/com/epam/reportportal/elastic/SearchEngineClient.java index b81ed57..8efd483 100644 --- a/src/main/java/com/epam/reportportal/elastic/ElasticSearchClient.java +++ b/src/main/java/com/epam/reportportal/elastic/SearchEngineClient.java @@ -4,11 +4,11 @@ import java.util.List; /** - * Client interface to work with Elasticsearch. + * Client interface to work with Search engine. * * @author Maksim Antonov */ -public interface ElasticSearchClient { +public interface SearchEngineClient { void save(List logMessageList); diff --git a/src/main/java/com/epam/reportportal/elastic/SimpleElasticSearchClient.java b/src/main/java/com/epam/reportportal/elastic/SimpleSearchEngineClient.java similarity index 89% rename from src/main/java/com/epam/reportportal/elastic/SimpleElasticSearchClient.java rename to src/main/java/com/epam/reportportal/elastic/SimpleSearchEngineClient.java index 233f437..3eab580 100644 --- a/src/main/java/com/epam/reportportal/elastic/SimpleElasticSearchClient.java +++ b/src/main/java/com/epam/reportportal/elastic/SimpleSearchEngineClient.java @@ -19,23 +19,23 @@ import org.springframework.web.client.RestTemplate; /** - * Simple client to work with Elasticsearch. + * Simple client to work with Search engine. * * @author Maksim Antonov */ @Primary @Service -@ConditionalOnProperty(prefix = "rp.elasticsearch", name = "host") -public class SimpleElasticSearchClient implements ElasticSearchClient { +@ConditionalOnProperty(prefix = "rp.searchengine", name = "host") +public class SimpleSearchEngineClient implements SearchEngineClient { - protected final Logger LOGGER = LoggerFactory.getLogger(SimpleElasticSearchClient.class); + protected final Logger LOGGER = LoggerFactory.getLogger(SimpleSearchEngineClient.class); private final String host; private final RestTemplate restTemplate; - public SimpleElasticSearchClient(@Value("${rp.elasticsearch.host}") String host, - @Value("${rp.elasticsearch.username:}") String username, - @Value("${rp.elasticsearch.password:}") String password) { + public SimpleSearchEngineClient(@Value("${rp.searchengine.host}") String host, + @Value("${rp.searchengine.username:}") String username, + @Value("${rp.searchengine.password:}") String password) { restTemplate = new RestTemplate(); if (!username.isEmpty() && !password.isEmpty()) { diff --git a/src/main/java/com/epam/reportportal/jobs/clean/CleanLaunchJob.java b/src/main/java/com/epam/reportportal/jobs/clean/CleanLaunchJob.java index 0ea68ac..a43ce5a 100644 --- a/src/main/java/com/epam/reportportal/jobs/clean/CleanLaunchJob.java +++ b/src/main/java/com/epam/reportportal/jobs/clean/CleanLaunchJob.java @@ -1,7 +1,7 @@ package com.epam.reportportal.jobs.clean; import com.epam.reportportal.analyzer.index.IndexerServiceClient; -import com.epam.reportportal.elastic.ElasticSearchClient; +import com.epam.reportportal.elastic.SearchEngineClient; import com.google.common.collect.Lists; import java.time.LocalDateTime; import java.time.ZoneOffset; @@ -35,21 +35,21 @@ public class CleanLaunchJob extends BaseCleanJob { private final CleanLogJob cleanLogJob; private final IndexerServiceClient indexerServiceClient; private final ApplicationEventPublisher eventPublisher; - private final ElasticSearchClient elasticSearchClient; + private final SearchEngineClient searchEngineClient; public CleanLaunchJob( @Value("${rp.environment.variable.elements-counter.batch-size}") Integer batchSize, JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate namedParameterJdbcTemplate, CleanLogJob cleanLogJob, IndexerServiceClient indexerServiceClient, - ApplicationEventPublisher eventPublisher, ElasticSearchClient elasticSearchClient) { + ApplicationEventPublisher eventPublisher, SearchEngineClient searchEngineClient) { super(jdbcTemplate); this.batchSize = batchSize; this.namedParameterJdbcTemplate = namedParameterJdbcTemplate; this.cleanLogJob = cleanLogJob; this.indexerServiceClient = indexerServiceClient; this.eventPublisher = eventPublisher; - this.elasticSearchClient = elasticSearchClient; + this.searchEngineClient = searchEngineClient; } @Override @@ -77,7 +77,7 @@ private void removeLaunches() { indexerServiceClient.removeFromIndexLessThanLaunchDate(projectId, lessThanDate); LOGGER.info("Send message for deletion to analyzer for project {}", projectId); - deleteLogsFromElasticsearchByLaunchIdsAndProjectId(launchIds, projectId); + deleteLogsFromSearchEngineByLaunchIdsAndProjectId(launchIds, projectId); // eventPublisher.publishEvent(new ElementsDeletedEvent(launchIds, projectId, numberOfLaunchElements)); // LOGGER.info("Send event with elements deleted number {} for project {}", deleted, projectId); @@ -86,10 +86,10 @@ private void removeLaunches() { }); } - private void deleteLogsFromElasticsearchByLaunchIdsAndProjectId(List launchIds, + private void deleteLogsFromSearchEngineByLaunchIdsAndProjectId(List launchIds, Long projectId) { for (Long launchId : launchIds) { - elasticSearchClient.deleteLogsByLaunchIdAndProjectId(launchId, projectId); + searchEngineClient.deleteLogsByLaunchIdAndProjectId(launchId, projectId); LOGGER.info("Delete logs from ES by launch {} and project {}", launchId, projectId); } } diff --git a/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java b/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java index 0446356..20c25d6 100644 --- a/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java +++ b/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java @@ -1,7 +1,7 @@ package com.epam.reportportal.jobs.clean; import com.epam.reportportal.analyzer.index.IndexerServiceClient; -import com.epam.reportportal.elastic.ElasticSearchClient; +import com.epam.reportportal.elastic.SearchEngineClient; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.List; @@ -29,18 +29,18 @@ public class CleanLogJob extends BaseCleanJob { private final CleanAttachmentJob cleanAttachmentJob; private final IndexerServiceClient indexerServiceClient; private final ApplicationEventPublisher eventPublisher; - private final ElasticSearchClient elasticSearchClient; + private final SearchEngineClient searchEngineClient; private final NamedParameterJdbcTemplate namedParameterJdbcTemplate; public CleanLogJob(JdbcTemplate jdbcTemplate, CleanAttachmentJob cleanAttachmentJob, IndexerServiceClient indexerServiceClient, ApplicationEventPublisher eventPublisher, - ElasticSearchClient elasticSearchClient, + SearchEngineClient searchEngineClient, NamedParameterJdbcTemplate namedParameterJdbcTemplate) { super(jdbcTemplate); this.cleanAttachmentJob = cleanAttachmentJob; this.indexerServiceClient = indexerServiceClient; this.eventPublisher = eventPublisher; - this.elasticSearchClient = elasticSearchClient; + this.searchEngineClient = searchEngineClient; this.namedParameterJdbcTemplate = namedParameterJdbcTemplate; } @@ -68,16 +68,16 @@ void removeLogs() { final List launchIds = getLaunchIds(projectId, lessThanDate); if (!launchIds.isEmpty()) { - deleteLogsFromElasticsearchByLaunchIdsAndProjectId(launchIds, projectId); + deleteLogsFromSearchEngineByLaunchIdsAndProjectId(launchIds, projectId); } } }); } - private void deleteLogsFromElasticsearchByLaunchIdsAndProjectId(List launchIds, + private void deleteLogsFromSearchEngineByLaunchIdsAndProjectId(List launchIds, Long projectId) { for (Long launchId : launchIds) { - elasticSearchClient.deleteLogsByLaunchIdAndProjectId(launchId, projectId); + searchEngineClient.deleteLogsByLaunchIdAndProjectId(launchId, projectId); LOGGER.info("Delete logs from ES by launch {} and project {}", launchId, projectId); } } diff --git a/src/main/java/com/epam/reportportal/jobs/processing/SaveLogMessageJob.java b/src/main/java/com/epam/reportportal/jobs/processing/SaveLogMessageJob.java index 4a93e6b..fb121fe 100644 --- a/src/main/java/com/epam/reportportal/jobs/processing/SaveLogMessageJob.java +++ b/src/main/java/com/epam/reportportal/jobs/processing/SaveLogMessageJob.java @@ -14,7 +14,7 @@ * @author Maksim Antonov */ @Service -@ConditionalOnProperty(prefix = "rp.elasticsearch", name = "host") +@ConditionalOnProperty(prefix = "rp.searchengine", name = "host") public class SaveLogMessageJob { public static final String LOG_MESSAGE_SAVING_QUEUE_NAME = "log_message_saving"; diff --git a/src/main/java/com/epam/reportportal/log/LogProcessing.java b/src/main/java/com/epam/reportportal/log/LogProcessing.java index 2781596..e07b55c 100644 --- a/src/main/java/com/epam/reportportal/log/LogProcessing.java +++ b/src/main/java/com/epam/reportportal/log/LogProcessing.java @@ -1,7 +1,7 @@ package com.epam.reportportal.log; import com.epam.reportportal.calculation.BatchProcessing; -import com.epam.reportportal.elastic.ElasticSearchClient; +import com.epam.reportportal.elastic.SearchEngineClient; import java.util.List; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -15,22 +15,22 @@ * @author Maksim Antonov */ @Component -@ConditionalOnProperty(prefix = "rp.elasticsearch", name = "host") +@ConditionalOnProperty(prefix = "rp.searchengine", name = "host") public class LogProcessing extends BatchProcessing { - private final ElasticSearchClient elasticSearchClient; + private final SearchEngineClient searchEngineClient; - public LogProcessing(ElasticSearchClient elasticSearchClient, + public LogProcessing(SearchEngineClient searchEngineClient, @Value("${rp.processing.log.maxBatchSize}") int batchSize, @Value("${rp.processing.log.maxBatchTimeout}") int timeout) { super(batchSize, timeout, new DefaultManagedTaskScheduler()); - this.elasticSearchClient = elasticSearchClient; + this.searchEngineClient = searchEngineClient; } @Override protected void process(List logMessageList) { if (!CollectionUtils.isEmpty(logMessageList)) { - elasticSearchClient.save(logMessageList); + searchEngineClient.save(logMessageList); } } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d60d20d..588149e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -45,7 +45,7 @@ rp: project: core: 5 max: 10 -# elasticsearch: +# searchengine: # host: http://elasticsearch:9200 # username: # password: