Package com.github.kagkarlsson.scheduler
Interface SchedulerClient
-
- All Known Implementing Classes:
ManualScheduler,Scheduler,SchedulerClient.StandardSchedulerClient
public interface SchedulerClient
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classSchedulerClient.Builderstatic classSchedulerClient.ScheduleOptionsstatic classSchedulerClient.SchedulerClientNamestatic classSchedulerClient.StandardSchedulerClient
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_BATCH_SIZE
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description voidcancel(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.Optional<ScheduledExecution<Object>>getScheduledExecution(TaskInstanceId taskInstanceId)Gets the details for a specific scheduled execution.default List<ScheduledExecution<Object>>getScheduledExecutions()default List<ScheduledExecution<Object>>getScheduledExecutions(ScheduledExecutionsFilter filter)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.usescheduleIfNotExists(SchedulableInstance)instead.<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 Detail
-
DEFAULT_BATCH_SIZE
static final int DEFAULT_BATCH_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
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:
Instant,TaskInstance,TaskInstanceCurrentlyExecutingException
-
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:
SchedulableInstance,TaskInstanceCurrentlyExecutingException
-
schedule
@Deprecated <T> void schedule(TaskInstance<T> taskInstance, Instant executionTime)
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:
Instant,TaskInstance
-
schedule
@Deprecated <T> void schedule(SchedulableInstance<T> schedulableInstance)
Deprecated.usescheduleIfNotExists(SchedulableInstance)instead.
-
scheduleIfNotExists
<T> boolean scheduleIfNotExists(TaskInstance<T> taskInstance, Instant executionTime)
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:
Instant,TaskInstance
-
scheduleIfNotExists
<T> boolean scheduleIfNotExists(SchedulableInstance<T> schedulableInstance)
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:
SchedulableInstance
-
scheduleBatch
void scheduleBatch(List<TaskInstance<?>> taskInstances, Instant executionTime)
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:
Instant,TaskInstance
-
scheduleBatch
void scheduleBatch(List<SchedulableInstance<?>> schedulableInstances)
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:
SchedulableInstance
-
scheduleBatch
default void scheduleBatch(Stream<TaskInstance<?>> taskInstances, Instant executionTime)
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:
Instant,TaskInstance
-
scheduleBatch
default void scheduleBatch(Stream<SchedulableInstance<?>> schedulableInstances)
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:
SchedulableInstance
-
reschedule
boolean reschedule(TaskInstanceId taskInstanceId, Instant newExecutionTime)
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
- See Also:
Instant,TaskInstanceId
-
reschedule
<T> boolean reschedule(TaskInstanceId taskInstanceId, Instant newExecutionTime, T newData)
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
- See Also:
Instant,TaskInstanceId
-
reschedule
<T> boolean reschedule(SchedulableInstance<T> schedulableInstance)
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
-
cancel
void cancel(TaskInstanceId taskInstanceId)
Removes/Cancels an execution.- Parameters:
taskInstanceId-- See Also:
TaskInstanceId
-
fetchScheduledExecutions
void fetchScheduledExecutions(Consumer<ScheduledExecution<Object>> consumer)
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
default List<ScheduledExecution<Object>> getScheduledExecutions()
- See Also:
fetchScheduledExecutions(Consumer)
-
getScheduledExecutions
default List<ScheduledExecution<Object>> getScheduledExecutions(ScheduledExecutionsFilter filter)
- See Also:
fetchScheduledExecutions(Consumer)
-
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
default <T> List<ScheduledExecution<Object>> getScheduledExecutionsForTask(String taskName)
-
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
Optional<ScheduledExecution<Object>> getScheduledExecution(TaskInstanceId taskInstanceId)
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:
TaskInstanceId,ScheduledExecution
-
-