From 316baa355c5dfea69b3014c4d8ec74f1429d57ee Mon Sep 17 00:00:00 2001 From: Olin Blodgett Date: Mon, 6 Jan 2025 10:21:10 -0500 Subject: [PATCH] Added forced stopped job status --- .../org/alliancegenome/curation_api/enums/JobStatus.java | 8 ++++---- .../curation_api/jobs/executors/LoadFileExecutor.java | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/alliancegenome/curation_api/enums/JobStatus.java b/src/main/java/org/alliancegenome/curation_api/enums/JobStatus.java index 52810fb94..6beb9ef5b 100644 --- a/src/main/java/org/alliancegenome/curation_api/enums/JobStatus.java +++ b/src/main/java/org/alliancegenome/curation_api/enums/JobStatus.java @@ -4,11 +4,11 @@ public enum JobStatus { SCHEDULED_PENDING, SCHEDULED_STARTED, SCHEDULED_RUNNING, - FORCED_PENDING, FORCED_STARTED, FORCED_RUNNING, + FORCED_PENDING, FORCED_STARTED, FORCED_RUNNING, FORCED_STOPPED, MANUAL_PENDING, MANUAL_STARTED, MANUAL_RUNNING, - FAILED, STOPPED, FINISHED, + FAILED, STOPPED, FINISHED ; @@ -25,7 +25,7 @@ public boolean isStarted() { } public boolean isNotRunning() { - return this == FAILED || this == STOPPED || this == FINISHED; + return this == FAILED || this == STOPPED || this == FINISHED || this == FORCED_STOPPED; } public JobStatus getNextStatus() { @@ -54,6 +54,6 @@ public JobStatus getNextStatus() { } public boolean isForced() { - return this == FORCED_PENDING || this == FORCED_STARTED || this == FORCED_RUNNING; + return this == FORCED_PENDING || this == FORCED_STARTED || this == FORCED_RUNNING || this == FORCED_STOPPED; } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java index 7deba9e9e..712e7fd78 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java @@ -218,6 +218,9 @@ protected boolean runLoad(BaseUpser } protected boolean runLoad(BaseUpsertServiceInterface service, BulkLoadFileHistory history, BackendBulkDataProvider dataProvider, List objectList, List idsAdded, Boolean terminateFailing, String countType, String dataType) { + if (Thread.currentThread().isInterrupted()) { + return false; + } ProcessDisplayHelper ph = new ProcessDisplayHelper(); ph.addDisplayHandler(loadProcessDisplayService); if (CollectionUtils.isNotEmpty(objectList)) { @@ -256,6 +259,7 @@ protected boolean runLoad(BaseUpser } ph.progressProcess(); if (Thread.currentThread().isInterrupted()) { + history.setBulkloadStatus(JobStatus.FORCED_STOPPED); Log.info("Thread Interrupted:"); break; } @@ -273,6 +277,9 @@ protected boolean runLoad(BaseUpser // The following methods are for bulk validation protected > void runCleanup(S service, BulkLoadFileHistory history, String dataProviderName, List annotationIdsBefore, List annotationIdsAfter, String loadTypeString, Boolean deprecate) { + if (Thread.currentThread().isInterrupted()) { + return; + } Log.debug("runLoad: After: " + dataProviderName + " " + annotationIdsAfter.size()); List distinctAfter = annotationIdsAfter.stream().distinct().collect(Collectors.toList()); @@ -307,6 +314,7 @@ protected boolean runLoad(BaseUpser } ph.progressProcess(); if (Thread.currentThread().isInterrupted()) { + history.setBulkloadStatus(JobStatus.FORCED_STOPPED); Log.info("Thread Interrupted:"); break; }