@Service(value="taskManager") @DependsOn(value="repositoryService") public class TaskManagerQuartzImpl extends Object implements TaskManager, org.springframework.beans.factory.BeanFactoryAware
Constructor and Description |
---|
TaskManagerQuartzImpl() |
Modifier and Type | Method and Description |
---|---|
String |
addTask(PrismObject<TaskType> taskPrism,
OperationResult parentResult)
Add new task.
|
void |
checkWaitingTasks(OperationResult result) |
void |
cleanupTasks(CleanupPolicyType policy,
OperationResult parentResult)
Deletes obsolete tasks, as specified in the policy.
|
void |
closeTask(Task task,
OperationResult parentResult) |
void |
closeTaskWithoutSavingState(Task task,
OperationResult parentResult) |
int |
countNodes(ObjectQuery query,
OperationResult result)
Returns the number of nodes satisfying given query.
|
int |
countTasks(ObjectQuery query,
OperationResult result)
Returns the number of tasks satisfying given query.
|
Task |
createTaskInstance()
Creates new transient, running task instance.
|
Task |
createTaskInstance(PrismObject<TaskType> taskPrism,
OperationResult parentResult)
Creates task instance from the XML task representation.
|
Task |
createTaskInstance(PrismObject<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 nodeIdentifier,
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.
|
Set<Task> |
getLocallyRunningTasks(OperationResult parentResult)
Returns tasks that currently run on this node.
|
NodeErrorStatus |
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.
|
PrismContext |
getPrismContext() |
RepositoryService |
getRepositoryService() |
ClusterStatusInformation |
getRunningTasksClusterwide(long allowedAge,
OperationResult parentResult)
As above; with the difference that this method fetches new information only if after last query
elapsed at least 'allowedAge' milliseconds.
|
ClusterStatusInformation |
getRunningTasksClusterwide(OperationResult parentResult)
Returns the cluster state, including tasks that execute on particular nodes.
|
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.
|
void |
init()
Initialization.
|
boolean |
isCurrentNode(PrismObject<NodeType> node)
Checks whether supplied node is the current node.
|
boolean |
isInErrorState() |
List<Task> |
listTasksRelatedToObject(String oid,
ClusterStatusInformation clusterStatusInformation,
OperationResult result)
Returns tasks that are related to an object with a given OID.
|
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 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 |
resumeTask(Task task,
OperationResult parentResult)
Resume suspended task.
|
void |
scheduleTaskNow(Task task,
OperationResult parentResult)
Schedules a RUNNABLE task to be run immediately.
|
List<Node> |
searchNodes(ObjectQuery query,
ClusterStatusInformation clusterStatusInformation,
OperationResult parentResult)
Returns relevant nodes satisfying given query.
|
List<Task> |
searchTasks(ObjectQuery query,
ClusterStatusInformation clusterStatusInformation,
OperationResult parentResult)
Returns tasks satisfying given query.
|
void |
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) |
void |
setConfiguration(TaskManagerConfiguration configuration) |
void |
setNodeErrorStatus(NodeErrorStatus nodeErrorStatus) |
void |
shutdown()
Shuts down current node.
|
void |
startScheduler(String nodeIdentifier,
OperationResult parentResult)
Starts the scheduler on a given node.
|
void |
stopScheduler(String nodeIdentifier,
OperationResult parentResult)
Stops the scheduler on a given node.
|
boolean |
stopSchedulersAndTasks(List<String> nodeList,
long timeToWait,
OperationResult result)
Stops a set of schedulers (on their nodes) and tasks that are executing on these nodes.
|
void |
suspendAndDeleteTasks(List<String> taskOidList,
long suspendTimeout,
boolean alsoSubtasks,
OperationResult parentResult)
Suspends tasks and deletes them.
|
boolean |
suspendTask(Task task,
long waitTime,
boolean doNotStop,
OperationResult parentResult) |
boolean |
suspendTask(Task task,
long waitTime,
OperationResult parentResult)
Suspend a task.
|
boolean |
suspendTasks(Collection<Task> tasks,
long waitTime,
boolean doNotStop,
OperationResult parentResult)
Suspends a set of tasks.
|
boolean |
suspendTasks(Collection<Task> tasks,
long waitTime,
OperationResult parentResult)
Suspend a set of tasks.
|
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 |
unscheduleTask(Task task,
OperationResult parentResult) |
ParseException |
validateCronExpression(String cron)
Validates a cron expression for scheduling tasks - without context of any given task.
|
@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 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 suspendTask(Task task, long waitTime, boolean doNotStop, OperationResult parentResult)
public boolean suspendTasks(Collection<Task> tasks, long waitTime, OperationResult parentResult)
TaskManager
suspendTasks
in interface TaskManager
public boolean suspendTasks(Collection<Task> tasks, long waitTime, boolean doNotStop, OperationResult parentResult)
TaskManager
suspendTasks
in interface TaskManager
tasks
- a set of tasks to be suspendedwaitTime
- how long (in milliseconds) to wait for stopping the execution of tasks;
0 means wait indefinitely
-1 means stop the task but do not wait for finishing their executiondoNotStop
- if true, the task execution will not be stopped. They will only be put into SUSPENDED state, and
their executions (if any) will be left as they arepublic 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 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<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<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<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(List<String> taskOidList, long suspendTimeout, boolean alsoSubtasks, OperationResult parentResult)
TaskManager
suspendAndDeleteTasks
in interface TaskManager
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?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 Long getNextRunStartTime(String oid, OperationResult parentResult)
TaskManager
getNextRunStartTime
in interface TaskManager
oid
- OID of the taskpublic int countNodes(ObjectQuery query, OperationResult result) throws SchemaException
TaskManager
countNodes
in interface TaskManager
query
- search querySchemaException
public List<Node> searchNodes(ObjectQuery query, ClusterStatusInformation clusterStatusInformation, OperationResult parentResult) throws SchemaException
TaskManager
searchNodes
in interface TaskManager
query
- search queryclusterStatusInformation
- The same as in searchTasks.SchemaException
public List<Task> listTasksRelatedToObject(String oid, ClusterStatusInformation clusterStatusInformation, OperationResult result) throws SchemaException
TaskManager
listTasksRelatedToObject
in interface TaskManager
oid
- object OID to be searched forclusterStatusInformation
- runtime information to be used (if not null)SchemaException
public List<Task> searchTasks(ObjectQuery query, ClusterStatusInformation clusterStatusInformation, OperationResult parentResult) throws SchemaException
TaskManager
searchTasks
in interface TaskManager
query
- Search queryclusterStatusInformation
- If null, the method will query cluster nodes to get up-to-date runtime information.
If non-null, the method will use the provided information. Used to optimize
network traffic in case of repeating calls to searchTasks/searchNodes (e.g. when
displaying them on one page).SchemaException
public int countTasks(ObjectQuery query, OperationResult result) throws SchemaException
TaskManager
countTasks
in interface TaskManager
query
- search querySchemaException
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-2handler
- 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 TaskManagerConfiguration getConfiguration()
public PrismContext getPrismContext()
public NodeErrorStatus getLocalNodeErrorStatus()
public void setNodeErrorStatus(NodeErrorStatus 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 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 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 startScheduler(String nodeIdentifier, OperationResult parentResult)
TaskManager
startScheduler
in interface TaskManager
nodeIdentifier
- Node on which the scheduler should be started. Null means current node.public boolean stopSchedulersAndTasks(List<String> nodeList, long timeToWait, OperationResult result)
TaskManager
stopSchedulersAndTasks
in interface TaskManager
nodeList
- list of node identifierstimeToWait
- how long to wait for task shutdown, in milliseconds
0 = indefinitely
-1 = do not wait at allpublic ClusterStatusInformation getRunningTasksClusterwide(OperationResult parentResult)
TaskManager
getRunningTasksClusterwide
in interface TaskManager
public ClusterStatusInformation getRunningTasksClusterwide(long allowedAge, OperationResult parentResult)
TaskManager
getRunningTasksClusterwide
in interface TaskManager
public boolean isCurrentNode(PrismObject<NodeType> node)
TaskManager
isCurrentNode
in interface TaskManager
public void deleteNode(String nodeIdentifier, OperationResult result)
TaskManager
deleteNode
in interface TaskManager
public void scheduleTaskNow(Task task, OperationResult parentResult)
TaskManager
scheduleTaskNow
in interface TaskManager
public 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 void checkWaitingTasks(OperationResult result) throws SchemaException
SchemaException
public void cleanupTasks(CleanupPolicyType policy, OperationResult parentResult) throws SchemaException
TaskManager
cleanupTasks
in interface TaskManager
policy
- specifies which tasks are to be deleted, e.g. how old they have to beSchemaException
Copyright © 2013 evolveum. All rights reserved.