com.evolveum.midpoint.task.quartzimpl.execution
Class ExecutionManager

java.lang.Object
  extended by com.evolveum.midpoint.task.quartzimpl.execution.ExecutionManager

public class ExecutionManager
extends java.lang.Object

Manages task threads (clusterwide). Concerned mainly with stopping threads and querying their state.

Author:
Pavol Mederly

Constructor Summary
ExecutionManager(TaskManagerQuartzImpl taskManager)
           
 
Method Summary
 ClusterStatusInformation getClusterStatusInformation(boolean clusterwide, OperationResult parentResult)
           
 java.util.Set<Task> getLocallyRunningTasks()
           
 java.lang.Long getNextRunStartTime(java.lang.String oid, OperationResult result)
           
 org.quartz.Scheduler getQuartzScheduler()
           
 void initializeLocalScheduler()
           
 boolean removeTaskFromQuartz(java.lang.String oid, OperationResult parentResult)
          Removes task from quartz.
 void scheduleTaskNow(Task task, OperationResult parentResult)
           
 void setQuartzScheduler(org.quartz.Scheduler quartzScheduler)
           
 void shutdownLocalScheduler()
           
 void shutdownLocalSchedulerChecked()
          Robust version of 'shutdownScheduler', ignores exceptions, shuts down the scheduler only if not shutdown already.
 void startScheduler(java.lang.String nodeIdentifier, OperationResult parentResult)
           
 boolean stopAllTasksOnThisNodeAndWait(long timeToWait, OperationResult parentResult)
          Signals all running tasks that they have to finish.
 void stopScheduler(java.lang.String nodeIdentifier, OperationResult parentResult)
           
 boolean stopSchedulerAndTasksLocally(long timeToWait, OperationResult result)
           
 boolean stopSchedulersAndTasks(java.util.List<java.lang.String> nodeList, long timeToWait, OperationResult parentResult)
           
 boolean stopTasksRunAndWait(java.util.Collection<Task> tasks, ClusterStatusInformation csi, long waitTime, boolean clusterwide, OperationResult parentResult)
          Stops given set of tasks and waits for their completion.
 boolean synchronizeJobStores(OperationResult result)
           
 void synchronizeTask(TaskQuartzImpl task, OperationResult result)
           
 void unscheduleTask(Task task, OperationResult parentResult)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecutionManager

public ExecutionManager(TaskManagerQuartzImpl taskManager)
Method Detail

stopScheduler

public void stopScheduler(java.lang.String nodeIdentifier,
                          OperationResult parentResult)

stopSchedulersAndTasks

public boolean stopSchedulersAndTasks(java.util.List<java.lang.String> nodeList,
                                      long timeToWait,
                                      OperationResult parentResult)

startScheduler

public void startScheduler(java.lang.String nodeIdentifier,
                           OperationResult parentResult)

getClusterStatusInformation

public ClusterStatusInformation getClusterStatusInformation(boolean clusterwide,
                                                            OperationResult parentResult)

stopAllTasksOnThisNodeAndWait

public boolean stopAllTasksOnThisNodeAndWait(long timeToWait,
                                             OperationResult parentResult)
Signals all running tasks that they have to finish. Waits for their completion. Terminology: STOP TASK means "tell the task to stop" (using any appropriate means)

Parameters:
timeToWait - How long to wait (milliseconds); 0 means forever.
Returns:
true if all the tasks finished within time allotted, false otherwise.

stopTasksRunAndWait

public boolean stopTasksRunAndWait(java.util.Collection<Task> tasks,
                                   ClusterStatusInformation csi,
                                   long waitTime,
                                   boolean clusterwide,
                                   OperationResult parentResult)
Stops given set of tasks and waits for their completion.

Parameters:
tasks -
csi - Cluster status information. Must be relatively current, i.e. got AFTER a moment preventing new tasks to be scheduled (e.g. when suspending tasks, CSI has to be taken after tasks have been unscheduled; when stopping schedulers, CSI has to be taken after schedulers were stopped). May be null; in that case the method will query nodes themselves.
waitTime - How long to wait for task stop. -1 means no wait will be performed.
clusterwide - If false, only tasks running on local node will be stopped.
parentResult -
Returns:
Note: does not throw exceptions: it tries hard to stop the tasks, if something breaks, it just return 'false'

unscheduleTask

public void unscheduleTask(Task task,
                           OperationResult parentResult)

removeTaskFromQuartz

public boolean removeTaskFromQuartz(java.lang.String oid,
                                    OperationResult parentResult)
Removes task from quartz. On error, creates a subresult in parent OperationResult. (On success, does nothing to keep ORs from becoming huge.)

Parameters:
oid -
parentResult -
Returns:
true if the job was successfully removed.

setQuartzScheduler

public void setQuartzScheduler(org.quartz.Scheduler quartzScheduler)

getQuartzScheduler

public org.quartz.Scheduler getQuartzScheduler()

shutdownLocalScheduler

public void shutdownLocalScheduler()
                            throws TaskManagerException
Throws:
TaskManagerException

shutdownLocalSchedulerChecked

public void shutdownLocalSchedulerChecked()
Robust version of 'shutdownScheduler', ignores exceptions, shuts down the scheduler only if not shutdown already. Used for emergency situations, e.g. node error.


stopSchedulerAndTasksLocally

public boolean stopSchedulerAndTasksLocally(long timeToWait,
                                            OperationResult result)

synchronizeTask

public void synchronizeTask(TaskQuartzImpl task,
                            OperationResult result)

getNextRunStartTime

public java.lang.Long getNextRunStartTime(java.lang.String oid,
                                          OperationResult result)

synchronizeJobStores

public boolean synchronizeJobStores(OperationResult result)

getLocallyRunningTasks

public java.util.Set<Task> getLocallyRunningTasks()

initializeLocalScheduler

public void initializeLocalScheduler()
                              throws TaskManagerInitializationException
Throws:
TaskManagerInitializationException

scheduleTaskNow

public void scheduleTaskNow(Task task,
                            OperationResult parentResult)


Copyright © 2012 evolveum. All Rights Reserved.