package eu.openaire.pdf_aggregation_statistics.Components; import eu.openaire.pdf_aggregation_statistics.services.StatsService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @Component public class SchedulingTasks { private static final Logger logger = LoggerFactory.getLogger(SchedulingTasks.class); @Autowired StatsService statsService; @Scheduled(initialDelay = 1, fixedDelay = 21_600_000) // Run right after initialization and then every 6 hours. public void gatherPayloadsPerDatasource() { // Request the number of payloads for each datasource and keep them in a ConcurrentHashMap, // where the "key" will be the "datasourceId" and the "value" will be the numOfPayloads for that datasource. // When the user requests the numOfPayloads for a given datasourceI, the app will return the rwsult immediately // It will be a quick O(1) get operation in the HashMap. statsService.gatherNumberOfPayloadsPerDatasource(); } }