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)
  • Field Details

    • 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 Details

  • Method Details

    • 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.
    • getActivity

      @NotNull public @NotNull Activity<WD,AH> getActivity()
    • 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:
    • runInternal

      @NotNull protected abstract @NotNull ActivityRunResult runInternal(OperationResult result) throws ActivityRunException, CommonException
      Carries out the actual run of this activity.
      Throws:
      ActivityRunException
      CommonException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • debugDump

      public String debugDump(int indent)
      Specified by:
      debugDump in interface DebugDumpable
    • 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 interface ExecutionSupport
    • 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 interface ExecutionSupport
      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
      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 interface ExecutionSupport
    • 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 interface ExecutionSupport
    • 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()