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 TypeMethodDescriptionboolean
canHandle
(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.target
andBulkUpdate.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.exclusions
to filter/include results. A reasonable implementation could have the following rules:- If
filterString
is blank andinclusions
is not empty, only the entities specified ininclusions
will be returned (minus anyexclusions
). - If
filterString
is blank andinclusions
is empty, all entities in the data store will be returned (minus anyexclusions
). - If
filterString
is not blank, then all entities matching the filters and any entities specified ininclusions
will be returned (minus anyexclusions
).
- Parameters:
bulkUpdate
- the update that is being processed- Returns:
- a
ReadRecordsResponse
containing the full stream of records from the data store that should be processed, withfilterString
,inclusions
, andexclusions
already accounted for - See Also:
-
BulkUpdate.filterString
BulkUpdate.inclusions
BulkUpdate.exclusions
- If
-
modifyAndPersist
Accepts a list of objects - this will be a batch subset of the full results returned inreadRecordsToProcess(BulkUpdate)
. Then,BulkUpdate.serializedPayload
and 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
-