Class ReadChangeStreamPartitionProgressTracker
ReadChangeStreamPartitionDoFn to keep
 track of the progress of the stream and to split the restriction for runner initiated
 checkpoints.
 StreamProgress usually is a continuation token which represents a position in time of the stream of a specific partition. The token is used to resume streaming a partition.
On ChangeStreamMutation or Heartbeat response, the tracker will try to claim the continuation token from the response. The tracker stores that continuation token (wrapped in a StreamProgress) so that if the DoFn checkpoints or restarts, the token can be used to resume the stream.
The tracker will fail to claim a token if runner has initiated a checkpoint (by calling 
 trySplit(0)). This signals to the DoFn to stop.
 
When runner initiates a checkpoint, the tracker returns null for the primary split and the residual split includes the entire token. The next time the DoFn try to claim a new StreamProgress, it will fail, and stop. The residual will be scheduled on a new DoFn to resume the work from the previous StreamProgress
- 
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker
RestrictionTracker.HasProgress, RestrictionTracker.IsBounded, RestrictionTracker.Progress, RestrictionTracker.TruncateResult<RestrictionT> - 
Constructor Summary
ConstructorsConstructorDescriptionReadChangeStreamPartitionProgressTracker(StreamProgress streamProgress) Constructs a restriction tracker with the streamProgress. - 
Method Summary
Modifier and TypeMethodDescriptionvoidThis is to signal to the runner that this restriction has completed.Returns the streamProgress that was successfully claimed.This restriction tracker is for unbounded streams.toString()booleantryClaim(StreamProgress streamProgress) Claims a new StreamProgress to be processed.trySplit(double fractionOfRemainder) Splits the work that's left. 
- 
Constructor Details
- 
ReadChangeStreamPartitionProgressTracker
Constructs a restriction tracker with the streamProgress.- Parameters:
 streamProgress- represents a position in time of the stream.
 
 - 
 - 
Method Details
- 
isBounded
This restriction tracker is for unbounded streams.- Specified by:
 isBoundedin classRestrictionTracker<StreamProgress,StreamProgress> - Returns:
 - 
invalid reference
IsBounded.UNBOUNDED 
 - 
checkDone
This is to signal to the runner that this restriction has completed. Throw an exception if there is more work to be done, and it should not stop. A restriction tracker stops after a runner initiated checkpoint or the streamProgress contains a closeStream response and not a token.- Specified by:
 checkDonein classRestrictionTracker<StreamProgress,StreamProgress> - Throws:
 IllegalStateException- when the restriction is not done and there is more work to be done.
 - 
tryClaim
Claims a new StreamProgress to be processed. StreamProgress can either be a ContinuationToken or a CloseStream.The claim fails if the runner has previously initiated a checkpoint. The restriction tracker respects the runner initiated checkpoint and fails to claim this streamProgress. The new split will start from the previously successfully claimed streamProgress.
- Specified by:
 tryClaimin classRestrictionTracker<StreamProgress,StreamProgress> - Parameters:
 streamProgress- position in time of the stream that is being claimed.- Returns:
 - true if claim was successful, otherwise false.
 
 - 
currentRestriction
Returns the streamProgress that was successfully claimed.- Specified by:
 currentRestrictionin classRestrictionTracker<StreamProgress,StreamProgress> - Returns:
 - the streamProgress that was successfully claimed.
 
 - 
trySplit
Splits the work that's left. Since the position in the stream isn't a contiguous value, we cannot estimate how much work is left or breakdown the work into smaller chunks. Therefore, there's no way to split the work. To conform to the API, we return null for the primary split and then continue the work on the residual split.Also note that, we only accept checkpoints (fractionOfRemainder = 0). Any other value, we reject (by returning
null) the request to split since StreamProgress cannot be broken down into fractions.- Specified by:
 trySplitin classRestrictionTracker<StreamProgress,StreamProgress> - Parameters:
 fractionOfRemainder- the fraction of work remaining, where 0 is a request to checkpoint current work.- Returns:
 - split result when fractionOfRemainder = 0, otherwise null.
 
 - 
toString
 
 -