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 in modifyAndPersist(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 Details

    • canHandle

      boolean canHandle(BulkUpdate bulkUpdate)
      Returns whether this processor can support performing the given bulk update operation. Generally this should be entirely based on BulkUpdate.target and BulkUpdate.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

      ReadRecordsResponse<P> readRecordsToProcess(BulkUpdate bulkUpdate)
      Returns the full stream of records from the data store that should be processed.

      Implementations should utilize BulkUpdate.filterString, BulkUpdate.inclusions, and BulkUpdate.exclusions to filter/include results. A reasonable implementation could have the following rules:

      • If filterString is blank and inclusions is not empty, only the entities specified in inclusions will be returned (minus any exclusions).
      • If filterString is blank and inclusions is empty, all entities in the data store will be returned (minus any exclusions).
      • If filterString is not blank, then all entities matching the filters and any entities specified in inclusions will be returned (minus any exclusions).
      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, with filterString, inclusions, and exclusions already accounted for
      See Also:
      • BulkUpdate.filterString
      • BulkUpdate.inclusions
      • BulkUpdate.exclusions
    • modifyAndPersist

      BatchProcessResponse modifyAndPersist(List<P> batchToProcess, BulkUpdate bulkUpdate)
      Accepts a list of objects - this will be a batch subset of the full results returned in readRecordsToProcess(BulkUpdate). Then, BulkUpdate.serializedPayload and context information (such as BulkUpdate.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 by BulkUpdateProcessingConfigurationProperties.batchSize.
      bulkUpdate - the update that is being processed
      Returns:
      a response describing whether the processing of the batch succeeded/failed