Class IterativeActivityRun<I,WD extends WorkDefinition,AH extends ActivityHandler<WD,AH>,WS extends AbstractActivityWorkStateType>
java.lang.Object
com.evolveum.midpoint.repo.common.activity.run.AbstractActivityRun<WD,AH,BS>
com.evolveum.midpoint.repo.common.activity.run.LocalActivityRun<WD,AH,WS>
com.evolveum.midpoint.repo.common.activity.run.IterativeActivityRun<I,WD,AH,WS>
- All Implemented Interfaces:
ImplicitSegmentationResolver
,IterativeActivityRunSpecifics
,ExecutionSupport
,DebugDumpable
- Direct Known Subclasses:
PlainIterativeActivityRun
,SearchBasedActivityRun
public abstract class IterativeActivityRun<I,WD extends WorkDefinition,AH extends ActivityHandler<WD,AH>,WS extends AbstractActivityWorkStateType>
extends LocalActivityRun<WD,AH,WS>
implements ExecutionSupport, IterativeActivityRunSpecifics
Represents a run of an iterative activity: either plain iterative one or search-based one.
Responsibilities at this level of abstraction:
1. Orchestrates the basic run cycle - see
runLocally(OperationResult)
:
a. calls before/after execution "hook" methods + the main execution routine,
b. generates the execution result based on kind(s) of error(s) encountered.
2. Orchestrates the basic bucket execution cycle - see processOrAnalyzeOrSkipSingleBucket(OperationResult)
:
a. item source preparation,
b. before/after bucket execution "hook" methods, along with main iterateOverItemsInBucket(OperationResult)
method,
c. sets up and winds down the coordinator,-
Nested Class Summary
Nested classes/interfaces inherited from interface com.evolveum.midpoint.task.api.ExecutionSupport
ExecutionSupport.CountersGroup
-
Field Summary
Modifier and TypeFieldDescriptionprotected final @NotNull CommonTaskBeans
Useful Spring beans.protected WorkBucketType
Current bucket that is being processed.protected ProcessingCoordinator<I>
Schedules individual items for processing by worker threads (if running in multiple threads).protected final @NotNull ErrorState
Error state.protected final @NotNull TransientActivityRunStatistics
Maintains selected statistical information related to processing items in the current run.Fields inherited from class com.evolveum.midpoint.repo.common.activity.run.AbstractActivityRun
activity, activityState, endTimestamp, startTimestamp, taskRun
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
-
Constructor Summary
ConstructorDescriptionIterativeActivityRun
(@NotNull ActivityRunInstantiationContext<WD, AH> context, @NotNull String shortName) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Returns true if it's safe to update TL statistics in coordinator.protected final @NotNull ActivityState
determineActivityStateForCounters
(@NotNull OperationResult result) @Nullable Integer
Determines the current bucket size.@Nullable Integer
determineOverallSize
(OperationResult result) Determines expected progress (overall size) for the activity.final void
final void
protected final void
Fails if there is any parallelism within this activity: worker threads or worker tasks.protected final void
Fails if worker threads are defined.final WorkBucketType
protected @Nullable String
Channel URI that should be set into the task during this activity run.final @NotNull ConnIdOperationsReport
final @NotNull String
final @NotNull String
Inserts a space before context description if it's not empty.protected abstract ErrorHandlingStrategyExecutor.FollowUpAction
@NotNull ErrorState
final @NotNull ItemsReport
final @NotNull String
final @NotNull String
final @NotNull TransientActivityRunStatistics
handleError
(@NotNull OperationResultStatus status, @NotNull Throwable exception, ItemProcessingRequest<?> request, OperationResult result) protected abstract boolean
isInRepository
(OperationResult result) Do we execute over items in repository? (Maybe the name should be changed.)final boolean
protected abstract void
Starts the item source (e.g.protected abstract void
Prepares the item source.abstract boolean
processItem
(@NotNull ItemProcessingRequest<I> request, @NotNull RunningTask workerTask, OperationResult result) protected final @NotNull ActivityRunResult
runLocally
(OperationResult result) final void
setContextDescription
(String value) final boolean
final boolean
final boolean
void
updateStatistics
(boolean updateThreadLocalStatistics, OperationResult result) Updates statistics in the coordinator task (including TL if it's safe to do so).Methods inherited from class com.evolveum.midpoint.repo.common.activity.run.LocalActivityRun
createReportingCharacteristics, getCurrentResultStatusBean, getDesiredTaskObjectRef, getSimulationTransaction, getTaskExecutionMode, isExcludedFromStalenessChecking, runInternal, shouldUpdateProgressInStateOverview, updateItemProgressInTreeOverviewIfTimePassed
Methods inherited from class com.evolveum.midpoint.repo.common.activity.run.AbstractActivityRun
areActionsExecutedStatisticsSupported, areRunRecordsSupported, areStatisticsSupported, areSynchronizationStatisticsSupported, canRun, debugDump, debugDumpExtra, determineActivityStateDefinition, ensureFullExecution, ensureNoDryRun, ensureNoPreviewNorDryRun, getActivity, getActivityDefinition, getActivityExecutionMode, getActivityHandler, getActivityPath, getActivityState, getActivityStateDefinition, getBeans, getItemsProcessed, getLocalParentRun, getReportingCharacteristics, getRunningTask, getStartTimestampRequired, getTaskRun, getTreeStateOverview, getWorkDefinition, incrementCounters, incrementProgress, isBucketAnalysis, isDryRun, isFullExecution, isNoExecution, isNonScavengingWorker, isProgressSupported, isWorker, onActivityRealizationComplete, onActivityRealizationStart, recordIterativeOperationStart, run, setInstanceReady, shouldCreateWorkStateOnInitialization, standardRunResult, standardRunResult, 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
Methods inherited from interface com.evolveum.midpoint.task.api.ExecutionSupport
getActivityExecutionMode, getActivityPath, incrementCounters, recordIterativeOperationStart
Methods inherited from interface com.evolveum.midpoint.repo.common.activity.run.IterativeActivityRunSpecifics
afterBucketProcessing, afterRun, beforeBucketProcessing, beforeRun, createReportingCharacteristics, resolveImplicitSegmentation, useOtherActivityStateForCounters
-
Field Details
-
bucket
Current bucket that is being processed. It is used to narrow the search query for search-based activities. -
coordinator
Schedules individual items for processing by worker threads (if running in multiple threads). Re-created for each individual bucket. -
errorState
Error state. In particular, should we stop immediately because of a fatal exception? TODO rethink this -
transientRunStatistics
Maintains selected statistical information related to processing items in the current run. It is like a simplified version ofActivityItemProcessingStatistics
that cover all the runs (and sometimes all the realizations) of an activity. -
beans
Useful Spring beans.
-
-
Constructor Details
-
IterativeActivityRun
public IterativeActivityRun(@NotNull @NotNull ActivityRunInstantiationContext<WD, AH> context, @NotNull @NotNull String shortName)
-
-
Method Details
-
runLocally
@NotNull protected final @NotNull ActivityRunResult runLocally(OperationResult result) throws ActivityRunException, CommonException - Specified by:
runLocally
in classLocalActivityRun<WD extends WorkDefinition,
AH extends ActivityHandler<WD, AH>, WS extends AbstractActivityWorkStateType> - Throws:
ActivityRunException
CommonException
-
getChannelOverride
Channel URI that should be set into the task during this activity run. (If not null.) -
prepareItemSourceForCurrentBucket
protected abstract void prepareItemSourceForCurrentBucket(OperationResult result) throws ActivityRunException, CommonException Prepares the item source. E.g. for search-iterative tasks we prepare object type, query, and options here. Iterative activities delegate this method fully to the plugin. However, search-based activities provide their own default implementation.- Throws:
ActivityRunException
CommonException
-
isInRepository
protected abstract boolean isInRepository(OperationResult result) throws ActivityRunException, CommonException Do we execute over items in repository? (Maybe the name should be changed.)- Throws:
ActivityRunException
CommonException
-
determineOverallSize
@Nullable public @Nullable Integer determineOverallSize(OperationResult result) throws CommonException, ActivityRunException Determines expected progress (overall size) for the activity. E.g. for search-based activities we count the objects here (overall).- Returns:
- null if no value could be determined or is not applicable
- Throws:
CommonException
ActivityRunException
-
determineCurrentBucketSize
@Nullable public @Nullable Integer determineCurrentBucketSize(OperationResult result) throws CommonException Determines the current bucket size. E.g. for search-based activities we count the objects here (in current bucket).- Returns:
- null if no value could be determined or is not applicable
- Throws:
CommonException
-
iterateOverItemsInBucket
Starts the item source (e.g. `searchObjectsIterative` call or `synchronize` call) and begins processing items generated by it. Returns when the source finishes. For example: - for search-based tasks, this call returns immediately after the iterative search is over; - for live sync task, this returns after all changes were fetched and acknowledged, and the resulting token was written; - for async update task, this returns also after all changes were fetched and acknowledged and confirmed to the source.- Throws:
CommonException
-
isMultithreaded
public final boolean isMultithreaded() -
ensureNoWorkerThreads
protected final void ensureNoWorkerThreads()Fails if worker threads are defined. To be used in tasks that do not support multithreading. -
ensureNoParallelism
protected final void ensureNoParallelism()Fails if there is any parallelism within this activity: worker threads or worker tasks. It is to avoid unintended parallel execution like the one in MID-7861. Note that this method does not preclude parallel execution with a different activity. But that is not enabled by default, so it's safe to assume it will not be configured by mistake. -
getShortName
-
getContextDescription
-
getContextDescriptionSpaced
Inserts a space before context description if it's not empty. -
setContextDescription
-
handleError
public final ErrorHandlingStrategyExecutor.FollowUpAction handleError(@NotNull @NotNull OperationResultStatus status, @NotNull @NotNull Throwable exception, ItemProcessingRequest<?> request, OperationResult result) -
getDefaultErrorAction
- Returns:
- Default error action if no policy is specified or if no policy entry matches.
-
getRootTaskOid
-
updateStatistics
public void updateStatistics(boolean updateThreadLocalStatistics, OperationResult result) throws SchemaException, ObjectNotFoundException Updates statistics in the coordinator task (including TL if it's safe to do so). If needed, also updates the statistics in the repository. Statistics updated in the task: - task.operationStats, - progress (both activity-based and legacy), - activity statistics: items, synchronization, actions executed, bucketing operations Note that using modifyObjectDynamically would be perhaps better, but the current use of last update timestamp ensures that there will not be concurrent updates of the coordinator coming from its worker threads. -
canUpdateThreadLocalStatistics
protected boolean canUpdateThreadLocalStatistics()Returns true if it's safe to update TL statistics in coordinator. Normally, it is so. A notable exception is asynchronous update using AMQP (an experimental feature for now). The reason is that the message handling occurs in a thread different from the task thread. See MID-7464. -
getTransientRunStatistics
-
processItem
public abstract boolean processItem(@NotNull @NotNull ItemProcessingRequest<I> request, @NotNull @NotNull RunningTask workerTask, OperationResult result) throws ActivityRunException, CommonException - Throws:
ActivityRunException
CommonException
-
determineActivityStateForCounters
@NotNull protected final @NotNull ActivityState determineActivityStateForCounters(@NotNull @NotNull OperationResult result) throws SchemaException, ObjectNotFoundException - Overrides:
determineActivityStateForCounters
in classAbstractActivityRun<WD extends WorkDefinition,
AH extends ActivityHandler<WD, AH>, WS extends AbstractActivityWorkStateType> - Throws:
SchemaException
ObjectNotFoundException
-
getItemsReport
-
getConnIdOperationsReport
-
shouldReportItems
public final boolean shouldReportItems() -
shouldReportConnIdOperations
public final boolean shouldReportConnIdOperations() -
shouldReportInternalOperations
public final boolean shouldReportInternalOperations() -
getBucket
-
enableGlobalConnIdOperationsListener
public final void enableGlobalConnIdOperationsListener() -
disableGlobalConnIdOperationsListener
public final void disableGlobalConnIdOperationsListener() -
getErrorState
-