Package dev.frostlake.task
Class TaskScheduler
java.lang.Object
dev.frostlake.task.TaskScheduler
Schedules and executes tasks
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TaskThe task whose body is executing on the current thread, or null outside a task run.voidexecuteTaskManually(String qualifiedTaskName) Execute a task manually by name (for EXECUTE TASK command)voidexecuteTaskNow(String qualifiedTaskName, Task task) Execute a task immediately (for testing)booleanhasRunningExecutions(String qualifiedTaskName) Whether a run of this task is in flight right now.booleanbooleanisScheduled(String qualifiedTaskName) Whether this task currently holds a live timer entry.voidresumeTask(String qualifiedTaskName, Task task) static StringschedulerKey(String databaseName, String schemaName, String taskName) The scheduler key for a task:DB.SCHEMA.TASK, upper-cased.voidscheduleTask(String qualifiedTaskName, Task task) voidstart()Start the scheduler and arm every task already in the STARTED state.voidstop()voidsuspendTask(String qualifiedTaskName, Task task) voidunscheduleTask(String qualifiedTaskName)
-
Constructor Details
-
TaskScheduler
-
-
Method Details
-
currentTask
The task whose body is executing on the current thread, or null outside a task run. -
schedulerKey
The scheduler key for a task:DB.SCHEMA.TASK, upper-cased. Every path that arms or cancels a task must build it the same way, or a later SUSPEND cancels nothing because it looks up a key that RESUME never wrote. Shared byALTER TASK … RESUME/SUSPENDand bystart()'s arming scan. -
start
public void start()Start the scheduler and arm every task already in the STARTED state.The scan matters because a task can reach STARTED without anyone calling
resumeTask(java.lang.String, dev.frostlake.metastore.model.Task): a snapshot restore writes the state straight onto the model (CatalogSnapshotReader), so a task that was running when the engine was persisted comes back STARTED but unarmed, and would never fire again until it was manually RESUMEd. Arming here makes "it was running before the restart" survive the restart.Still OPT-IN — nothing starts the scheduler at engine boot, so an embedded engine spawns no timer threads unless the embedder asks for them (or a RESUME lazy-starts it).
-
stop
public void stop() -
scheduleTask
-
unscheduleTask
-
resumeTask
-
suspendTask
-
executeTaskNow
Execute a task immediately (for testing) -
executeTaskManually
Execute a task manually by name (for EXECUTE TASK command) -
isRunning
public boolean isRunning() -
isScheduled
Whether this task currently holds a live timer entry. The key must be built withschedulerKey(java.lang.String, java.lang.String, java.lang.String); anything else answers false because it is not the key the scheduler armed under. -
hasRunningExecutions
Whether a run of this task is in flight right now. Only tracked for tasks that forbid overlapping execution (the default) — a task withALLOW_OVERLAPPING_EXECUTION = TRUEneeds no in-flight bookkeeping, so it always reports false.
-