|
@@ -8,7 +8,6 @@ import java.util.concurrent.ScheduledExecutorService;
|
|
|
import java.util.concurrent.ScheduledFuture;
|
|
import java.util.concurrent.ScheduledFuture;
|
|
|
|
|
|
|
|
import static cz.senslog.watchdog.util.TimeConverter.secToMillis;
|
|
import static cz.senslog.watchdog.util.TimeConverter.secToMillis;
|
|
|
-import static java.time.LocalTime.now;
|
|
|
|
|
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
|
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
|
|
|
|
|
|
|
public final class ScheduleTask {
|
|
public final class ScheduleTask {
|
|
@@ -55,7 +54,14 @@ public final class ScheduleTask {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void schedule(ScheduledExecutorService scheduledService, CountDownLatch latch) {
|
|
public void schedule(ScheduledExecutorService scheduledService, CountDownLatch latch) {
|
|
|
- long delay = startAt != null ? now().until(startAt, ChronoUnit.MILLIS) : delayMillis > 0 ? delayMillis : DEFAULT_DELAY_MILLIS;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ long delay = DEFAULT_DELAY_MILLIS;
|
|
|
|
|
+ if (startAt != null) {
|
|
|
|
|
+ delay = LocalDateTime.now().until(startAt, ChronoUnit.MILLIS);
|
|
|
|
|
+ } else if (delayMillis > 0) {
|
|
|
|
|
+ delay = delayMillis;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
ScheduledFuture<?> future = scheduledService.scheduleAtFixedRate(task, delay, periodMillis, MILLISECONDS);
|
|
ScheduledFuture<?> future = scheduledService.scheduleAtFixedRate(task, delay, periodMillis, MILLISECONDS);
|
|
|
description = new TaskDescription(description.getName(), Status.RUNNING);
|
|
description = new TaskDescription(description.getName(), Status.RUNNING);
|
|
|
new Thread(() -> {
|
|
new Thread(() -> {
|