Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-82701 || Update Search configs and naming #127

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck> reported by reviewdog 🐶
Abbreviation in name 'LOGGER' must contain no more than '1' consecutive capital letters.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck> reported by reviewdog 🐶
Member name 'LOGGER' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.


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,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck> reported by reviewdog 🐶
Missing a Javadoc comment.

@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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck> reported by reviewdog 🐶
'if' child has incorrect indentation level 10, expected level should be 22.


// 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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck> reported by reviewdog 🐶
'if' child has incorrect indentation level 10, expected level should be 22.

}
}
});
}

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
Loading