@Service(value="taskManagement") @Transactional(propagation=REQUIRED) public class TaskManagementImpl extends Object implements TaskManagement
| Constructor and Description |
|---|
TaskManagementImpl() |
| 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
TaskManagement.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.
|
public Long addTask(String uniqueTaskName, boolean active, Long interval, Date nextExecutionDate, Class<? extends TaskHandler> handlerClass) throws TaskAlreadyExistsException
TaskManagementaddTask in interface TaskManagementuniqueTaskName - 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.public Long addTask(String uniqueTaskName, boolean active, Long interval, Date nextExecutionDate, Map<String,String> properties, Class<? extends TaskHandler> handlerClass) throws TaskAlreadyExistsException
TaskManagementaddTask in interface TaskManagementuniqueTaskName - 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.public Long addTask(String uniqueTaskName, boolean active, Long interval, Date nextExecutionDate, Map<String,String> properties, String handlerClass) throws TaskAlreadyExistsException
TaskManagementaddTask in interface TaskManagementuniqueTaskName - 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.public Long addTask(String uniqueTaskName, boolean active, Long interval, Date nextExecutionDate, String handlerClass) throws TaskAlreadyExistsException
TaskManagementaddTask in interface TaskManagementuniqueTaskName - 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.public void addTaskHandler(Class<? extends TaskHandler> taskHandler)
TaskManagementaddTaskHandler in interface TaskManagementtaskHandler - the task handler to add@Transactional(propagation=SUPPORTS) public void addTaskHandler(String handlerName, Class<? extends TaskHandler> taskHandler)
TaskManagementaddTaskHandler in interface TaskManagementhandlerName - the name of the handler to be usedtaskHandler - the task handler to add@Transactional(propagation=NEVER) public void addTaskHandlerWithTask(String handlerName, Class<? extends TaskHandler> taskHandlerClazz, Map<String,String> properties, long startOffset, boolean resetFailed)
TaskManagementaddTaskHandlerWithTask in interface TaskManagementhandlerName - 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.public void failTaskExecution(String uniqueTaskName) throws InvalidInstanceException
TaskManagementfailTaskExecution in interface TaskManagementuniqueTaskName - Name of the task.InvalidInstanceException - Thrown, when the task is not running on this instance.@Transactional(readOnly=true) public TaskTO findTask(String uniqueTaskName)
TaskManagementfindTask in interface TaskManagementuniqueTaskName - The name of the taskpublic TaskTO getNextScheduledTask()
TaskManagementgetNextScheduledTask in interface TaskManagementpublic TaskTO getNextScheduledTask(Date upperBound)
TaskManagementgetNextScheduledTask in interface TaskManagementupperBound - The upper bound of the task's next execution (exclusive).public Collection<TaskTO> getNextScheduledTasks(Date upperBound, int maxTasks, Collection<Long> taskIdsToExclude)
TaskManagementgetNextScheduledTasks in interface TaskManagementupperBound - NextExecution < UpperBound.maxTasks - maximum number of tasks to returntaskIdsToExclude - the IDs of the task to exclude from the query. Can be null.@Transactional(readOnly=true) public Collection<TaskExecution> getTaskExecutions(String instanceName)
TaskManagementgetTaskExecutions in interface TaskManagementinstanceName - Name of the instance@Transactional(readOnly=true) public boolean isTaskRunningOnCurrentInstance(String uniqueTaskName)
TaskManagementisTaskRunningOnCurrentInstance in interface TaskManagementuniqueTaskName - the unique name of the taskpublic String killTaskExecution(Long executionId)
TaskManagementkillTaskExecution in interface TaskManagementexecutionId - The execution IDpublic void removeTask(String uniqueTaskName) throws TaskAlreadyRunningException
TaskManagementremoveTask in interface TaskManagementuniqueTaskName - The task to remove.TaskAlreadyRunningException - Thrown, when the task is currently running.@Transactional(propagation=SUPPORTS) public boolean removeTaskHandler(String handlerName)
TaskManagementremoveTaskHandler in interface TaskManagementhandlerName - the handler namepublic void rescheduleTask(String uniqueTaskName, Date nextExecutionDate) throws TaskStatusException
TaskManagementrescheduleTask in interface TaskManagementuniqueTaskName - 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 pendingpublic void resetTask(String uniqueTaskName)
TaskManagementresetTask in interface TaskManagementuniqueTaskName - The name of the task to reset@Transactional(propagation=NEVER) public Long startTaskExecution(String uniqueTaskName) throws TaskAlreadyRunningException, TaskNotActiveException, TaskManagementException
TaskManagementstartTaskExecution in interface TaskManagementuniqueTaskName - 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 error@Transactional(propagation=REQUIRES_NEW) public Long startTaskExecutionTx(String uniqueTaskName) throws TaskNotActiveException, TaskAlreadyRunningException
TaskManagementTaskManagement.startTaskExecution(String) but can throw
DatabaseIntegrityViolationException. Therefore this method should never be called directly
and TaskManagement.startTaskExecution(String) should be used instead.startTaskExecutionTx in interface TaskManagementuniqueTaskName - Name of the task to start.TaskNotActiveException - In case if the task is not activated.TaskAlreadyRunningException - in case the task is already running.public void stopAllTaskExecutions()
TaskManagementstopAllTaskExecutions in interface TaskManagementpublic void stopAllTaskExecutions(boolean resetFailed,
Date rescheduleDate)
TaskManagementstopAllTaskExecutions in interface TaskManagementresetFailed - If set, all failed tasks will be reset.rescheduleDate - If set, this will be the new date the task will be executed.public void stopTaskExecution(String uniqueTaskName) throws InvalidInstanceException
TaskManagementstopTaskExecution in interface TaskManagementuniqueTaskName - Name of the task.InvalidInstanceException - in case the task is not executed on this instancepublic void stopTaskExecution(String uniqueTaskName, Date rescheduleDate) throws InvalidInstanceException
TaskManagementstopTaskExecution in interface TaskManagementuniqueTaskName - 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.