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

com.epam.reportportal.log.LogProcessing Maven / Gradle / Ivy

There is a newer version: 5.13.0
Show newest version
package com.epam.reportportal.log;

import com.epam.reportportal.calculation.BatchProcessing;
import com.epam.reportportal.elastic.ElasticSearchClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.concurrent.DefaultManagedTaskScheduler;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * Batch processing for log.
 * @author Maksim Antonov
 */
@Component
@ConditionalOnProperty(prefix = "rp.elasticsearch", name = "host")
public class LogProcessing extends BatchProcessing {

    private final ElasticSearchClient elasticSearchClient;

    public LogProcessing(ElasticSearchClient elasticSearchClient,
                         @Value("${rp.processing.log.maxBatchSize}") int batchSize,
                         @Value("${rp.processing.log.maxBatchTimeout}") int timeout) {
        super(batchSize, timeout, new DefaultManagedTaskScheduler());
        this.elasticSearchClient = elasticSearchClient;
    }

    @Override
    protected void process(List logMessageList) {
        if (!CollectionUtils.isEmpty(logMessageList)) {
            elasticSearchClient.save(logMessageList);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy