Browse Source

- 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 5 months ago
parent
commit
8abb260d60
  1. 2
      src/main/java/eu/openaire/urls_worker/UrlsWorkerApplication.java
  2. 7
      src/main/java/eu/openaire/urls_worker/plugins/PublicationsRetrieverPlugin.java
  3. 3
      src/main/java/eu/openaire/urls_worker/util/AssignmentsHandler.java

2
src/main/java/eu/openaire/urls_worker/UrlsWorkerApplication.java

@ -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.
System.exit(exitCode);

7
src/main/java/eu/openaire/urls_worker/plugins/PublicationsRetrieverPlugin.java

@ -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.UrlUtils;
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.Error;
import eu.openaire.urls_worker.models.Payload;
@ -127,8 +128,14 @@ public class PublicationsRetrieverPlugin {
}
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 )
logger.warn(numFailedTasks + " tasks failed, from assignments_" + assignmentRequestCounter);
addUrlReportsToWorkerReport();
callableTasks.clear(); // Reset the thread-tasks-list for the next batch.

3
src/main/java/eu/openaire/urls_worker/util/AssignmentsHandler.java

@ -138,8 +138,7 @@ public class AssignmentsHandler {
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..");
ScheduledTasks.deleteHandledAssignmentsFullTexts();
UrlsWorkerApplication.gentleShutdown();
UrlsWorkerApplication.gentleAppShutdown();
}
}

Loading…
Cancel
Save