Skip to content

Commit

Permalink
rename NEW to WAITING
Browse files Browse the repository at this point in the history
  • Loading branch information
sterlp committed Dec 28, 2024
1 parent 0e9183d commit fa37b5b
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import java.util.Set;

public enum TriggerStatus {
NEW,
WAITING,
RUNNING,
SUCCESS,
FAILED,
CANCELED
;
public static final Set<TriggerStatus> ACTIVE_STATES = EnumSet.of(NEW, RUNNING);
public static final Set<TriggerStatus> ACTIVE_STATES = EnumSet.of(WAITING, RUNNING);
public static final Set<TriggerStatus> END_STATES = EnumSet.of(SUCCESS, FAILED, CANCELED);
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public List<TriggerEntity> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class LockNextTriggerComponent {

public List<TriggerEntity> 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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit fa37b5b

Please sign in to comment.