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 its ActivityStateDefinition
), 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 - see run(OperationResult)
, managing (among others):
a. activity state initialization and closing,
b. execution of "before run" code,
c. conversion of exceptions into ActivityRunResult
(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 of LocalActivityRun.runInternal(OperationResult)
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.evolveum.midpoint.task.api.ExecutionSupport
ExecutionSupport.CountersGroup
-
Field Summary
Modifier and TypeFieldDescriptionDefinition of the activity.protected final @NotNull CurrentActivityState<WS>
The "live" version of the activity state.protected Long
When did this run end?protected Long
When did this run start?protected final @NotNull ActivityBasedTaskRun
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
ModifierConstructorDescriptionprotected
AbstractActivityRun
(@NotNull ActivityRunInstantiationContext<WD, AH> context) -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
boolean
boolean
boolean
canRun()
@NotNull ActivityReportingCharacteristics
This method should be called only after the concrete instance is fully initialized.debugDump
(int indent) protected void
debugDumpExtra
(StringBuilder sb, int indent) protected ActivityStateDefinition<WS>
Called during initialization.protected @NotNull ActivityState
determineActivityStateForCounters
(@NotNull OperationResult result) protected void
protected void
protected void
Use this to disallow running activities that do not honor preview and/or dry-run mode, to avoid any confusion of the user.protected @NotNull ActivityDefinition<WD>
@NotNull ExecutionModeType
Returns the mode in which the activity executes (normal, dry run, simulate, ...).@NotNull ActivityPath
Returns the path of the activity we are executing.@NotNull CurrentActivityState<WS>
@NotNull ActivityStateDefinition<WS>
getBeans()
int
AbstractActivityRun<?,
?, ?> @NotNull ActivityReportingCharacteristics
@NotNull RunningTask
long
@NotNull ActivityBasedTaskRun
Returns task run that contains this activity run.protected @NotNull ActivityTreeStateOverview
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
boolean
isDryRun()
protected boolean
boolean
boolean
boolean
boolean
isWorker()
protected void
Called when the activity realization is complete.protected void
Called when the activity realization starts.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
boolean
Returns true if the work (business) state should be created right on activity run initialization, along with the rest of the state.protected ActivityRunResult
protected ActivityRunResult
standardRunResult
(@Nullable OperationResultStatus status) Finished (with specified status), or interrupted.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 Details
-
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, activityAH>> Definition of the activity. Contains the definition of the work. -
activityState
@NotNull protected final @NotNull CurrentActivityState<WS extends AbstractActivityWorkStateType> activityStateThe "live" version of the activity state. -
startTimestamp
When did this run start? -
endTimestamp
When did this run end?
-
-
Constructor Details
-
AbstractActivityRun
-
-
Method Details
-
createReportingCharacteristics
This method should be called only after the concrete instance is fully initialized. -
setInstanceReady
protected void setInstanceReady() -
determineActivityStateDefinition
Called during initialization. Should not access reporting characteristics. -
getTaskRun
Returns task run that contains this activity run. -
getActivity
-
getBeans
-
run
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:
-
runInternal
@NotNull protected abstract @NotNull ActivityRunResult runInternal(OperationResult result) throws ActivityRunException, CommonException Carries out the actual run of this activity.- Throws:
ActivityRunException
CommonException
-
toString
-
debugDump
- Specified by:
debugDump
in interfaceDebugDumpable
-
debugDumpExtra
-
getActivityPath
Description copied from interface:ExecutionSupport
Returns the path of the activity we are executing.- Specified by:
getActivityPath
in interfaceExecutionSupport
-
getLocalParentRun
-
getActivityHandler
-
getActivityState
-
getRunningTask
-
getTreeStateOverview
-
standardRunResult
-
standardRunResult
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
-
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
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
-
getActivityDefinition
-
getReportingCharacteristics
-
getStartTimestampRequired
public long getStartTimestampRequired() -
recordIterativeOperationStart
- Specified by:
recordIterativeOperationStart
in interfaceExecutionSupport
-
onActivityRealizationStart
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
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()
-