Class AbstractTaskHandler<TH extends AbstractTaskHandler<TH,TE>,TE extends AbstractTaskExecution<TH,TE>>
- java.lang.Object
-
- com.evolveum.midpoint.repo.common.task.AbstractTaskHandler<TH,TE>
-
- All Implemented Interfaces:
TaskHandler
,WorkBucketAwareTaskHandler
- Direct Known Subclasses:
AbstractModelTaskHandler
public abstract class AbstractTaskHandler<TH extends AbstractTaskHandler<TH,TE>,TE extends AbstractTaskExecution<TH,TE>> extends Object implements WorkBucketAwareTaskHandler
Task handler for iterative tasks. This class fulfills rudimentary duties only: 1. holds autowired beans (as it is a Spring component, unlike related classes), 2. providesWorkBucketAwareTaskHandler
interface to the task manager. *WARNING!* The task handler is effectively singleton! It is a Spring bean and it is supposed to handle all search task instances. Therefore it must not have task-specific fields. It can only contain fields specific to all tasks of a specified type. All of the work is delegated toAbstractTaskExecution
which in turn uses other classes to do the work. The whole structure then looks like this: 1.AbstractTaskHandler
is the main entry point. It instantiatesAbstractTaskExecution
that is responsible for the execution of the iterative task. 2. Then,AbstractTaskExecution
represents the specific execution of the task. It should contain all the fields that are specific to given task instance, like fetched resource definition object (for synchronization tasks), timestamps (for scanner tasks), and so on. Also data provided by theTaskManager
when starting the task execution (like current task part definition, current bucket, and so on) are kept there. 3. The task execution object then instantiates - viaAbstractTaskExecution.createPartExecutions()
method - objects that are responsible for execution of individual task parts. For example, a reconciliation task consists of three such parts: processing unfinished shadows, resource objects reconciliation, and (remaining) shadows reconciliation. Majority of task parts are search-iterative. Each such part execution class contains code to construct a query, search options, and instantiates _item processor_: a subclass ofAbstractSearchIterativeItemProcessor
. 4. Task parts that are not based on search method call are used for live sync and async update tasks. Please see the appropriate task handlers for more information. *TODO Specify responsibilities of individual components w.r.t. multithreading, error handling, progress and error reporting, and so on.* This approach may look like an overkill for simple tasks (like e.g. recompute or propagation tasks), but it enables code deduplication and simplification for really complex tasks, like the reconciliation. It is experimental and probably will evolve in the future. There is also a possibility of introducing the _task execution_ concept at the level of the task manager. For the simplest tasks please use `SimpleIterativeTaskHandler` (in `model-impl`) that hides all the complexity in exchange for some task limitations, like having only a single part, and so on. *TODO: Generalize this class a bit. In fact, there is nothing specific to the iterative nature of the processing here.*- Author:
- semancik
-
-
Field Summary
Fields Modifier and Type Field Description protected @NotNull TaskReportingOptions
globalReportingOptions
Options that govern how various aspects of task execution (progress, errors, statistics, and so on) are reported - into the log or by other means.protected LightweightIdentifierGenerator
lightweightIdentifierGenerator
protected MatchingRuleRegistry
matchingRuleRegistry
protected OperationExecutionRecorderForTasks
operationExecutionRecorder
protected PrismContext
prismContext
protected RepositoryService
repositoryService
protected SchemaService
schemaService
protected TaskManager
taskManager
protected @NotNull String
taskTypeName
Human-understandable name of the task type, like "Recompute", "Import from resource", and so on.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractTaskHandler(@NotNull Trace logger, @NotNull String taskTypeName, @NotNull String taskOperationPrefix)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.evolveum.midpoint.task.api.TaskHandler
getArchetypeOid, getCategoryName, getCategoryNames, getDefaultChannel, run
-
Methods inherited from interface com.evolveum.midpoint.task.api.WorkBucketAwareTaskHandler
onNoMoreBuckets, run
-
-
-
-
Field Detail
-
taskTypeName
@NotNull protected final @NotNull String taskTypeName
Human-understandable name of the task type, like "Recompute", "Import from resource", and so on. Used for logging and similar purposes. Provided by the constructor.
-
globalReportingOptions
@NotNull protected final @NotNull TaskReportingOptions globalReportingOptions
Options that govern how various aspects of task execution (progress, errors, statistics, and so on) are reported - into the log or by other means.
-
taskManager
@Autowired protected TaskManager taskManager
-
repositoryService
@Autowired @Qualifier("cacheRepositoryService") protected RepositoryService repositoryService
-
prismContext
@Autowired protected PrismContext prismContext
-
schemaService
@Autowired protected SchemaService schemaService
-
matchingRuleRegistry
@Autowired protected MatchingRuleRegistry matchingRuleRegistry
-
operationExecutionRecorder
@Autowired protected OperationExecutionRecorderForTasks operationExecutionRecorder
-
lightweightIdentifierGenerator
@Autowired protected LightweightIdentifierGenerator lightweightIdentifierGenerator
-
-
Method Detail
-
getTaskTypeName
@NotNull public @NotNull String getTaskTypeName()
-
getTaskManager
@NotNull public @NotNull TaskManager getTaskManager()
-
getRepositoryService
@NotNull public @NotNull RepositoryService getRepositoryService()
-
getPrismContext
@NotNull public @NotNull PrismContext getPrismContext()
-
getStatisticsCollectionStrategy
@NotNull public @NotNull StatisticsCollectionStrategy getStatisticsCollectionStrategy()
- Specified by:
getStatisticsCollectionStrategy
in interfaceTaskHandler
-
run
public TaskWorkBucketProcessingResult run(RunningTask localCoordinatorTask, WorkBucketType workBucket, TaskPartitionDefinitionType partition, TaskWorkBucketProcessingResult previousRunResult)
Main entry point. We basically delegate all the processing to a TaskExecution object. Error handling is delegated toTaskExceptionHandlingUtil.processException(Throwable, Trace, TaskPartitionDefinitionType, String, TaskRunResult)
method.- Specified by:
run
in interfaceWorkBucketAwareTaskHandler
-
createTaskExecution
@NotNull protected TE createTaskExecution(RunningTask localCoordinatorTask, WorkBucketType workBucket, TaskPartitionDefinitionType partition, TaskWorkBucketProcessingResult previousRunResult)
Method to create the task execution. Can be overridden.
-
heartbeat
public Long heartbeat(Task task)
TODO decide what to do with this method.- Specified by:
heartbeat
in interfaceTaskHandler
-
refreshStatus
public void refreshStatus(Task task)
TODO decide what to do with this method.- Specified by:
refreshStatus
in interfaceTaskHandler
-
getGlobalReportingOptions
@NotNull public @NotNull TaskReportingOptions getGlobalReportingOptions()
-
getMatchingRuleRegistry
@NotNull public @NotNull MatchingRuleRegistry getMatchingRuleRegistry()
-
getOperationExecutionRecorder
@NotNull public @NotNull OperationExecutionRecorderForTasks getOperationExecutionRecorder()
-
getLogger
@NotNull public @NotNull Trace getLogger()
-
getTracer
public Tracer getTracer()
-
getCacheConfigurationManager
public CacheConfigurationManager getCacheConfigurationManager()
-
-