Reduce the waiting time for new background tasks to be scheduled for processing.

This commit is contained in:
Lampros Smyrnaios 2023-07-24 20:33:56 +03:00
parent d821ae398f
commit 8d8a387ff2
1 changed files with 4 additions and 3 deletions

View File

@ -66,8 +66,9 @@ public class ScheduledTasks {
}
@Scheduled(initialDelay = 1_800_000, fixedDelay = 1_800_000) // Execute this method 30 mins from the start and 30 mins after each last execution, in order for some tasks to have been gathered.
//@Scheduled(initialDelay = 20_000, fixedDelay = 20_000) // Just for testing (every 20 secs).
@Scheduled(initialDelay = 1_800_000, fixedDelay = 900_000) // Execute this method 30 mins from the start and 15 mins after each last execution, in order for some tasks to have been gathered.
//@Scheduled(initialDelay = 60_000, fixedDelay = 20_000) // Just for testing (every 20 secs).
// The initial delay is larger, because we have to wait some time for at least one worker to finish retrieving the full-texts from thousands of publications, whereas, later we will have a lot of workerReports waiting to be processed.
public void executeBackgroundTasks()
{
List<Callable<Boolean>> tempList = new ArrayList<>(UrlsController.backgroundCallableTasks); // Copy the list in order to know what was executed.
@ -76,7 +77,7 @@ public class ScheduledTasks {
if ( numOfTasks == 0 )
return;
// Immediately delete the selected tasks form the global list, so that if these tasks are not finished before the scheduler runs again, they will not be re-executed.
// Immediately delete the selected tasks form the global list, so that if these tasks are not finished before the scheduler runs again, they will not be re-processed.
for ( Callable<Boolean> selectedTask : tempList )
UrlsController.backgroundCallableTasks.remove(selectedTask);