Package com.github.kagkarlsson.scheduler
Interface SchedulerClient
- All Known Implementing Classes:
ManualScheduler,Scheduler,SchedulerClient.StandardSchedulerClient
public interface SchedulerClient
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic classstatic classstatic class -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel(TaskInstanceId taskInstanceId) Removes/Cancels an execution.voidfetchScheduledExecutions(ScheduledExecutionsFilter filter, Consumer<ScheduledExecution<Object>> consumer) voidfetchScheduledExecutions(Consumer<ScheduledExecution<Object>> consumer) Gets all scheduled executions and supplies them to the provided Consumer.<T> voidfetchScheduledExecutionsForTask(String taskName, Class<T> dataClass, ScheduledExecutionsFilter filter, Consumer<ScheduledExecution<T>> consumer) <T> voidfetchScheduledExecutionsForTask(String taskName, Class<T> dataClass, Consumer<ScheduledExecution<T>> consumer) Gets all scheduled executions for a task and supplies them to the provided Consumer.getScheduledExecution(TaskInstanceId taskInstanceId) Gets the details for a specific scheduled execution.default List<ScheduledExecution<Object>>default List<ScheduledExecution<Object>>default <T> List<ScheduledExecution<Object>>getScheduledExecutionsForTask(String taskName) default <T> List<ScheduledExecution<T>>getScheduledExecutionsForTask(String taskName, Class<T> dataClass) default <T> List<ScheduledExecution<T>>getScheduledExecutionsForTask(String taskName, Class<T> dataClass, ScheduledExecutionsFilter filter) <T> booleanreschedule(SchedulableInstance<T> schedulableInstance) Update an existing execution with a new execution-time and new task-data.booleanreschedule(TaskInstanceId taskInstanceId, Instant newExecutionTime) Update an existing execution to a new execution-time.<T> booleanreschedule(TaskInstanceId taskInstanceId, Instant newExecutionTime, T newData) Update an existing execution with a new execution-time and new task-data.<T> voidschedule(SchedulableInstance<T> schedulableInstance) Deprecated.<T> booleanschedule(SchedulableInstance<T> schedulableInstance, SchedulerClient.ScheduleOptions scheduleOptions) Schedule a new execution for the given task instance.<T> voidschedule(TaskInstance<T> taskInstance, Instant executionTime) Deprecated.usescheduleIfNotExists(TaskInstance, Instant)instead.<T> booleanschedule(TaskInstance<T> taskInstance, Instant executionTime, SchedulerClient.ScheduleOptions scheduleOptions) Schedule a new execution for the given task instance.voidscheduleBatch(List<SchedulableInstance<?>> schedulableInstances) Schedule a batch of executions.voidscheduleBatch(List<TaskInstance<?>> taskInstances, Instant executionTime) Schedule a batch of executions.default voidscheduleBatch(Stream<SchedulableInstance<?>> schedulableInstances) Schedule a batch of executions.default voidscheduleBatch(Stream<TaskInstance<?>> taskInstances, Instant executionTime) Schedule a batch of executions.<T> booleanscheduleIfNotExists(SchedulableInstance<T> schedulableInstance) Schedule a new execution if task instance does not already exists.<T> booleanscheduleIfNotExists(TaskInstance<T> taskInstance, Instant executionTime) Schedule a new execution if task instance does not already exists.
-
Field Details
-
DEFAULT_BATCH_SIZE
static final int DEFAULT_BATCH_SIZE- See Also:
-
-
Method Details
-
schedule
<T> boolean schedule(TaskInstance<T> taskInstance, Instant executionTime, SchedulerClient.ScheduleOptions scheduleOptions) Schedule a new execution for the given task instance.If the task instance already exists, the specified policy in
scheduleOptionsapplies.An exception is thrown if the execution is currently running.
- Parameters:
taskInstance- Task-instance, optionally with dataexecutionTime- Instant it should runscheduleOptions- policy for when the instance exists- Returns:
- true if the task-instance actually was scheduled
- Throws:
TaskInstanceCurrentlyExecutingException- if the execution is currently running- See Also:
-
schedule
<T> boolean schedule(SchedulableInstance<T> schedulableInstance, SchedulerClient.ScheduleOptions scheduleOptions) Schedule a new execution for the given task instance.If the task instance already exists, the specified policy in
scheduleOptionsapplies.An exception is thrown if the execution is currently running.
- Parameters:
schedulableInstance- Task-instance and time it should runscheduleOptions- policy for when the instance exists- Returns:
- true if the task-instance actually was scheduled
- Throws:
TaskInstanceCurrentlyExecutingException- if the execution is currently running- See Also:
-
schedule
Deprecated.usescheduleIfNotExists(TaskInstance, Instant)instead.Schedule a new execution if task instance does not already exists.- Parameters:
taskInstance- Task-instance, optionally with dataexecutionTime- Instant it should run- See Also:
-
schedule
Deprecated.usescheduleIfNotExists(SchedulableInstance)instead. -
scheduleIfNotExists
Schedule a new execution if task instance does not already exists.- Parameters:
taskInstance- Task-instance, optionally with dataexecutionTime- Instant it should run- Returns:
- true if scheduled successfully
- See Also:
-
scheduleIfNotExists
Schedule a new execution if task instance does not already exists.- Parameters:
schedulableInstance- Task-instance and time it should run- Returns:
- true if scheduled successfully
- See Also:
-
scheduleBatch
Schedule a batch of executions. If any of the executions already exists, the scheduling will fail and an exception will be thrown.- Parameters:
taskInstances- Task-instance to schedule, optionally with dataexecutionTime- Instant it should run- See Also:
-
scheduleBatch
Schedule a batch of executions. If any of the executions already exists, the scheduling will fail and an exception will be thrown.- Parameters:
schedulableInstances- Task-instances with individual execution-times- See Also:
-
scheduleBatch
Schedule a batch of executions. If any of the executions already exists, the scheduling will fail and an exception will be thrown.- Parameters:
taskInstances- Task-instances to schedule, optionally with dataexecutionTime- Instant it should run- See Also:
-
scheduleBatch
Schedule a batch of executions. If any of the executions already exists, the scheduling will fail and an exception will be thrown.- Parameters:
schedulableInstances- Task-instances with individual execution-times- See Also:
-
reschedule
Update an existing execution to a new execution-time. If the execution does not exist or if it is currently running, an exception is thrown.- Parameters:
taskInstanceId- Task-instance to reschedule, expected to existnewExecutionTime- the new execution-time- Returns:
- true if rescheduled successfully
- Throws:
TaskInstanceNotFoundException- if the given instance does not existTaskInstanceCurrentlyExecutingException- if the execution is currently running- See Also:
-
reschedule
Update an existing execution with a new execution-time and new task-data. If the execution does not exist or if it is currently running, an exception is thrown.- Parameters:
taskInstanceId-newExecutionTime- the new execution-timenewData- the new task-data- Returns:
- true if rescheduled successfully
- Throws:
TaskInstanceNotFoundException- if the given instance does not existTaskInstanceCurrentlyExecutingException- if the execution is currently running- See Also:
-
reschedule
Update an existing execution with a new execution-time and new task-data. If the execution does not exist or if it is currently running, an exception is thrown.- Parameters:
schedulableInstance- the updated instance- Returns:
- true if rescheduled successfully
- Throws:
TaskInstanceNotFoundException- if the given instance does not existTaskInstanceCurrentlyExecutingException- if the execution is currently running
-
cancel
Removes/Cancels an execution.- Parameters:
taskInstanceId-- Throws:
TaskInstanceNotFoundException- if the given instance does not existTaskInstanceCurrentlyExecutingException- if the given instance is currently being executed- See Also:
-
fetchScheduledExecutions
Gets all scheduled executions and supplies them to the provided Consumer. A Consumer is used to avoid forcing the SchedulerClient to load all executions in memory. Currently running executions are not returned.- Parameters:
consumer- Consumer for the executions
-
fetchScheduledExecutions
void fetchScheduledExecutions(ScheduledExecutionsFilter filter, Consumer<ScheduledExecution<Object>> consumer) -
getScheduledExecutions
- See Also:
-
getScheduledExecutions
- See Also:
-
fetchScheduledExecutionsForTask
<T> void fetchScheduledExecutionsForTask(String taskName, Class<T> dataClass, Consumer<ScheduledExecution<T>> consumer) Gets all scheduled executions for a task and supplies them to the provided Consumer. A Consumer is used to avoid forcing the SchedulerClient to load all executions in memory. Currently running executions are not returned.- Parameters:
taskName- the name of the task to get scheduled-executions fordataClass- the task data-class the data will be serialized and cast toconsumer- Consumer for the executions
-
fetchScheduledExecutionsForTask
<T> void fetchScheduledExecutionsForTask(String taskName, Class<T> dataClass, ScheduledExecutionsFilter filter, Consumer<ScheduledExecution<T>> consumer) -
getScheduledExecutionsForTask
-
getScheduledExecutionsForTask
default <T> List<ScheduledExecution<T>> getScheduledExecutionsForTask(String taskName, Class<T> dataClass) -
getScheduledExecutionsForTask
default <T> List<ScheduledExecution<T>> getScheduledExecutionsForTask(String taskName, Class<T> dataClass, ScheduledExecutionsFilter filter) -
getScheduledExecution
Gets the details for a specific scheduled execution. Currently running executions are also returned.- Parameters:
taskInstanceId-- Returns:
- Optional.empty() if no matching execution found
- See Also:
-
scheduleIfNotExists(SchedulableInstance)instead.