Package com.github.kagkarlsson.scheduler
Class Scheduler
java.lang.Object
com.github.kagkarlsson.scheduler.Scheduler
- All Implemented Interfaces:
SchedulerClient
- Direct Known Subclasses:
ManualScheduler
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.github.kagkarlsson.scheduler.SchedulerClient
SchedulerClient.Builder, SchedulerClient.SchedulerClientName, SchedulerClient.StandardSchedulerClient -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final PollStrategyprotected final Executorstatic final Stringstatic final double -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedScheduler(Clock clock, TaskRepository schedulerTaskRepository, TaskRepository clientTaskRepository, TaskResolver taskResolver, int threadpoolSize, ExecutorService executorService, SchedulerName schedulerName, Waiter executeDueWaiter, Duration heartbeatInterval, boolean enableImmediateExecution, StatsRegistry statsRegistry, PollingStrategyConfig pollingStrategyConfig, Duration deleteUnresolvedAfter, Duration shutdownMaxWait, LogLevel logLevel, boolean logStackTrace, List<OnStartup> onStartup) -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel(TaskInstanceId taskInstanceId) Removes/Cancels an execution.static SchedulerBuildercreate(DataSource dataSource, Task<?>... knownTasks) static SchedulerBuildercreate(DataSource dataSource, List<Task<?>> knownTasks) protected voidprotected voidprotected voidvoidfetchScheduledExecutions(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.getFailingExecutions(Duration failingAtLeastFor) getScheduledExecution(TaskInstanceId taskInstanceId) Gets the details for a specific scheduled execution.voidpause()<T> voidreschedule(SchedulableInstance<T> schedulableInstance) Update an existing execution with a new execution-time and new task-data.voidreschedule(TaskInstanceId taskInstanceId, Instant newExecutionTime) Update an existing execution to a new execution-time.<T> voidreschedule(TaskInstanceId taskInstanceId, Instant newExecutionTime, T newData) Update an existing execution with a new execution-time and new task-data.voidresume()<T> voidschedule(SchedulableInstance<T> schedulableInstance) <T> voidschedule(TaskInstance<T> taskInstance, Instant executionTime) Schedule a new execution.voidstart()voidstop()voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.kagkarlsson.scheduler.SchedulerClient
getScheduledExecutions, getScheduledExecutions, getScheduledExecutionsForTask, getScheduledExecutionsForTask
-
Field Details
-
TRIGGER_NEXT_BATCH_WHEN_AVAILABLE_THREADS_RATIO
public static final double TRIGGER_NEXT_BATCH_WHEN_AVAILABLE_THREADS_RATIO- See Also:
-
THREAD_PREFIX
- See Also:
-
executeDueStrategy
-
executor
-
onStartup
-
-
Constructor Details
-
Scheduler
protected Scheduler(Clock clock, TaskRepository schedulerTaskRepository, TaskRepository clientTaskRepository, TaskResolver taskResolver, int threadpoolSize, ExecutorService executorService, SchedulerName schedulerName, Waiter executeDueWaiter, Duration heartbeatInterval, boolean enableImmediateExecution, StatsRegistry statsRegistry, PollingStrategyConfig pollingStrategyConfig, Duration deleteUnresolvedAfter, Duration shutdownMaxWait, LogLevel logLevel, boolean logStackTrace, List<OnStartup> onStartup)
-
-
Method Details
-
start
public void start() -
executeDue
protected void executeDue() -
executeOnStartup
protected void executeOnStartup() -
stop
public void stop() -
pause
public void pause() -
resume
public void resume() -
getSchedulerState
-
schedule
- Specified by:
schedulein interfaceSchedulerClient
-
schedule
Description copied from interface:SchedulerClientSchedule a new execution.- Specified by:
schedulein interfaceSchedulerClient- Parameters:
taskInstance- Task-instance, optionally with dataexecutionTime- Instant it should run- See Also:
-
reschedule
Description copied from interface:SchedulerClientUpdate an existing execution to a new execution-time. If the execution does not exist or if it is currently running, an exception is thrown.- Specified by:
reschedulein interfaceSchedulerClientnewExecutionTime- the new execution-time- See Also:
-
reschedule
Description copied from interface:SchedulerClientUpdate 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.- Specified by:
reschedulein interfaceSchedulerClient- Parameters:
schedulableInstance- the updated instance
-
reschedule
Description copied from interface:SchedulerClientUpdate 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.- Specified by:
reschedulein interfaceSchedulerClientnewExecutionTime- the new execution-timenewData- the new task-data- See Also:
-
cancel
Description copied from interface:SchedulerClientRemoves/Cancels an execution.- Specified by:
cancelin interfaceSchedulerClient- See Also:
-
fetchScheduledExecutions
Description copied from interface:SchedulerClientGets 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.- Specified by:
fetchScheduledExecutionsin interfaceSchedulerClient- Parameters:
consumer- Consumer for the executions
-
fetchScheduledExecutions
public void fetchScheduledExecutions(ScheduledExecutionsFilter filter, Consumer<ScheduledExecution<Object>> consumer) - Specified by:
fetchScheduledExecutionsin interfaceSchedulerClient
-
fetchScheduledExecutionsForTask
public <T> void fetchScheduledExecutionsForTask(String taskName, Class<T> dataClass, Consumer<ScheduledExecution<T>> consumer) Description copied from interface:SchedulerClientGets 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.- Specified by:
fetchScheduledExecutionsForTaskin interfaceSchedulerClient- 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
public <T> void fetchScheduledExecutionsForTask(String taskName, Class<T> dataClass, ScheduledExecutionsFilter filter, Consumer<ScheduledExecution<T>> consumer) - Specified by:
fetchScheduledExecutionsForTaskin interfaceSchedulerClient
-
getScheduledExecution
Description copied from interface:SchedulerClientGets the details for a specific scheduled execution. Currently running executions are also returned.- Specified by:
getScheduledExecutionin interfaceSchedulerClient- Returns:
- Optional.empty() if no matching execution found
- See Also:
-
getFailingExecutions
-
triggerCheckForDueExecutions
public void triggerCheckForDueExecutions() -
getCurrentlyExecuting
-
detectDeadExecutions
protected void detectDeadExecutions() -
create
-
create
-