- In case of an unknown (non-documented) exception inside "LoaderAndChecker.invokeAllTasksAndWait", now it will be logged and the app will gently shut down with an error-message in the Error-stream.

- Avoid double-checking for handledAssignments -in order to delete their full-texts- when the app is about to shut down, in case the "maxAssignmentsBatchesToHandleBeforeRestart" is set above Zero.
master
Lampros Smyrnaios 2 years ago
parent 92d011e8a0
commit 8abb260d60

@ -62,7 +62,7 @@ public class UrlsWorkerApplication {
} }
public static void gentleShutdown() public static void gentleAppShutdown()
{ {
int exitCode = SpringApplication.exit(context, () -> 0); // The "PreDestroy" method will be called. int exitCode = SpringApplication.exit(context, () -> 0); // The "PreDestroy" method will be called.
System.exit(exitCode); System.exit(exitCode);

@ -9,6 +9,7 @@ import eu.openaire.publications_retriever.util.url.DataToBeLogged;
import eu.openaire.publications_retriever.util.url.LoaderAndChecker; import eu.openaire.publications_retriever.util.url.LoaderAndChecker;
import eu.openaire.publications_retriever.util.url.UrlUtils; import eu.openaire.publications_retriever.util.url.UrlUtils;
import eu.openaire.urls_worker.UrlsWorkerApplication; import eu.openaire.urls_worker.UrlsWorkerApplication;
import eu.openaire.urls_worker.components.ScheduledTasks;
import eu.openaire.urls_worker.models.Assignment; import eu.openaire.urls_worker.models.Assignment;
import eu.openaire.urls_worker.models.Error; import eu.openaire.urls_worker.models.Error;
import eu.openaire.urls_worker.models.Payload; import eu.openaire.urls_worker.models.Payload;
@ -127,8 +128,14 @@ public class PublicationsRetrieverPlugin {
} }
int numFailedTasks = LoaderAndChecker.invokeAllTasksAndWait(callableTasks); int numFailedTasks = LoaderAndChecker.invokeAllTasksAndWait(callableTasks);
if ( numFailedTasks == -1 ) { // The unknown exception is logged inside the above method.
System.err.println("Invoking and/or executing the callableTasks failed with the exception written in the log files!");
UrlsWorkerApplication.gentleAppShutdown();
}
if ( numFailedTasks > 0 ) if ( numFailedTasks > 0 )
logger.warn(numFailedTasks + " tasks failed, from assignments_" + assignmentRequestCounter); logger.warn(numFailedTasks + " tasks failed, from assignments_" + assignmentRequestCounter);
addUrlReportsToWorkerReport(); addUrlReportsToWorkerReport();
callableTasks.clear(); // Reset the thread-tasks-list for the next batch. callableTasks.clear(); // Reset the thread-tasks-list for the next batch.

@ -138,8 +138,7 @@ public class AssignmentsHandler {
if ( AssignmentsHandler.numHandledAssignmentsBatches == UrlsWorkerApplication.maxAssignmentsBatchesToHandleBeforeRestart ) if ( AssignmentsHandler.numHandledAssignmentsBatches == UrlsWorkerApplication.maxAssignmentsBatchesToHandleBeforeRestart )
{ {
logger.info("The maximum assignments-batches (" + UrlsWorkerApplication.maxAssignmentsBatchesToHandleBeforeRestart + ") to be handled was reached! Shut down, in order for the external Linux-service to restart on its own.."); logger.info("The maximum assignments-batches (" + UrlsWorkerApplication.maxAssignmentsBatchesToHandleBeforeRestart + ") to be handled was reached! Shut down, in order for the external Linux-service to restart on its own..");
ScheduledTasks.deleteHandledAssignmentsFullTexts(); UrlsWorkerApplication.gentleAppShutdown();
UrlsWorkerApplication.gentleShutdown();
} }
} }

Loading…
Cancel
Save