Skip to content

Commit

Permalink
EPMRPP-82701 || Update Search configs and naming
Browse files Browse the repository at this point in the history
  • Loading branch information
APiankouski authored Feb 19, 2024
2 parents 6b4a77c + 721345d commit 0e5aa0e
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @author <a href="mailto:[email protected]">Maksim Antonov</a>
*/
@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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import org.springframework.stereotype.Service;

/**
* Empty client to work with Elasticsearch.
* Empty client to work with Search engine.
*
* @author <a href="mailto:[email protected]">Maksim Antonov</a>
*/
@Service
public class EmptyElasticSearchClient implements ElasticSearchClient {
public class EmptySearchEngineClient implements SearchEngineClient {

@Override
public void save(List<LogMessage> logMessageList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import java.util.List;

/**
* Client interface to work with Elasticsearch.
* Client interface to work with Search engine.
*
* @author <a href="mailto:[email protected]">Maksim Antonov</a>
*/
public interface ElasticSearchClient {
public interface SearchEngineClient {

void save(List<LogMessage> logMessageList);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@
import org.springframework.web.client.RestTemplate;

/**
* Simple client to work with Elasticsearch.
* Simple client to work with Search engine.
*
* @author <a href="mailto:[email protected]">Maksim Antonov</a>
*/
@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()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -86,10 +86,10 @@ private void removeLaunches() {
});
}

private void deleteLogsFromElasticsearchByLaunchIdsAndProjectId(List<Long> launchIds,
private void deleteLogsFromSearchEngineByLaunchIdsAndProjectId(List<Long> 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);
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -68,16 +68,16 @@ void removeLogs() {

final List<Long> launchIds = getLaunchIds(projectId, lessThanDate);
if (!launchIds.isEmpty()) {
deleteLogsFromElasticsearchByLaunchIdsAndProjectId(launchIds, projectId);
deleteLogsFromSearchEngineByLaunchIdsAndProjectId(launchIds, projectId);
}
}
});
}

private void deleteLogsFromElasticsearchByLaunchIdsAndProjectId(List<Long> launchIds,
private void deleteLogsFromSearchEngineByLaunchIdsAndProjectId(List<Long> 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @author <a href="mailto:[email protected]">Maksim Antonov</a>
*/
@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";
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/epam/reportportal/log/LogProcessing.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,22 +15,22 @@
* @author <a href="mailto:[email protected]">Maksim Antonov</a>
*/
@Component
@ConditionalOnProperty(prefix = "rp.elasticsearch", name = "host")
@ConditionalOnProperty(prefix = "rp.searchengine", name = "host")
public class LogProcessing extends BatchProcessing<LogMessage> {

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<LogMessage> logMessageList) {
if (!CollectionUtils.isEmpty(logMessageList)) {
elasticSearchClient.save(logMessageList);
searchEngineClient.save(logMessageList);
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ rp:
project:
core: 5
max: 10
# elasticsearch:
# searchengine:
# host: http://elasticsearch:9200
# username:
# password:
Expand Down

0 comments on commit 0e5aa0e

Please sign in to comment.