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 (execution) of an activity in the current task. Responsibilities _at this [highest] level of abstraction_: . Maintains links to other activity framework objects: -taskRun
(ActivityBasedTaskRun
) -activity
(Activity
) -activityState
(ActivityState
) (and itsActivityStateDefinition
), including the state holding thresholds-supporting counters . Provides methods for navigation to more distant objects of the framework and other auxiliary objects (beans). . Provides skeleton of the execution - seerun(OperationResult)
, managing (among others): a. activity state initialization and closing, b. execution of "before run" code, c. conversion of exceptions intoActivityRunResult
(such conversion is done at various other levels, btw), d. start/end logging, e. updating task statistics, f. sending notifications. + Some of these duties are related to ones ofLocalActivityRun.runInternal(OperationResult)
-
-
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 Long
endTimestamp
When did this run end?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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
areActionsExecutedStatisticsSupported()
boolean
areRunRecordsSupported()
boolean
areStatisticsSupported()
boolean
areSynchronizationStatisticsSupported()
boolean
canRun()
@NotNull ActivityReportingCharacteristics
createReportingCharacteristics()
This method should be called only after the concrete instance is fully initialized.String
debugDump(int indent)
protected void
debugDumpExtra(StringBuilder sb, int indent)
protected ActivityStateDefinition<WS>
determineActivityStateDefinition()
Called during initialization.protected @NotNull ActivityState
determineActivityStateForCounters(@NotNull OperationResult result)
protected void
ensureFullExecution()
protected void
ensureNoDryRun()
protected void
ensureNoPreviewNorDryRun()
Use this to disallow running activities that do not honor preview and/or dry-run mode, to avoid any confusion of the user.@NotNull Activity<WD,AH>
getActivity()
protected @NotNull ActivityDefinition<WD>
getActivityDefinition()
@NotNull ExecutionModeType
getActivityExecutionMode()
Returns the mode in which the activity executes (normal, dry run, simulate, ...).AH
getActivityHandler()
@NotNull ActivityPath
getActivityPath()
Returns the path of the activity we are executing.@NotNull CurrentActivityState<WS>
getActivityState()
@NotNull ActivityStateDefinition<WS>
getActivityStateDefinition()
CommonTaskBeans
getBeans()
int
getItemsProcessed()
AbstractActivityRun<?,?,?>
getLocalParentRun()
@NotNull ActivityReportingCharacteristics
getReportingCharacteristics()
@NotNull RunningTask
getRunningTask()
long
getStartTimestampRequired()
@NotNull ActivityBasedTaskRun
getTaskRun()
Returns task run that contains this activity run.protected @NotNull ActivityTreeStateOverview
getTreeStateOverview()
WD
getWorkDefinition()
Map<String,Integer>
incrementCounters(@NotNull ExecutionSupport.CountersGroup counterGroup, @NotNull Collection<String> countersIdentifiers, @NotNull OperationResult result)
Increments given counters related to the activity execution.void
incrementProgress(@NotNull QualifiedItemProcessingOutcomeType outcome)
boolean
isBucketAnalysis()
boolean
isDryRun()
protected boolean
isFullExecution()
boolean
isNoExecution()
boolean
isNonScavengingWorker()
boolean
isProgressSupported()
boolean
isWorker()
protected void
onActivityRealizationComplete(OperationResult result)
Called when the activity realization is complete.protected void
onActivityRealizationStart(OperationResult result)
Called when the activity realization starts.Operation
recordIterativeOperationStart(@NotNull IterativeOperationStartInfo info)
@NotNull ActivityRunResult
run(OperationResult result)
Runs the activity.protected abstract @NotNull ActivityRunResult
runInternal(OperationResult result)
Carries out the actual run of this activity.protected void
setInstanceReady()
boolean
shouldCreateWorkStateOnInitialization()
Returns true if the work (business) state should be created right on activity run initialization, along with the rest of the state.protected ActivityRunResult
standardRunResult()
protected ActivityRunResult
standardRunResult(@Nullable OperationResultStatus status)
Finished (with specified status), or interrupted.String
toString()
-
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.
-
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?
-
-
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
- See Also:
LocalActivityRun.runInternal(OperationResult)
-
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)
-
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()
-
getTreeStateOverview
@NotNull protected @NotNull ActivityTreeStateOverview getTreeStateOverview()
-
standardRunResult
protected ActivityRunResult standardRunResult()
-
standardRunResult
protected ActivityRunResult standardRunResult(@Nullable @Nullable OperationResultStatus status)
Finished (with specified status), or interrupted.
-
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.
-
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
-
getActivityExecutionMode
@NotNull public @NotNull ExecutionModeType getActivityExecutionMode()
Description copied from interface:ExecutionSupport
Returns the mode in which the activity executes (normal, dry run, simulate, ...).- Specified by:
getActivityExecutionMode
in interfaceExecutionSupport
-
isDryRun
public boolean isDryRun()
-
isFullExecution
protected 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 protected @NotNull ActivityDefinition<WD> getActivityDefinition()
-
getReportingCharacteristics
@NotNull public @NotNull ActivityReportingCharacteristics getReportingCharacteristics()
-
getStartTimestampRequired
public long getStartTimestampRequired()
-
recordIterativeOperationStart
public Operation recordIterativeOperationStart(@NotNull @NotNull IterativeOperationStartInfo info)
- Specified by:
recordIterativeOperationStart
in interfaceExecutionSupport
-
onActivityRealizationStart
protected void onActivityRealizationStart(OperationResult result) throws ActivityRunException
Called when the activity realization starts. - For delegated activities this is _after_ the delegation occurred. (I.e. in the delegate run.) - For distributed activities this is before any of the workers are started. - For non-delegated, non-distributed (local-only) activities this is when the local run starts the first time. Overall, this should happen exactly once per activity realization. In subclasses: Do not forget to call the implementation in the super-class.- Throws:
ActivityRunException
-
onActivityRealizationComplete
protected void onActivityRealizationComplete(OperationResult result) throws ActivityRunException
Called when the activity realization is complete. It should be called at most once for any given activity. (Regardless of its delegation or distribution.) Planned e.g. for closing the simulation result (for computing statistics, etc). TODO this is something like a placeholder for now -- probably it will NOT work in the current implementation!- Throws:
ActivityRunException
-
ensureNoPreviewNorDryRun
protected void ensureNoPreviewNorDryRun()
Use this to disallow running activities that do not honor preview and/or dry-run mode, to avoid any confusion of the user.
-
ensureNoDryRun
protected void ensureNoDryRun()
-
ensureFullExecution
protected void ensureFullExecution()
-
-