Class AbstractActivityRun<WD extends WorkDefinition,AH extends ActivityHandler<WD,AH>,WS extends AbstractActivityWorkStateType>
- java.lang.Object
-
- com.evolveum.midpoint.repo.common.activity.run.AbstractActivityRun<WD,AH,WS>
-
- Type Parameters:
WD
- Definition of the work that this activity has to do.AH
- Type of the activity handler.WS
- Type of the activity work (business) state.
- All Implemented Interfaces:
ExecutionSupport
,DebugDumpable
- Direct Known Subclasses:
DelegatingActivityRun
,DistributingActivityRun
,LocalActivityRun
public abstract class AbstractActivityRun<WD extends WorkDefinition,AH extends ActivityHandler<WD,AH>,WS extends AbstractActivityWorkStateType> extends Object implements ExecutionSupport, DebugDumpable
Implements (represents) a run of an activity. Responsibilities _at this [highest] level of abstraction_: 1. During execution - seerun(OperationResult)
: a. initializes activity state (if needed), b. skips run of the activity if the activity realization is complete, c. executes "before run" and the real code, d. handles exceptions thrown by the execution code, converting them intoActivityRunResult
(such conversion is done at various other levels, btw), e. logs the start/end, f. updates execution and result (op) status in the repository, 2. Maintains links to other activity framework objects: task run, activity, activity state (and its definition), activity state for counters. 3. Provides methods for navigation to more distant objects of the framework and other auxiliary objects (beans).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.evolveum.midpoint.task.api.ExecutionSupport
ExecutionSupport.CountersGroup
-
-
Field Summary
Fields Modifier and Type Field Description protected @NotNull Activity<WD,AH>
activity
Definition of the activity.protected @NotNull CurrentActivityState<WS>
activityState
The "live" version of the activity state.protected @NotNull ActivityStateDefinition<WS>
activityStateDefinition
Captures traits of the activity state (e.g.protected Long
endTimestamp
When did this run end?protected @NotNull Lazy<ActivityReportingCharacteristics>
reportingCharacteristics
Reporting characteristics of this kind of activity run.protected Long
startTimestamp
When did this run start?protected @NotNull ActivityBasedTaskRun
taskRun
The task run in context of which this activity run takes place.-
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractActivityRun(@NotNull ActivityRunInstantiationContext<WD,AH> context)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.evolveum.midpoint.util.DebugDumpable
debugDump, debugDumpLazily, debugDumpLazily
-
-
-
-
Field Detail
-
taskRun
@NotNull protected final @NotNull ActivityBasedTaskRun taskRun
The task run in context of which this activity run takes place.
-
activity
@NotNull protected final @NotNull Activity<WD extends WorkDefinition,AH extends ActivityHandler<WD,AH>> activity
Definition of the activity. Contains the definition of the work.
-
activityStateDefinition
@NotNull protected final @NotNull ActivityStateDefinition<WS extends AbstractActivityWorkStateType> activityStateDefinition
Captures traits of the activity state (e.g. if it has to be created).
-
activityState
@NotNull protected final @NotNull CurrentActivityState<WS extends AbstractActivityWorkStateType> activityState
The "live" version of the activity state.
-
startTimestamp
protected Long startTimestamp
When did this run start?
-
endTimestamp
protected Long endTimestamp
When did this run end?
-
reportingCharacteristics
@NotNull protected final @NotNull Lazy<ActivityReportingCharacteristics> reportingCharacteristics
Reporting characteristics of this kind of activity run. Can be used only after the concrete instance is ready (i.e. fully initialized)!
-
-
Constructor Detail
-
AbstractActivityRun
protected AbstractActivityRun(@NotNull @NotNull ActivityRunInstantiationContext<WD,AH> context)
-
-
Method Detail
-
createReportingCharacteristics
@NotNull public @NotNull ActivityReportingCharacteristics createReportingCharacteristics()
This method should be called only after the concrete instance is fully initialized.
-
setInstanceReady
protected void setInstanceReady()
-
determineActivityStateDefinition
protected ActivityStateDefinition<WS> determineActivityStateDefinition()
Called during initialization. Should not access reporting characteristics.
-
getTaskRun
@NotNull public @NotNull ActivityBasedTaskRun getTaskRun()
Returns task run that contains this activity run.
-
getBeans
public CommonTaskBeans getBeans()
-
run
@NotNull public @NotNull ActivityRunResult run(OperationResult result) throws ActivityRunException
Runs the activity. This method is responsible for carrying out the work, e.g. recomputing all the users. For pure- or semi-composite activities it is also responsible for creating the children runs. Note that the work can be delegated to other (asynchronous) tasks. This is the case of worker tasks in multi-node task run, or of activities executed as separate subtasks.- Throws:
ActivityRunException
-
runInternal
@NotNull protected abstract @NotNull ActivityRunResult runInternal(OperationResult result) throws ActivityRunException, CommonException
Carries out the actual run of this activity.- Throws:
ActivityRunException
CommonException
-
debugDump
public String debugDump(int indent)
- Specified by:
debugDump
in interfaceDebugDumpable
-
debugDumpExtra
protected void debugDumpExtra(StringBuilder sb, int indent)
-
getActivityLocalPath
@Nullable public @Nullable ActivityPath getActivityLocalPath()
-
getActivityPath
@NotNull public @NotNull ActivityPath getActivityPath()
Description copied from interface:ExecutionSupport
Returns the path of the activity we are executing.- Specified by:
getActivityPath
in interfaceExecutionSupport
-
getLocalParentRun
public AbstractActivityRun<?,?,?> getLocalParentRun()
-
getActivityHandler
@NotNull public AH getActivityHandler()
-
getActivityState
@NotNull public @NotNull CurrentActivityState<WS> getActivityState()
-
getRunningTask
@NotNull public @NotNull RunningTask getRunningTask()
-
getWorkStateTypeName
@NotNull public @NotNull QName getWorkStateTypeName()
-
getTreeStateOverview
@NotNull protected @NotNull ActivityTreeStateOverview getTreeStateOverview()
-
standardRunResult
protected ActivityRunResult standardRunResult()
-
standardRunResult
protected ActivityRunResult standardRunResult(@Nullable @Nullable OperationResultStatus status)
Finished (with specified status), or interrupted.
-
autoComputeRunResult
protected ActivityRunResult autoComputeRunResult()
The status will be computed based on current operation result. (This is ensured by setting the status to `null`.)
-
canRun
public boolean canRun()
-
shouldCreateWorkStateOnInitialization
public boolean shouldCreateWorkStateOnInitialization()
- Returns:
- true if the work (business) state should be created right on activity run initialization, along with the rest of the state Maybe we should provide this customization in the "specifics" interface for iterative activities.
-
getPersistenceType
@NotNull public @NotNull ActivityStatePersistenceType getPersistenceType()
-
getPrismContext
@NotNull public @NotNull PrismContext getPrismContext()
-
areStatisticsSupported
public boolean areStatisticsSupported()
-
isProgressSupported
public boolean isProgressSupported()
-
areSynchronizationStatisticsSupported
public boolean areSynchronizationStatisticsSupported()
-
areActionsExecutedStatisticsSupported
public boolean areActionsExecutedStatisticsSupported()
-
areRunRecordsSupported
public boolean areRunRecordsSupported()
-
incrementProgress
public void incrementProgress(@NotNull @NotNull QualifiedItemProcessingOutcomeType outcome)
-
getActivityStateDefinition
@NotNull public @NotNull ActivityStateDefinition<WS> getActivityStateDefinition()
-
incrementCounters
public Map<String,Integer> incrementCounters(@NotNull @NotNull ExecutionSupport.CountersGroup counterGroup, @NotNull @NotNull Collection<String> countersIdentifiers, @NotNull @NotNull OperationResult result) throws SchemaException, ObjectNotFoundException, ObjectAlreadyExistsException
Description copied from interface:ExecutionSupport
Increments given counters related to the activity execution.- Specified by:
incrementCounters
in interfaceExecutionSupport
- Returns:
- Current values of the counters (after the update).
- Throws:
SchemaException
ObjectNotFoundException
ObjectAlreadyExistsException
-
determineActivityStateForCounters
@NotNull protected @NotNull ActivityState determineActivityStateForCounters(@NotNull @NotNull OperationResult result) throws SchemaException, ObjectNotFoundException
-
getExecutionMode
@NotNull public @NotNull ExecutionModeType getExecutionMode()
Description copied from interface:ExecutionSupport
Returns the mode in which the activity executes (normal, dry run, simulate, ...).- Specified by:
getExecutionMode
in interfaceExecutionSupport
-
isPreview
public boolean isPreview()
-
isDryRun
public boolean isDryRun()
-
isFullExecution
public boolean isFullExecution()
-
isNoExecution
public boolean isNoExecution()
-
isBucketAnalysis
public boolean isBucketAnalysis()
-
getItemsProcessed
public int getItemsProcessed()
-
isNonScavengingWorker
public boolean isNonScavengingWorker()
-
isWorker
public boolean isWorker()
-
getWorkDefinition
@NotNull public WD getWorkDefinition()
-
getActivityDefinition
@NotNull public @NotNull ActivityDefinition<WD> getActivityDefinition()
-
getReportingDefinition
@NotNull public @NotNull ActivityReportingDefinition getReportingDefinition()
-
getReportingCharacteristics
@NotNull public @NotNull ActivityReportingCharacteristics getReportingCharacteristics()
-
getStartTimestamp
public Long getStartTimestamp()
-
getStartTimestampRequired
public long getStartTimestampRequired()
-
getEndTimestamp
public Long getEndTimestamp()
-
recordIterativeOperationStart
public Operation recordIterativeOperationStart(@NotNull @NotNull IterativeOperationStartInfo info)
- Specified by:
recordIterativeOperationStart
in interfaceExecutionSupport
-
getDiagName
@NotNull public @NotNull String getDiagName()
Returns the name for diagnostic purposes, e.g. when logging an error.
-
-