diff --git a/core/src/main/java/org/sterl/spring/persistent_tasks/api/Trigger.java b/core/src/main/java/org/sterl/spring/persistent_tasks/api/Trigger.java index 9b409a83..689ea5be 100644 --- a/core/src/main/java/org/sterl/spring/persistent_tasks/api/Trigger.java +++ b/core/src/main/java/org/sterl/spring/persistent_tasks/api/Trigger.java @@ -32,7 +32,7 @@ public class Trigger { /** priority, the higher a more priority it will get */ private int priority = 4; - private TriggerStatus status = TriggerStatus.NEW; + private TriggerStatus status = TriggerStatus.WAITING; private Long runningDurationInMs; diff --git a/core/src/main/java/org/sterl/spring/persistent_tasks/shared/model/TriggerData.java b/core/src/main/java/org/sterl/spring/persistent_tasks/shared/model/TriggerData.java index 49df0658..c4a182db 100644 --- a/core/src/main/java/org/sterl/spring/persistent_tasks/shared/model/TriggerData.java +++ b/core/src/main/java/org/sterl/spring/persistent_tasks/shared/model/TriggerData.java @@ -74,7 +74,7 @@ public void updateRunningDuration() { @Enumerated(EnumType.STRING) @Column(length = 20, nullable = false) @Default - private TriggerStatus status = TriggerStatus.NEW; + private TriggerStatus status = TriggerStatus.WAITING; private Long runningDurationInMs; diff --git a/core/src/main/java/org/sterl/spring/persistent_tasks/shared/model/TriggerStatus.java b/core/src/main/java/org/sterl/spring/persistent_tasks/shared/model/TriggerStatus.java index 516a4521..5c4bcd0e 100644 --- a/core/src/main/java/org/sterl/spring/persistent_tasks/shared/model/TriggerStatus.java +++ b/core/src/main/java/org/sterl/spring/persistent_tasks/shared/model/TriggerStatus.java @@ -4,12 +4,12 @@ import java.util.Set; public enum TriggerStatus { - NEW, + WAITING, RUNNING, SUCCESS, FAILED, CANCELED ; - public static final Set ACTIVE_STATES = EnumSet.of(NEW, RUNNING); + public static final Set ACTIVE_STATES = EnumSet.of(WAITING, RUNNING); public static final Set END_STATES = EnumSet.of(SUCCESS, FAILED, CANCELED); } diff --git a/core/src/main/java/org/sterl/spring/persistent_tasks/trigger/TriggerService.java b/core/src/main/java/org/sterl/spring/persistent_tasks/trigger/TriggerService.java index 3253d907..0c16b3f4 100644 --- a/core/src/main/java/org/sterl/spring/persistent_tasks/trigger/TriggerService.java +++ b/core/src/main/java/org/sterl/spring/persistent_tasks/trigger/TriggerService.java @@ -157,7 +157,7 @@ public List rescheduleAbandonedTasks(OffsetDateTime timeout) { timeout); result.forEach(t -> { t.setRunningOn(null); - t.getData().setStatus(TriggerStatus.NEW); + t.getData().setStatus(TriggerStatus.WAITING); t.getData().setExceptionName("Abandoned tasks"); }); log.debug("rescheduled {} triggers", result.size()); diff --git a/core/src/main/java/org/sterl/spring/persistent_tasks/trigger/component/LockNextTriggerComponent.java b/core/src/main/java/org/sterl/spring/persistent_tasks/trigger/component/LockNextTriggerComponent.java index 98f5d8d7..46e4eb46 100644 --- a/core/src/main/java/org/sterl/spring/persistent_tasks/trigger/component/LockNextTriggerComponent.java +++ b/core/src/main/java/org/sterl/spring/persistent_tasks/trigger/component/LockNextTriggerComponent.java @@ -25,7 +25,7 @@ public class LockNextTriggerComponent { public List loadNext(String runningOn, int count, OffsetDateTime timeDueAt) { final var tasks = triggerRepository.loadNextTasks( - timeDueAt, TriggerStatus.NEW, PageRequest.of(0, count)); + timeDueAt, TriggerStatus.WAITING, PageRequest.of(0, count)); tasks.forEach(t -> t.runOn(runningOn)); diff --git a/core/src/main/java/org/sterl/spring/persistent_tasks/trigger/model/TriggerEntity.java b/core/src/main/java/org/sterl/spring/persistent_tasks/trigger/model/TriggerEntity.java index bb1d0063..89c16be0 100644 --- a/core/src/main/java/org/sterl/spring/persistent_tasks/trigger/model/TriggerEntity.java +++ b/core/src/main/java/org/sterl/spring/persistent_tasks/trigger/model/TriggerEntity.java @@ -99,7 +99,7 @@ public TriggerEntity complete(Exception e) { } public TriggerEntity runAt(OffsetDateTime runAt) { - data.setStatus(TriggerStatus.NEW); + data.setStatus(TriggerStatus.WAITING); data.setRunAt(runAt); return this; } diff --git a/core/src/test/java/org/sterl/spring/persistent_tasks/scheduler/SchedulerServiceTest.java b/core/src/test/java/org/sterl/spring/persistent_tasks/scheduler/SchedulerServiceTest.java index 9b4eb1a0..b8a25f4b 100644 --- a/core/src/test/java/org/sterl/spring/persistent_tasks/scheduler/SchedulerServiceTest.java +++ b/core/src/test/java/org/sterl/spring/persistent_tasks/scheduler/SchedulerServiceTest.java @@ -55,7 +55,7 @@ void testWillTriggerOnlyFreeThreadSize() throws Exception { // THEN Thread.sleep(15); assertThat(triggerService.countTriggers(TriggerStatus.RUNNING)).isEqualTo(10); - assertThat(triggerService.countTriggers(TriggerStatus.NEW)).isEqualTo(5); + assertThat(triggerService.countTriggers(TriggerStatus.WAITING)).isEqualTo(5); // AND final SchedulerEntity scheduler = subject.getScheduler(); assertThat(scheduler.getRunnungTasks()).isEqualTo(10); @@ -99,7 +99,7 @@ void testQueuedInFuture() { // THEN asserts.assertMissing(Task3.NAME + "::Hallo"); - assertThat(triggerService.countTriggers(TriggerStatus.NEW)).isOne(); + assertThat(triggerService.countTriggers(TriggerStatus.WAITING)).isOne(); } @Test diff --git a/core/src/test/java/org/sterl/spring/persistent_tasks/scheduler/TaskFailoverTest.java b/core/src/test/java/org/sterl/spring/persistent_tasks/scheduler/TaskFailoverTest.java index 3b69a31d..a82acec3 100644 --- a/core/src/test/java/org/sterl/spring/persistent_tasks/scheduler/TaskFailoverTest.java +++ b/core/src/test/java/org/sterl/spring/persistent_tasks/scheduler/TaskFailoverTest.java @@ -58,7 +58,7 @@ void rescheduleAbandonedTasksTest() throws Exception { // AND assertThat(triggerService.countTriggers(TriggerStatus.RUNNING)) .isEqualTo(1); - assertThat(triggerService.countTriggers(TriggerStatus.NEW)) + assertThat(triggerService.countTriggers(TriggerStatus.WAITING)) .isEqualTo(1); } } diff --git a/core/src/test/java/org/sterl/spring/persistent_tasks/trigger/TriggerServiceTest.java b/core/src/test/java/org/sterl/spring/persistent_tasks/trigger/TriggerServiceTest.java index 24357331..5f2f1db1 100644 --- a/core/src/test/java/org/sterl/spring/persistent_tasks/trigger/TriggerServiceTest.java +++ b/core/src/test/java/org/sterl/spring/persistent_tasks/trigger/TriggerServiceTest.java @@ -288,7 +288,7 @@ void testQueuedInFuture() { // THEN asserts.assertMissing(Task3.NAME + "::Hallo"); - assertThat(triggerService.countTriggers(TriggerStatus.NEW)).isOne(); + assertThat(triggerService.countTriggers(TriggerStatus.WAITING)).isOne(); } @Test @@ -306,7 +306,7 @@ void testUpdateRunAt() { // THEN runTriggersAndWait(); asserts.assertValue(Task3.NAME + "::Hallo"); - assertThat(triggerService.countTriggers(TriggerStatus.NEW)).isZero(); + assertThat(triggerService.countTriggers(TriggerStatus.WAITING)).isZero(); } @Test