Interface BulkUpdateProcessor<P>
- Type Parameters:
P- the business-domain type of the records this processor can filter by. While the basic filtration can only be applied to a single domain, the logic inmodifyAndPersist(List, BulkUpdate)can query/update additional domains that need to be adjusted as part of the update.
public interface BulkUpdateProcessor<P>
While
BulkUpdateManager is responsible for most of the coordination during a bulk update,
it will delegate to a BulkUpdateProcessor for operations that are specific to the
BulkUpdate.target and BulkUpdate.type.
Generally speaking, there should be one BulkUpdateProcessor registered for each
BulkUpdate.target that needs to be supported, and inside of it there should be
implementations for each desired BulkUpdate.type on that BulkUpdate.target.
The BulkUpdateManager will use only the first BulkUpdateProcessor for which
canHandle(BulkUpdate) returns true.
- Author:
- Samarth Dhruva (samarthd)
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleancanHandle(BulkUpdate bulkUpdate) Returns whether this processor can support performing the given bulk update operation.modifyAndPersist(List<P> batchToProcess, BulkUpdate bulkUpdate) Accepts a list of objects - this will be a batch subset of the full results returned inreadRecordsToProcess(BulkUpdate).readRecordsToProcess(BulkUpdate bulkUpdate) Returns the full stream of records from the data store that should be processed.
-
Method Details
-
canHandle
Returns whether this processor can support performing the given bulk update operation. Generally this should be entirely based onBulkUpdate.targetandBulkUpdate.type.- Parameters:
bulkUpdate- the update that needs to be processed- Returns:
- true if the processor can support performing the bulk update operation, false otherwise
-
readRecordsToProcess
Returns the full stream of records from the data store that should be processed.Implementations should utilize
BulkUpdate.filterString,BulkUpdate.inclusions, andBulkUpdate.exclusionsto filter/include results. A reasonable implementation could have the following rules:- If
filterStringis blank andinclusionsis not empty, only the entities specified ininclusionswill be returned (minus anyexclusions). - If
filterStringis blank andinclusionsis empty, all entities in the data store will be returned (minus anyexclusions). - If
filterStringis not blank, then all entities matching the filters and any entities specified ininclusionswill be returned (minus anyexclusions).
- Parameters:
bulkUpdate- the update that is being processed- Returns:
- a
ReadRecordsResponsecontaining the full stream of records from the data store that should be processed, withfilterString,inclusions, andexclusionsalready accounted for - See Also:
-
BulkUpdate.filterStringBulkUpdate.inclusionsBulkUpdate.exclusions
- If
-
modifyAndPersist
Accepts a list of objects - this will be a batch subset of the full results returned inreadRecordsToProcess(BulkUpdate). Then,BulkUpdate.serializedPayloadand context information (such asBulkUpdate.updatingSandboxId,BulkUpdate.updatingApplicationId,BulkUpdate.updatingCatalogId) should be used to apply the necessary modifications and persist the results.This method is called multiple times - once for each batch until all records are processed.
- Parameters:
batchToProcess- a list of records to update and persist. The maximum size of this list is defined byBulkUpdateProcessingConfigurationProperties.batchSize.bulkUpdate- the update that is being processed- Returns:
- a response describing whether the processing of the batch succeeded/failed
-