Class SearchBasedActivityRun<C extends Containerable,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<C,WD,AH,WS>
-
- com.evolveum.midpoint.repo.common.activity.run.SearchBasedActivityRun<C,WD,AH,WS>
-
- All Implemented Interfaces:
ImplicitSegmentationResolver
,IterativeActivityRunSpecifics
,ExecutionSupport
,DebugDumpable
- Direct Known Subclasses:
AutoScalingActivityRun
,ImportActivityRun
,PartialReconciliationActivityRun
,ScanActivityRun
,ShadowCleanupActivityHandler.MyRun
,ShadowIntegrityCheckActivityRun
public abstract class SearchBasedActivityRun<C extends Containerable,WD extends WorkDefinition,AH extends ActivityHandler<WD,AH>,WS extends AbstractActivityWorkStateType> extends IterativeActivityRun<C,WD,AH,WS>
A run of a given search-iterative activity. Responsibilities: 1. Bucketing, i.e. orchestrating getting and processing buckets. SeeIterativeActivityRun.doRun(OperationResult)
. 2. Item source preparation = preparation of search specification (prepareSearchSpecificationAndSearchableItemSource(OperationResult)
). This includes a. converting the configured object set to search spec (or obtaining the spec from the specifics object -SearchBasedActivityRunSpecifics
; b. customizing the spec by calling `customizeXXX` methods in the specifics object; c. narrowing the query for bucketing and error handling. 3. "Expected total" determination - seeIterativeActivityRun.setExpectedTotal(OperationResult)
andIterativeActivityRun.setExpectedInCurrentBucket(OperationResult)
. 4. Pre-processing of items found - seeprocessItem(ItemProcessingRequest, RunningTask, OperationResult)
: a. checking for already-processed objects (OIDs seen), b. applying additional filter (currently used for retrying failed objects), c. applying additional pre-processing to objects (currently used for retrying failed objects),
-
-
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 SearchSpecification<C>
searchSpecification
Specification of the search that is to be executed: container type, query, options, and "use repository" flag.-
Fields inherited from class com.evolveum.midpoint.repo.common.activity.run.IterativeActivityRun
beans, bucket, coordinator, errorState, transientRunStatistics
-
Fields inherited from class com.evolveum.midpoint.repo.common.activity.run.AbstractActivityRun
activity, activityState, activityStateDefinition, endTimestamp, reportingCharacteristics, startTimestamp, taskRun
-
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
-
-
Constructor Summary
Constructors Constructor Description SearchBasedActivityRun(@NotNull ActivityRunInstantiationContext<WD,AH> context, @NotNull String shortNameCapitalized)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Default Methods Modifier and Type Method Description protected Integer
countObjects(OperationResult result)
Used to count objects using model or any similar higher-level interface.default @Nullable SearchSpecification<C>
createCustomSearchSpecification(OperationResult result)
Creates a complete search specification.default ItemDefinitionProvider
createItemDefinitionProvider()
Returns a provider of definitions for runtime items (e.g.default ObjectQuery
customizeQuery(ObjectQuery configuredQuery, OperationResult result)
Customizes a query present in the original search specification (usually derived from the task configuration).default Collection<SelectorOptions<GetOperationOptions>>
customizeSearchOptions(Collection<SelectorOptions<GetOperationOptions>> configuredOptions, OperationResult result)
Customizes search options present in the original search specification (usually derived from the task configuration).@Nullable Integer
determineCurrentBucketSize(OperationResult result)
Determines the current bucket size.@Nullable Integer
determineOverallSize(OperationResult result)
Determines expected progress (overall size) for the activity.default boolean
doesRequireDirectRepositoryAccess()
protected ErrorHandlingStrategyExecutor.FollowUpAction
getDefaultErrorAction()
protected ExpressionProfile
getExpressionProfile()
Class<C>
getItemType()
ObjectQuery
getQuery()
SchemaService
getSchemaService()
Collection<SelectorOptions<GetOperationOptions>>
getSearchOptions()
protected @NotNull SearchSpecification<C>
getSearchSpecificationRequired()
protected TaskManager
getTaskManager()
protected boolean
isInRepository(OperationResult result)
Do we execute over items in repository? (Maybe the name should be changed.)protected void
iterateOverItemsInBucket(OperationResult result)
Starts the item source (e.g.protected void
prepareItemSourceForCurrentBucket(OperationResult result)
Prepares the item source.protected boolean
processError(C item, @NotNull OperationResultType errorFetchResult, RunningTask workerTask, OperationResult result)
boolean
processItem(@NotNull ItemProcessingRequest<C> request, @NotNull RunningTask workerTask, OperationResult result)
boolean
processItem(C item, @NotNull ItemProcessingRequest<C> request, RunningTask workerTask, OperationResult result)
Processes given item that came as part of a request.-
Methods inherited from class com.evolveum.midpoint.repo.common.activity.run.IterativeActivityRun
determineActivityStateForCounters, disableGlobalConnIdOperationsListener, enableGlobalConnIdOperationsListener, ensureNoWorkerThreads, getBucket, getConnIdOperationsReport, getContextDescription, getContextDescriptionSpaced, getErrorState, getItemsReport, getRootTask, getRootTaskOid, getShortName, getShortNameUncapitalized, getStartTimeMillis, getTransientRunStatistics, handleError, isMultithreaded, runLocally, setContextDescription, shouldReportConnIdOperations, shouldReportInternalOperations, shouldReportItems, updateStatistics
-
Methods inherited from class com.evolveum.midpoint.repo.common.activity.run.LocalActivityRun
createReportingCharacteristics, getCurrentResultStatus, getCurrentResultStatusBean, getDesiredTaskObjectRef, isExcludedFromStalenessChecking, runInternal, setCurrentResultStatus, shouldUpdateProgressInStateOverview, updateItemProgressInTreeOverviewIfTimePassed
-
Methods inherited from class com.evolveum.midpoint.repo.common.activity.run.AbstractActivityRun
areActionsExecutedStatisticsSupported, areRunRecordsSupported, areStatisticsSupported, areSynchronizationStatisticsSupported, autoComputeRunResult, canRun, debugDump, debugDumpExtra, determineActivityStateDefinition, getActivity, getActivityDefinition, getActivityHandler, getActivityLocalPath, getActivityPath, getActivityState, getActivityStateDefinition, getBeans, getEndTimestamp, getExecutionMode, getItemsProcessed, getLocalParentRun, getPersistenceType, getPrismContext, getReportingCharacteristics, getReportingDefinition, getRunningTask, getStartTimestamp, getStartTimestampRequired, getTaskRun, getTreeStateOverview, getWorkDefinition, getWorkStateTypeName, incrementCounters, incrementProgress, isBucketAnalysis, isDryRun, isFullExecution, isNoExecution, isNonScavengingWorker, isPreview, isProgressSupported, isWorker, 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
getActivityPath, getExecutionMode, incrementCounters, recordIterativeOperationStart
-
Methods inherited from interface com.evolveum.midpoint.repo.common.activity.run.IterativeActivityRunSpecifics
afterBucketProcessing, afterRun, beforeBucketProcessing, beforeRun, createReportingCharacteristics, resolveImplicitSegmentation, useOtherActivityStateForCounters
-
-
-
-
Field Detail
-
searchSpecification
protected SearchSpecification<C extends Containerable> searchSpecification
Specification of the search that is to be executed: container type, query, options, and "use repository" flag.
-
-
Constructor Detail
-
SearchBasedActivityRun
public SearchBasedActivityRun(@NotNull @NotNull ActivityRunInstantiationContext<WD,AH> context, @NotNull @NotNull String shortNameCapitalized)
-
-
Method Detail
-
prepareItemSourceForCurrentBucket
protected final void prepareItemSourceForCurrentBucket(OperationResult result) throws ActivityRunException, CommonException
Description copied from class:IterativeActivityRun
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.- Specified by:
prepareItemSourceForCurrentBucket
in classIterativeActivityRun<C extends Containerable,WD extends WorkDefinition,AH extends ActivityHandler<WD,AH>,WS extends AbstractActivityWorkStateType>
- Throws:
ActivityRunException
CommonException
-
isInRepository
protected final boolean isInRepository(OperationResult result) throws ActivityRunException, CommonException
Description copied from class:IterativeActivityRun
Do we execute over items in repository? (Maybe the name should be changed.)- Specified by:
isInRepository
in classIterativeActivityRun<C extends Containerable,WD extends WorkDefinition,AH extends ActivityHandler<WD,AH>,WS extends AbstractActivityWorkStateType>
- Throws:
ActivityRunException
CommonException
-
determineOverallSize
@Nullable public final @Nullable Integer determineOverallSize(OperationResult result) throws CommonException, ActivityRunException
Description copied from class:IterativeActivityRun
Determines expected progress (overall size) for the activity. E.g. for search-based activities we count the objects here (overall).- Overrides:
determineOverallSize
in classIterativeActivityRun<C extends Containerable,WD extends WorkDefinition,AH extends ActivityHandler<WD,AH>,WS extends AbstractActivityWorkStateType>
- Returns:
- null if no value could be determined or is not applicable
- Throws:
CommonException
ActivityRunException
-
determineCurrentBucketSize
@Nullable public final @Nullable Integer determineCurrentBucketSize(OperationResult result) throws CommonException
Description copied from class:IterativeActivityRun
Determines the current bucket size. E.g. for search-based activities we count the objects here (in current bucket).- Overrides:
determineCurrentBucketSize
in classIterativeActivityRun<C extends Containerable,WD extends WorkDefinition,AH extends ActivityHandler<WD,AH>,WS extends AbstractActivityWorkStateType>
- Returns:
- null if no value could be determined or is not applicable
- Throws:
CommonException
-
countObjects
protected Integer countObjects(OperationResult result) throws CommonException
Used to count objects using model or any similar higher-level interface. Defaults to repository count.- Throws:
CommonException
-
iterateOverItemsInBucket
protected final void iterateOverItemsInBucket(OperationResult result) throws CommonException
Description copied from class:IterativeActivityRun
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.- Specified by:
iterateOverItemsInBucket
in classIterativeActivityRun<C extends Containerable,WD extends WorkDefinition,AH extends ActivityHandler<WD,AH>,WS extends AbstractActivityWorkStateType>
- Throws:
CommonException
-
getDefaultErrorAction
@NotNull protected final ErrorHandlingStrategyExecutor.FollowUpAction getDefaultErrorAction()
- Specified by:
getDefaultErrorAction
in classIterativeActivityRun<C extends Containerable,WD extends WorkDefinition,AH extends ActivityHandler<WD,AH>,WS extends AbstractActivityWorkStateType>
- Returns:
- Default error action if no policy is specified or if no policy entry matches.
-
processItem
public final boolean processItem(@NotNull @NotNull ItemProcessingRequest<C> request, @NotNull @NotNull RunningTask workerTask, OperationResult result) throws CommonException, ActivityRunException
- Specified by:
processItem
in classIterativeActivityRun<C extends Containerable,WD extends WorkDefinition,AH extends ActivityHandler<WD,AH>,WS extends AbstractActivityWorkStateType>
- Throws:
CommonException
ActivityRunException
-
processError
protected final boolean processError(C item, @NotNull @NotNull OperationResultType errorFetchResult, RunningTask workerTask, OperationResult result) throws CommonException, ActivityRunException
- Throws:
CommonException
ActivityRunException
-
getExpressionProfile
protected ExpressionProfile getExpressionProfile()
-
getSchemaService
public final SchemaService getSchemaService()
-
getTaskManager
protected final TaskManager getTaskManager()
-
getSearchSpecificationRequired
@NotNull protected final @NotNull SearchSpecification<C> getSearchSpecificationRequired()
-
getQuery
public final ObjectQuery getQuery()
-
getSearchOptions
public final Collection<SelectorOptions<GetOperationOptions>> getSearchOptions()
-
createCustomSearchSpecification
@Nullable public default @Nullable SearchSpecification<C> createCustomSearchSpecification(OperationResult result)
Creates a complete search specification. If the activity is not interested in this kind of customization, it should return null, and the default search specification is then produced by theSearchBasedActivityRun
. Note: freely addCommonException
andActivityRunException
to the signature of this method if needed.
-
customizeQuery
public default ObjectQuery customizeQuery(ObjectQuery configuredQuery, OperationResult result) throws CommonException
Customizes a query present in the original search specification (usually derived from the task configuration). The activity can either add specific clauses here, or rewrite the query altogether.- Throws:
CommonException
-
customizeSearchOptions
public default Collection<SelectorOptions<GetOperationOptions>> customizeSearchOptions(Collection<SelectorOptions<GetOperationOptions>> configuredOptions, OperationResult result) throws CommonException
Customizes search options present in the original search specification (usually derived from the task configuration). The activity can either add or modify some options in the provided object - if it's not null - or replace the whole object by its own version.- Throws:
CommonException
-
doesRequireDirectRepositoryAccess
public default boolean doesRequireDirectRepositoryAccess()
- Returns:
- True if the activity requires direct repository access. Note that the framework does not check the authorizations of the user running the activity in such cases. If an autz check is needed, the activity is responsible for that.
-
createItemDefinitionProvider
public default ItemDefinitionProvider createItemDefinitionProvider()
Returns a provider of definitions for runtime items (e.g. attributes) that are needed in bucket filters. Usually needed for activities that work with resource objects.
-
processItem
public abstract boolean processItem(@NotNull C item, @NotNull @NotNull ItemProcessingRequest<C> request, RunningTask workerTask, OperationResult result) throws CommonException, ActivityRunException
Processes given item that came as part of a request. BEWARE: Item may have been preprocessed, and may be different from the item present in the request.- Throws:
CommonException
ActivityRunException
-
-