public interface TaskManager
Task Manager Interface.
Status: public Stability: DRAFT
Task manager provides controls task execution, coordination, distribution and failover between nodes, etc.
This interface is just a basic framework for task management now. Although we hope that this is roughly almost final shape of the interface, the implementation is not complete and some changes may happen.
This definition specifies interface of Task Manager - a component that controls (asynchronous) task execution.
The task manager can store the task for later execution, switch them to background resume execution of a task from a different node, etc. Generally speaking, task manager provides operation to manage tasks in the whole midPoint cluster of IDM nodes.
This interface partially adheres to [Common Interface Concepts], but the goals are slightly different. This interface should be conveniently used also for tasks that are not persistent (synchronous short tasks). Therefore some methods are made much more user-friendly while tolerating some redundancy in the interface.
Modifier and Type | Field and Description |
---|---|
static long |
DO_NOT_STOP |
static long |
DO_NOT_WAIT |
static long |
WAIT_INDEFINITELY |
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 |
cleanupTasks(com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType closedTasksPolicy,
Task task,
OperationResult opResult)
Deletes obsolete tasks, as specified in the policy.
|
<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.
|
String |
getHandlerUriForCategory(String category)
Returns a default handler URI for a given task category.
|
Task |
getLocallyRunningTaskByIdentifier(String lightweightIdentifier)
Returns locally-run task by identifier.
|
Set<Task> |
getLocallyRunningTasks(OperationResult parentResult)
Returns tasks that currently run on this node.
|
Long |
getNextRunStartTime(String oid,
OperationResult result)
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> clazz,
String oid,
Collection<SelectorOptions<GetOperationOptions>> options,
OperationResult result)
TODO
|
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
|
boolean |
isCurrentNode(PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType> node)
Checks whether supplied node is the current node.
|
void |
modifyTask(String oid,
Collection<? extends ItemDelta> modifications,
OperationResult parentResult)
Modifies task using relative change description.
|
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 result)
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 |
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 |
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) |
void |
shutdown()
Shuts down current node.
|
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 waitTime,
OperationResult parentResult)
Stops a set of schedulers (on their nodes) and tasks that are executing on these nodes.
|
void |
suspendAndDeleteTasks(Collection<String> taskOidList,
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.
|
void |
switchToBackground(Task task,
OperationResult parentResult)
Switches the provided task to background, making it asynchronous.
|
void |
synchronizeTasks(OperationResult parentResult)
Synchronizes information in midPoint repository and task scheduling database.
|
void |
unpauseTask(Task task,
OperationResult parentResult)
Puts a WAITING task back into RUNNABLE state.
|
void |
unregisterTaskListener(TaskListener taskListener)
Unregisters a task listener.
|
ParseException |
validateCronExpression(String cron)
Validates a cron expression for scheduling tasks - without context of any given task.
|
void |
waitForTransientChildren(Task task,
OperationResult result) |
static final long WAIT_INDEFINITELY
static final long DO_NOT_WAIT
static final long DO_NOT_STOP
<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
T
- type
- query
- options
- parentResult
- 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 repository<T extends com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType> int countObjects(Class<T> type, ObjectQuery query, OperationResult parentResult) throws SchemaException
T
- type
- query
- parentResult
- SchemaException
void waitForTransientChildren(Task task, OperationResult result)
<T extends com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType> PrismObject<T> getObject(Class<T> clazz, String oid, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws ObjectNotFoundException, SchemaException
T
- clazz
- oid
- options
- task
- result
- ObjectNotFoundException
SchemaException
String addTask(PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType> taskPrism, OperationResult parentResult) throws ObjectAlreadyExistsException, SchemaException
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 violationIllegalArgumentException
- wrong OID format, etc.void modifyTask(String oid, Collection<? extends ItemDelta> modifications, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException
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 schemaIllegalArgumentException
- wrong OID format, described change is not applicableObjectAlreadyExistsException
void deleteTask(String oid, OperationResult parentResult) throws ObjectNotFoundException, SchemaException
oid
- OID of object to deleteparentResult
- parent OperationResult (in/out)ObjectNotFoundException
- specified object does not existIllegalArgumentException
- wrong OID format, described change is not applicableSchemaException
Task createTaskInstance()
Task createTaskInstance(PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType> taskPrism, OperationResult parentResult) throws SchemaException
taskPrism
- JAXB (XML) representation of the taskSchemaException
- The provided taskType is not compliant to schemaTask createTaskInstance(String operationName)
operationName
- operation name to use as a root for new result in taskTask createTaskInstance(PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType> taskPrism, String operationName, OperationResult parentResult) throws SchemaException
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 schemaTask getTask(String taskOid, OperationResult parentResult) throws ObjectNotFoundException, SchemaException
taskOid
- OID of the persistent task.SchemaException
- error dealing with resource schemaObjectNotFoundException
- wrong OID format, etc.Task getTaskByIdentifier(String identifier, OperationResult parentResult) throws SchemaException, ObjectNotFoundException
identifier
- task identifier to search forparentResult
- SchemaException
ObjectNotFoundException
PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType> getTaskTypeByIdentifier(String identifier, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws SchemaException, ObjectNotFoundException
identifier
- options
- parentResult
- SchemaException
ObjectNotFoundException
void cleanupTasks(com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType closedTasksPolicy, Task task, OperationResult opResult) throws SchemaException
closedTasksPolicy
- specifies which tasks are to be deleted, e.g. how old they have to betask
- task, within which context the cleanup executes (used to test for interruptions)opResult
- SchemaException
void onTaskCreate(String oid, OperationResult parentResult)
oid
- void onTaskDelete(String oid, OperationResult parentResult)
oid
- Set<Task> getLocallyRunningTasks(OperationResult parentResult) throws TaskManagerException
TaskManagerException
Task getLocallyRunningTaskByIdentifier(String lightweightIdentifier)
lightweightIdentifier
- parentResult
- TaskManagerException
boolean suspendTasks(Collection<String> taskOids, long waitForStop, OperationResult parentResult)
taskOids
- a collection of OIDs of tasks that have to be suspendedwaitTime
- how long (in milliseconds) to wait for stopping the execution of tasks;
WAIT_INDEFINITELY means wait indefinitely :)
DO_NOT_WAIT means stop the tasks, but do not wait for finishing their execution
DO_NOT_STOP means do not try to stop the task execution. Tasks will only be put into SUSPENDED state, and
their executions (if any) will be left as they are. Use this option only when you know what you're doing.parentResult
- boolean suspendTask(Task task, long waitTime, OperationResult parentResult)
void suspendAndDeleteTasks(Collection<String> taskOidList, long suspendTimeout, boolean alsoSubtasks, OperationResult parentResult)
taskOidList
- 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?parentResult
- void resumeTask(Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException
task
- task instance to be resumed.SchemaException
ObjectNotFoundException
void resumeTasks(Collection<String> taskOids, OperationResult parentResult)
taskOids
- a collection of OIDs of tasks that have to be resumedSchemaException
ObjectNotFoundException
void pauseTask(Task task, TaskWaitingReason reason, OperationResult parentResult) throws ObjectNotFoundException, SchemaException
task
- a runnable/running taskreason
- the reason for waiting, which is stored into the repositoryparentResult
- ObjectNotFoundException
SchemaException
void unpauseTask(Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException
task
- parentResult
- ObjectNotFoundException
SchemaException
void switchToBackground(Task task, OperationResult parentResult)
task
- task to switch to background.void scheduleTaskNow(Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException
task
- parentResult
- SchemaException
ObjectNotFoundException
void scheduleTasksNow(Collection<String> taskOids, OperationResult parentResult)
taskOids
- a collection of OIDs of tasks that have to be scheduledparentResult
- String getNodeId()
boolean isCurrentNode(PrismObject<com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType> node)
node
- void deleteNode(String nodeOid, OperationResult result) throws SchemaException, ObjectNotFoundException
nodeOid
- result
- SchemaException
ObjectNotFoundException
void shutdown()
boolean deactivateServiceThreads(long timeToWait, OperationResult parentResult)
void reactivateServiceThreads(OperationResult parentResult)
boolean getServiceThreadsActivationState()
void stopScheduler(String nodeIdentifier, OperationResult parentResult)
nodeIdentifier
- Node on which the scheduler should be stopped. Null means current node.void stopSchedulers(Collection<String> nodeIdentifiers, OperationResult parentResult)
boolean stopSchedulersAndTasks(Collection<String> nodeIdentifiers, long waitTime, OperationResult parentResult)
nodeIdentifiers
- collection of node identifierswaitTime
- how long to wait for task shutdown, in milliseconds
0 = indefinitely
-1 = do not wait at allparentResult
- void startScheduler(String nodeIdentifier, OperationResult parentResult)
nodeIdentifier
- Node on which the scheduler should be started. Null means current node.void startSchedulers(Collection<String> nodeIdentifiers, OperationResult parentResult)
void registerTaskListener(TaskListener taskListener)
taskListener
- listener to be registeredvoid unregisterTaskListener(TaskListener taskListener)
taskListener
- listener to be unregistetedvoid postInit(OperationResult result)
void synchronizeTasks(OperationResult parentResult)
parentResult
- Long getNextRunStartTime(String oid, OperationResult result)
oid
- OID of the taskresult
- List<String> getAllTaskCategories()
String getHandlerUriForCategory(String category)
category
- ParseException validateCronExpression(String cron)
cron
- expression to validatevoid registerHandler(String uri, TaskHandler handler)
uri
- URI of the handler, e.g. http://midpoint.evolveum.com/xml/ns/public/model/cleanup/handler-3handler
- instance of the handlervoid registerTaskDeletionListener(TaskDeletionListener listener)
Copyright © 2016 evolveum. All rights reserved.