Class ChildPartitionsRecordAction
java.lang.Object
org.apache.beam.sdk.io.gcp.spanner.changestreams.action.ChildPartitionsRecordAction
This class is part of the process for
ReadChangeStreamPartitionDoFn
SDF. It is
responsible for processing ChildPartitionsRecord
s. The new child partitions will be
stored in the Connector's metadata tables in order to be scheduled for future querying by the
DetectNewPartitionsDoFn
SDF.-
Method Summary
Modifier and TypeMethodDescriptionrun
(PartitionMetadata partition, ChildPartitionsRecord record, RestrictionTracker<TimestampRange, com.google.cloud.Timestamp> tracker, RestrictionInterrupter<com.google.cloud.Timestamp> interrupter, ManualWatermarkEstimator<Instant> watermarkEstimator) This is the main processing function for aChildPartitionsRecord
.
-
Method Details
-
run
public Optional<DoFn.ProcessContinuation> run(PartitionMetadata partition, ChildPartitionsRecord record, RestrictionTracker<TimestampRange, com.google.cloud.Timestamp> tracker, RestrictionInterrupter<com.google.cloud.Timestamp> interrupter, ManualWatermarkEstimator<Instant> watermarkEstimator) This is the main processing function for aChildPartitionsRecord
. It returns anOptional
ofDoFn.ProcessContinuation
to indicate if the calling function should stop or not. If theOptional
returned is empty, it means that the calling function can continue with the processing. If anOptional
ofDoFn.ProcessContinuation.stop()
is returned, it means that this function was unable to claim the timestamp of theChildPartitionsRecord
, so the caller should stop.When processing the
ChildPartitionsRecord
the following procedure is applied:- We try to claim the child partition record timestamp. If it is not possible, we stop here and return.
- We update the watermark to the child partition record timestamp.
- For each child partition, we try to insert them in the metadata tables if they do not exist.
- For each child partition, we check if they originate from a split or a merge and increment the corresponding metric.
- Partition Splits: child partition tokens should not exist in the partition metadata table, so new rows are just added to such table. In case of a bundle retry, we silently ignore duplicate entries.
- Partition Merges: the first parent partition that receives the child token should succeed in inserting it. The remaining parents will silently ignore and skip the insertion.
- Parameters:
partition
- the current partition being processedrecord
- the change stream child partition record receivedtracker
- the restriction tracker of theReadChangeStreamPartitionDoFn
SDFinterrupter
- the restriction interrupter suggesting early termination of the processingwatermarkEstimator
- the watermark estimator of theReadChangeStreamPartitionDoFn
SDF- Returns:
Optional.empty()
if the caller can continue processing more records. A non emptyOptional
withDoFn.ProcessContinuation.stop()
if this function was unable to claim theChildPartitionsRecord
timestamp. A non emptyOptional
withDoFn.ProcessContinuation.resume()
if this function should commit what has already been processed and resume.
-