public interface TaskManagement
StartupProperties
.Modifier and Type | Method and Description |
---|---|
Long |
addTask(String uniqueTaskName,
boolean active,
Long interval,
Date nextExecutionDate,
Class<? extends TaskHandler> handlerClass)
Add a new task.
|
Long |
addTask(String uniqueTaskName,
boolean active,
Long interval,
Date nextExecutionDate,
Map<String,String> properties,
Class<? extends TaskHandler> handlerClass)
Add a new task.
|
Long |
addTask(String uniqueTaskName,
boolean active,
Long interval,
Date nextExecutionDate,
Map<String,String> properties,
String handlerClass)
Add a new task.
|
Long |
addTask(String uniqueTaskName,
boolean active,
Long interval,
Date nextExecutionDate,
String handlerClass)
Add a new task.
|
void |
addTaskHandler(Class<? extends TaskHandler> taskHandler)
Add a handler for tasks.
|
void |
addTaskHandler(String handlerName,
Class<? extends TaskHandler> taskHandler)
Add a handler for tasks with the given name.
|
void |
addTaskHandlerWithTask(String handlerName,
Class<? extends TaskHandler> taskHandlerClazz,
Map<String,String> properties,
long startOffset,
boolean resetFailed)
Add a task handler and create a task for it.
|
void |
failTaskExecution(String uniqueTaskName)
Mark the execution of a task as failed.
|
TaskTO |
findTask(String uniqueTaskName)
Get the details of a task.
|
TaskTO |
getNextScheduledTask()
Return the next task to be scheduled.
|
TaskTO |
getNextScheduledTask(Date upperBound)
Return the next task to be scheduled.
|
Collection<TaskTO> |
getNextScheduledTasks(Date upperBound,
int maxTasks,
Collection<Long> taskIdsToExclude)
Get the tasks to schedule next
|
Collection<TaskExecution> |
getTaskExecutions(String instanceName)
Return all task executions running on the Communote with the given name.
|
boolean |
isTaskRunningOnCurrentInstance(String uniqueTaskName)
Return whether the given task is running on the current instance.
|
String |
killTaskExecution(Long executionId)
Kill the task with given execution ID by removing the execution and setting the task back to
pending.
|
void |
removeTask(String uniqueTaskName)
Remove a task if it is not RUNNING.
|
boolean |
removeTaskHandler(String handlerName)
Remove the task handler class from the list of known handlers.
|
void |
rescheduleTask(String uniqueTaskName,
Date nextExecutionDate)
Reschedule a pending task.
|
void |
resetTask(String uniqueTaskName)
Reset a task back from failed to pending.
|
Long |
startTaskExecution(String uniqueTaskName)
Mark a task as running on this instance by creating an execution for it and setting the
status to RUNNING.
|
Long |
startTaskExecutionTx(String uniqueTaskName)
Same as
startTaskExecution(String) but can throw
DatabaseIntegrityViolationException. |
void |
stopAllTaskExecutions()
Calls stopAllTaskExecutions(true,now).
|
void |
stopAllTaskExecutions(boolean resetFailed,
Date rescheduleDate)
End all task executions of this instance and schedules them again.
|
void |
stopTaskExecution(String uniqueTaskName)
End the execution of the given task.
|
void |
stopTaskExecution(String uniqueTaskName,
Date rescheduleDate)
End the execution of the given task.
|
Long addTask(String uniqueTaskName, boolean active, Long interval, Date nextExecutionDate, Class<? extends TaskHandler> handlerClass) throws TaskAlreadyExistsException
uniqueTaskName
- Unique name for this task.active
- True, if active.interval
- Interval for the execution.nextExecutionDate
- The next execution date.handlerClass
- Class of the handler.TaskAlreadyExistsException
- Thrown, when there is already a task with this name.Long addTask(String uniqueTaskName, boolean active, Long interval, Date nextExecutionDate, Map<String,String> properties, Class<? extends TaskHandler> handlerClass) throws TaskAlreadyExistsException
uniqueTaskName
- Unique name for this task.active
- True, if active.interval
- Interval for the execution.nextExecutionDate
- The next execution date.properties
- Properties of this task.handlerClass
- Class of the handler.TaskAlreadyExistsException
- Thrown, when there is already a task with this name.Long addTask(String uniqueTaskName, boolean active, Long interval, Date nextExecutionDate, Map<String,String> properties, String handlerClass) throws TaskAlreadyExistsException
uniqueTaskName
- Unique name for this task.active
- True, if active.interval
- Interval for the execution.nextExecutionDate
- The next execution date.properties
- Properties of this task.handlerClass
- Full qualified class name for the handler.TaskAlreadyExistsException
- Thrown, when there is already a task with this name.Long addTask(String uniqueTaskName, boolean active, Long interval, Date nextExecutionDate, String handlerClass) throws TaskAlreadyExistsException
uniqueTaskName
- Unique name for this task.active
- True, if active.interval
- Interval for the execution.nextExecutionDate
- The next execution date.handlerClass
- Full qualified class name for the handler.TaskAlreadyExistsException
- Thrown, when there is already a task with this name.void addTaskHandler(Class<? extends TaskHandler> taskHandler)
taskHandler
- the task handler to addvoid addTaskHandler(String handlerName, Class<? extends TaskHandler> taskHandler)
handlerName
- the name of the handler to be usedtaskHandler
- the task handler to addvoid addTaskHandlerWithTask(String handlerName, Class<? extends TaskHandler> taskHandlerClazz, Map<String,String> properties, long startOffset, boolean resetFailed)
handlerName
- the name of the handler. The name will also be used as unique name for the task.taskHandlerClazz
- the TaskHandler
classproperties
- Properties for the task (if one is added).startOffset
- the offset in milliseconds to add to the current time to delay the execution of
the taskresetFailed
- if true and the status of an existing task is failed the task will be always
rescheduled.void failTaskExecution(String uniqueTaskName) throws InvalidInstanceException
uniqueTaskName
- Name of the task.InvalidInstanceException
- Thrown, when the task is not running on this instance.TaskTO findTask(String uniqueTaskName)
uniqueTaskName
- The name of the taskTaskTO getNextScheduledTask()
TaskTO getNextScheduledTask(Date upperBound)
upperBound
- The upper bound of the task's next execution (exclusive).Collection<TaskTO> getNextScheduledTasks(Date upperBound, int maxTasks, Collection<Long> taskIdsToExclude)
upperBound
- NextExecution < UpperBound.maxTasks
- maximum number of tasks to returntaskIdsToExclude
- the IDs of the task to exclude from the query. Can be null.Collection<TaskExecution> getTaskExecutions(String instanceName)
instanceName
- Name of the instanceboolean isTaskRunningOnCurrentInstance(String uniqueTaskName)
uniqueTaskName
- the unique name of the taskString killTaskExecution(Long executionId)
executionId
- The execution IDvoid removeTask(String uniqueTaskName) throws TaskAlreadyRunningException
uniqueTaskName
- The task to remove.TaskAlreadyRunningException
- Thrown, when the task is currently running.boolean removeTaskHandler(String handlerName)
handlerName
- the handler namevoid rescheduleTask(String uniqueTaskName, Date nextExecutionDate) throws TaskStatusException
uniqueTaskName
- the unique name of task. If there is no task with the given name the call will be
ignored.nextExecutionDate
- the new execution dateTaskStatusException
- in case the task is not pendingvoid resetTask(String uniqueTaskName)
uniqueTaskName
- The name of the task to resetLong startTaskExecution(String uniqueTaskName) throws TaskAlreadyRunningException, TaskNotActiveException, TaskManagementException
uniqueTaskName
- Name of the task to start.TaskAlreadyRunningException
- in case the task is already running.TaskNotActiveException
- in case the task is not activated.TaskManagementException
- in case of an unexpected errorLong startTaskExecutionTx(String uniqueTaskName) throws TaskNotActiveException, TaskAlreadyRunningException
startTaskExecution(String)
but can throw
DatabaseIntegrityViolationException. Therefore this method should never be called directly
and startTaskExecution(String)
should be used instead.uniqueTaskName
- Name of the task to start.TaskAlreadyRunningException
- in case the task is already running.TaskNotActiveException
- In case if the task is not activated.void stopAllTaskExecutions()
void stopAllTaskExecutions(boolean resetFailed, Date rescheduleDate)
rescheduleDate
- If set, this will be the new date the task will be executed.resetFailed
- If set, all failed tasks will be reset.void stopTaskExecution(String uniqueTaskName) throws InvalidInstanceException
uniqueTaskName
- Name of the task.InvalidInstanceException
- in case the task is not executed on this instancevoid stopTaskExecution(String uniqueTaskName, Date rescheduleDate) throws InvalidInstanceException
uniqueTaskName
- Unique name of the task.rescheduleDate
- If set, this will be the new date the task will be executed.InvalidInstanceException
- in case the task is not running on this instanceCopyright © 2019 Communote team. All rights reserved.