diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2020-01-04 16:18:22 +0100 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2020-01-04 16:18:22 +0100 |
commit | 237a7caa6971b67d6f98aa4f2aae3cbab7d86def (patch) | |
tree | ed29d099f90c6fbbec9821dc0f28322a32504765 /src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/RecursiveScheduledTask.java | |
parent | 9be545d6f2609d5fe8143a1964d44f6eee588ea2 (diff) |
Run queries on an interval
Diffstat (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/RecursiveScheduledTask.java')
-rw-r--r-- | src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/RecursiveScheduledTask.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/RecursiveScheduledTask.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/RecursiveScheduledTask.java new file mode 100644 index 0000000..07e1fd4 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/RecursiveScheduledTask.java @@ -0,0 +1,26 @@ +package pl.edu.mimuw.cloudatlas.agent.modules; + +import java.util.function.Supplier; + +import pl.edu.mimuw.cloudatlas.agent.messages.TimerSchedulerMessage; + +public class RecursiveScheduledTask extends TimerScheduledTask { + private long delay; + private Supplier<TimerScheduledTask> taskSupplier; + + public RecursiveScheduledTask(long delay, Supplier<TimerScheduledTask> taskSupplier) { + this.delay = delay; + this.taskSupplier = taskSupplier; + } + + public void run() { + try { + TimerScheduledTask task = taskSupplier.get(); + task.setScheduler(scheduler); + task.run(); + sendMessage(new TimerSchedulerMessage("", 0, "", delay, 0, new RecursiveScheduledTask(delay, taskSupplier))); + } catch (InterruptedException e) { + System.out.println("Caught interrupted exception while running RecursiveScheduledTask"); + } + } +} |