@Service(value="taskManager") @DependsOn(value="repositoryService") public class TaskManagerQuartzImpl extends Object implements TaskManager, org.springframework.beans.factory.BeanFactoryAware
DO_NOT_STOP, DO_NOT_WAIT, WAIT_INDEFINITELY
Constructor and Description |
---|
TaskManagerQuartzImpl() |
Modifier and Type | Method and Description |
---|---|
String |
addTask(PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType> taskPrism,
OperationResult parentResult)
Add new task.
|
void |
checkStalledTasks(OperationResult result) |
void |
checkWaitingTasks(OperationResult result) |
void |
cleanupTasks(com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType policy,
Task executionTask,
OperationResult parentResult)
Deletes obsolete tasks, as specified in the policy.
|
void |
closeTask(Task task,
OperationResult parentResult) |
void |
closeTaskWithoutSavingState(Task task,
OperationResult parentResult) |
<T extends com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType> |
countObjects(Class<T> type,
ObjectQuery query,
OperationResult parentResult)
Counts the number of objects.
|
Task |
createTaskInstance()
Creates new transient, running task instance.
|
Task |
createTaskInstance(PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType> taskPrism,
OperationResult parentResult)
Creates task instance from the XML task representation.
|
Task |
createTaskInstance(PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType> taskPrism,
String operationName,
OperationResult parentResult)
Creates task instance from the XML task representation.
|
Task |
createTaskInstance(String operationName)
Creates new transient, running task instance.
|
boolean |
deactivateServiceThreads(long timeToWait,
OperationResult parentResult)
Deactivates service threads (temporarily).
|
void |
deleteNode(String nodeOid,
OperationResult result)
Deletes a node from the repository.
|
void |
deleteTask(String oid,
OperationResult parentResult)
Deletes task with provided OID.
|
List<String> |
getAllTaskCategories()
Gets a list of all task categories.
|
org.springframework.beans.factory.BeanFactory |
getBeanFactory() |
ClusterManager |
getClusterManager() |
TaskManagerConfiguration |
getConfiguration() |
ExecutionManager |
getExecutionManager() |
TaskHandler |
getHandler(String uri) |
String |
getHandlerUriForCategory(String category)
Returns a default handler URI for a given task category.
|
Task |
getLocallyRunningTaskByIdentifier(String lightweightIdentifier)
Returns locally-run task by identifier.
|
Map<String,TaskQuartzImpl> |
getLocallyRunningTaskInstances() |
Set<Task> |
getLocallyRunningTasks(OperationResult parentResult)
Returns tasks that currently run on this node.
|
com.evolveum.midpoint.xml.ns._public.common.common_3.NodeErrorStatusType |
getLocalNodeErrorStatus() |
MidpointConfiguration |
getMidpointConfiguration() |
Long |
getNextRunStartTime(String oid,
OperationResult parentResult)
Gets next scheduled execution time for a given task.
|
String |
getNodeId()
Returns identifier for current node.
|
<T extends com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType> |
getObject(Class<T> type,
String oid,
Collection<SelectorOptions<GetOperationOptions>> options,
OperationResult parentResult)
TODO
|
PrismContext |
getPrismContext() |
RepositoryService |
getRepositoryService() |
SecurityEnforcer |
getSecurityEnforcer() |
boolean |
getServiceThreadsActivationState()
Returns true if the service threads are running.
|
Task |
getTask(String taskOid,
OperationResult parentResult)
Returns a task with specified OID.
|
Task |
getTaskByIdentifier(String identifier,
OperationResult parentResult)
Returns a task with a given identifier.
|
PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType> |
getTaskTypeByIdentifier(String identifier,
Collection<SelectorOptions<GetOperationOptions>> options,
OperationResult parentResult)
TODO
|
Collection<Task> |
getTransientSubtasks(TaskQuartzImpl task) |
void |
init()
Initialization.
|
boolean |
isCurrentNode(PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType> node)
Checks whether supplied node is the current node.
|
boolean |
isInErrorState() |
boolean |
isRunning() |
List<PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType>> |
listSubtasksForTask(String taskIdentifier,
OperationResult result) |
void |
modifyTask(String oid,
Collection<? extends ItemDelta> modifications,
OperationResult parentResult)
Modifies task using relative change description.
|
void |
notifyTaskFinish(Task task,
TaskRunResult runResult) |
void |
notifyTaskStart(Task task) |
void |
notifyTaskThreadFinish(Task task) |
void |
notifyTaskThreadStart(Task task,
boolean isRecovering) |
void |
onTaskCreate(String oid,
OperationResult parentResult)
This is a signal to task manager that a new task was created in the repository.
|
void |
onTaskDelete(String oid,
OperationResult parentResult)
This is a signal to task manager that a task was removed from the repository.
|
void |
pauseTask(Task task,
TaskWaitingReason reason,
OperationResult parentResult)
Puts a runnable/running task into WAITING state.
|
void |
postInit(OperationResult parentResult)
Post initialization, e.g.
|
void |
reactivateServiceThreads(OperationResult parentResult)
Re-activates the service threads after they have been deactivated.
|
void |
registerHandler(String uri,
TaskHandler handler)
Registers a handler for a specified handler URI.
|
void |
registerRunningTask(TaskQuartzImpl task) |
void |
registerTaskDeletionListener(TaskDeletionListener listener) |
void |
registerTaskListener(TaskListener taskListener)
Registers a task listener that will be notified on task-related events.
|
void |
resumeTask(Task task,
OperationResult parentResult)
Resume suspended task.
|
void |
resumeTasks(Collection<String> taskOids,
OperationResult parentResult)
Resume suspended tasks.
|
void |
scheduleRunnableTaskNow(Task task,
OperationResult parentResult) |
void |
scheduleTaskNow(Task task,
OperationResult parentResult)
Schedules a RUNNABLE task or CLOSED single-run task to be run immediately.
|
void |
scheduleTasksNow(Collection<String> taskOids,
OperationResult parentResult)
Schedules a RUNNABLE/CLOSED tasks to be run immediately.
|
<T extends com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType> |
searchObjects(Class<T> type,
ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options,
OperationResult parentResult) |
SearchResultList<PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType>> |
searchTasks(ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options,
OperationResult result) |
void |
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) |
void |
setConfiguration(TaskManagerConfiguration configuration) |
void |
setNodeErrorStatus(com.evolveum.midpoint.xml.ns._public.common.common_3.NodeErrorStatusType nodeErrorStatus) |
void |
shutdown()
Shuts down current node.
|
void |
startLightweightTask(TaskQuartzImpl task) |
void |
startScheduler(String nodeIdentifier,
OperationResult parentResult)
Starts the scheduler on a given node.
|
void |
startSchedulers(Collection<String> nodeIdentifiers,
OperationResult parentResult) |
void |
stopScheduler(String nodeIdentifier,
OperationResult parentResult)
Stops the scheduler on a given node.
|
void |
stopSchedulers(Collection<String> nodeIdentifiers,
OperationResult parentResult) |
boolean |
stopSchedulersAndTasks(Collection<String> nodeIdentifiers,
long timeToWait,
OperationResult result)
Stops a set of schedulers (on their nodes) and tasks that are executing on these nodes.
|
void |
suspendAndDeleteTasks(Collection<String> taskOids,
long suspendTimeout,
boolean alsoSubtasks,
OperationResult parentResult)
Suspends tasks and deletes them.
|
boolean |
suspendTask(Task task,
long waitTime,
OperationResult parentResult)
Suspend a task.
|
boolean |
suspendTasks(Collection<String> taskOids,
long waitForStop,
OperationResult parentResult)
Suspends a set of tasks.
|
boolean |
suspendTasksResolved(Collection<Task> tasks,
long waitForStop,
OperationResult parentResult) |
void |
switchToBackground(Task task,
OperationResult parentResult)
Switches the provided task to background, making it asynchronous.
|
void |
synchronizeTasks(OperationResult result)
Synchronizes information in midPoint repository and task scheduling database.
|
void |
unpauseTask(Task task,
OperationResult parentResult)
Puts a WAITING task back into RUNNABLE state.
|
void |
unregisterRunningTask(TaskQuartzImpl task) |
void |
unregisterTaskListener(TaskListener taskListener)
Unregisters a task listener.
|
void |
unscheduleTask(Task task,
OperationResult parentResult) |
ParseException |
validateCronExpression(String cron)
Validates a cron expression for scheduling tasks - without context of any given task.
|
void |
waitForTransientChildren(Task task,
OperationResult result) |
@PostConstruct public void init()
public void postInit(OperationResult parentResult)
TaskManager
postInit
in interface TaskManager
@PreDestroy public void shutdown()
TaskManager
shutdown
in interface TaskManager
public boolean isRunning()
public boolean isInErrorState()
public boolean deactivateServiceThreads(long timeToWait, OperationResult parentResult)
TaskManager
deactivateServiceThreads
in interface TaskManager
public void reactivateServiceThreads(OperationResult parentResult)
TaskManager
reactivateServiceThreads
in interface TaskManager
public boolean getServiceThreadsActivationState()
TaskManager
getServiceThreadsActivationState
in interface TaskManager
public boolean suspendTask(Task task, long waitTime, OperationResult parentResult)
TaskManager
suspendTask
in interface TaskManager
public boolean suspendTasks(Collection<String> taskOids, long waitForStop, OperationResult parentResult)
TaskManager
suspendTasks
in interface TaskManager
taskOids
- a collection of OIDs of tasks that have to be suspendedpublic boolean suspendTasksResolved(Collection<Task> tasks, long waitForStop, OperationResult parentResult)
public void pauseTask(Task task, TaskWaitingReason reason, OperationResult parentResult) throws ObjectNotFoundException, SchemaException
TaskManager
pauseTask
in interface TaskManager
task
- a runnable/running taskreason
- the reason for waiting, which is stored into the repositoryObjectNotFoundException
SchemaException
public void unpauseTask(Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException
TaskManager
unpauseTask
in interface TaskManager
ObjectNotFoundException
SchemaException
public void resumeTasks(Collection<String> taskOids, OperationResult parentResult)
TaskManager
resumeTasks
in interface TaskManager
taskOids
- a collection of OIDs of tasks that have to be resumedpublic void resumeTask(Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException
TaskManager
resumeTask
in interface TaskManager
task
- task instance to be resumed.ObjectNotFoundException
SchemaException
public Task createTaskInstance()
TaskManager
createTaskInstance
in interface TaskManager
public Task createTaskInstance(String operationName)
TaskManager
createTaskInstance
in interface TaskManager
operationName
- operation name to use as a root for new result in taskpublic Task createTaskInstance(PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType> taskPrism, OperationResult parentResult) throws SchemaException
TaskManager
createTaskInstance
in interface TaskManager
taskPrism
- JAXB (XML) representation of the taskSchemaException
- The provided taskType is not compliant to schemapublic Task createTaskInstance(PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType> taskPrism, String operationName, OperationResult parentResult) throws SchemaException
TaskManager
createTaskInstance
in interface TaskManager
taskPrism
- Prism representation of the taskoperationName
- operation name to use as a root for new result in taskSchemaException
- The provided taskType is not compliant to schemapublic Task getTask(String taskOid, OperationResult parentResult) throws ObjectNotFoundException, SchemaException
TaskManager
getTask
in interface TaskManager
taskOid
- OID of the persistent task.ObjectNotFoundException
- wrong OID format, etc.SchemaException
- error dealing with resource schemapublic void switchToBackground(Task task, OperationResult parentResult)
TaskManager
switchToBackground
in interface TaskManager
task
- task to switch to background.public String addTask(PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType> taskPrism, OperationResult parentResult) throws ObjectAlreadyExistsException, SchemaException
TaskManager
addTask
in interface TaskManager
taskPrism
- object to createparentResult
- parent OperationResult (in/out)ObjectAlreadyExistsException
- object with specified identifiers already exists, cannot addSchemaException
- error dealing with storage schema, e.g. schema violationpublic void modifyTask(String oid, Collection<? extends ItemDelta> modifications, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException
TaskManager
modifyTask
in interface TaskManager
oid
- OID of the task to be changedmodifications
- specification of object changesparentResult
- parent OperationResult (in/out)ObjectNotFoundException
- specified object does not existSchemaException
- resulting object would violate the schemaObjectAlreadyExistsException
public void suspendAndDeleteTasks(Collection<String> taskOids, long suspendTimeout, boolean alsoSubtasks, OperationResult parentResult)
TaskManager
suspendAndDeleteTasks
in interface TaskManager
taskOids
- List of task OIDs to be suspended and deleted.suspendTimeout
- How long (in milliseconds) to wait for task suspension before proceeding with deletion.alsoSubtasks
- Should also subtasks be deleted?public void deleteTask(String oid, OperationResult parentResult) throws ObjectNotFoundException, SchemaException
TaskManager
deleteTask
in interface TaskManager
oid
- OID of object to deleteparentResult
- parent OperationResult (in/out)ObjectNotFoundException
- specified object does not existSchemaException
public void registerRunningTask(TaskQuartzImpl task)
public void unregisterRunningTask(TaskQuartzImpl task)
public void startLightweightTask(TaskQuartzImpl task)
public void waitForTransientChildren(Task task, OperationResult result)
waitForTransientChildren
in interface TaskManager
public <T extends com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType> PrismObject<T> getObject(Class<T> type, String oid, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws SchemaException, ObjectNotFoundException
TaskManager
getObject
in interface TaskManager
SchemaException
ObjectNotFoundException
public List<PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType>> listSubtasksForTask(String taskIdentifier, OperationResult result) throws SchemaException
SchemaException
public <T extends com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType> SearchResultList<PrismObject<T>> searchObjects(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws SchemaException
searchObjects
in interface TaskManager
SchemaException
- Notes: Implemented options are:
- noFetch: it causes task manager NOT to ask remote nodes about node/task status.
- (for tasks) TaskType.F_NEXT_RUN_START_TIMESTAMP: it can be used to disable asking Quartz for next run start time
- other options that are passed down to repositorypublic <T extends com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType> int countObjects(Class<T> type, ObjectQuery query, OperationResult parentResult) throws SchemaException
TaskManager
countObjects
in interface TaskManager
SchemaException
public SearchResultList<PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType>> searchTasks(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException
SchemaException
public void registerTaskDeletionListener(TaskDeletionListener listener)
registerTaskDeletionListener
in interface TaskManager
public void registerHandler(String uri, TaskHandler handler)
TaskManager
registerHandler
in interface TaskManager
uri
- URI of the handler, e.g. http://midpoint.evolveum.com/xml/ns/public/model/cleanup/handler-3handler
- instance of the handlerpublic TaskHandler getHandler(String uri)
public List<String> getAllTaskCategories()
TaskManager
getAllTaskCategories
in interface TaskManager
public String getHandlerUriForCategory(String category)
TaskManager
getHandlerUriForCategory
in interface TaskManager
public void onTaskCreate(String oid, OperationResult parentResult)
TaskManager
onTaskCreate
in interface TaskManager
public void onTaskDelete(String oid, OperationResult parentResult)
TaskManager
onTaskDelete
in interface TaskManager
public void registerTaskListener(TaskListener taskListener)
TaskManager
registerTaskListener
in interface TaskManager
taskListener
- listener to be registeredpublic void unregisterTaskListener(TaskListener taskListener)
TaskManager
unregisterTaskListener
in interface TaskManager
taskListener
- listener to be unregistetedpublic void notifyTaskStart(Task task)
public void notifyTaskFinish(Task task, TaskRunResult runResult)
public void notifyTaskThreadStart(Task task, boolean isRecovering)
public void notifyTaskThreadFinish(Task task)
public TaskManagerConfiguration getConfiguration()
public PrismContext getPrismContext()
public com.evolveum.midpoint.xml.ns._public.common.common_3.NodeErrorStatusType getLocalNodeErrorStatus()
public void setNodeErrorStatus(com.evolveum.midpoint.xml.ns._public.common.common_3.NodeErrorStatusType nodeErrorStatus)
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
setBeanFactory
in interface org.springframework.beans.factory.BeanFactoryAware
org.springframework.beans.BeansException
public MidpointConfiguration getMidpointConfiguration()
public org.springframework.beans.factory.BeanFactory getBeanFactory()
public ClusterManager getClusterManager()
public RepositoryService getRepositoryService()
public void setConfiguration(TaskManagerConfiguration configuration)
public ExecutionManager getExecutionManager()
public SecurityEnforcer getSecurityEnforcer()
public void synchronizeTasks(OperationResult result)
TaskManager
synchronizeTasks
in interface TaskManager
public String getNodeId()
TaskManager
getNodeId
in interface TaskManager
public Set<Task> getLocallyRunningTasks(OperationResult parentResult) throws TaskManagerException
TaskManager
getLocallyRunningTasks
in interface TaskManager
TaskManagerException
public Task getLocallyRunningTaskByIdentifier(String lightweightIdentifier)
TaskManager
getLocallyRunningTaskByIdentifier
in interface TaskManager
public void stopScheduler(String nodeIdentifier, OperationResult parentResult)
TaskManager
stopScheduler
in interface TaskManager
nodeIdentifier
- Node on which the scheduler should be stopped. Null means current node.public void stopSchedulers(Collection<String> nodeIdentifiers, OperationResult parentResult)
stopSchedulers
in interface TaskManager
public void startScheduler(String nodeIdentifier, OperationResult parentResult)
TaskManager
startScheduler
in interface TaskManager
nodeIdentifier
- Node on which the scheduler should be started. Null means current node.public void startSchedulers(Collection<String> nodeIdentifiers, OperationResult parentResult)
startSchedulers
in interface TaskManager
public boolean stopSchedulersAndTasks(Collection<String> nodeIdentifiers, long timeToWait, OperationResult result)
TaskManager
stopSchedulersAndTasks
in interface TaskManager
nodeIdentifiers
- collection of node identifierstimeToWait
- how long to wait for task shutdown, in milliseconds
0 = indefinitely
-1 = do not wait at allpublic boolean isCurrentNode(PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType> node)
TaskManager
isCurrentNode
in interface TaskManager
public void deleteNode(String nodeOid, OperationResult result) throws SchemaException, ObjectNotFoundException
TaskManager
deleteNode
in interface TaskManager
SchemaException
ObjectNotFoundException
public void scheduleTaskNow(Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException
TaskManager
scheduleTaskNow
in interface TaskManager
SchemaException
ObjectNotFoundException
public void scheduleRunnableTaskNow(Task task, OperationResult parentResult)
public void scheduleTasksNow(Collection<String> taskOids, OperationResult parentResult)
TaskManager
scheduleTasksNow
in interface TaskManager
taskOids
- a collection of OIDs of tasks that have to be scheduledpublic void unscheduleTask(Task task, OperationResult parentResult)
public void closeTask(Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException
public void closeTaskWithoutSavingState(Task task, OperationResult parentResult)
public ParseException validateCronExpression(String cron)
TaskManager
validateCronExpression
in interface TaskManager
cron
- expression to validatepublic Task getTaskByIdentifier(String identifier, OperationResult parentResult) throws SchemaException, ObjectNotFoundException
TaskManager
getTaskByIdentifier
in interface TaskManager
identifier
- task identifier to search forSchemaException
ObjectNotFoundException
public PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType> getTaskTypeByIdentifier(String identifier, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws SchemaException, ObjectNotFoundException
TaskManager
getTaskTypeByIdentifier
in interface TaskManager
SchemaException
ObjectNotFoundException
public void cleanupTasks(com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType policy, Task executionTask, OperationResult parentResult) throws SchemaException
TaskManager
cleanupTasks
in interface TaskManager
policy
- specifies which tasks are to be deleted, e.g. how old they have to beexecutionTask
- task, within which context the cleanup executes (used to test for interruptions)SchemaException
public Long getNextRunStartTime(String oid, OperationResult parentResult)
TaskManager
getNextRunStartTime
in interface TaskManager
oid
- OID of the taskpublic void checkStalledTasks(OperationResult result)
public void checkWaitingTasks(OperationResult result) throws SchemaException
SchemaException
public Map<String,TaskQuartzImpl> getLocallyRunningTaskInstances()
public Collection<Task> getTransientSubtasks(TaskQuartzImpl task)
Copyright © 2016 evolveum. All rights reserved.