public class ReadChangeStreamPartitionRangeTracker extends OffsetRangeTracker
OffsetRangeTracker
. It modifies the
behaviour of OffsetRangeTracker.tryClaim(Long)
to ignore claims for the same long
multiple times. This is because several change stream records might have the same timestamp, thus
leading to multiple claims of the same Long
. Other than that, it modifies the OffsetRangeTracker.trySplit(double)
method to always deny splits for the InitialPartition.PARTITION_TOKEN
, since we only need to perform this query once.RestrictionTracker.HasProgress, RestrictionTracker.IsBounded, RestrictionTracker.Progress, RestrictionTracker.TruncateResult<RestrictionT>
lastAttemptedOffset, lastClaimedOffset, range
Constructor and Description |
---|
ReadChangeStreamPartitionRangeTracker(PartitionMetadata partition,
OffsetRange range)
Receives the partition that will be queried and be using this tracker, alongside the range
itself.
|
Modifier and Type | Method and Description |
---|---|
boolean |
tryClaim(java.lang.Long i)
Attempts to claim the given offset.
|
SplitResult<OffsetRange> |
trySplit(double fractionOfRemainder)
If the partition token is the
InitialPartition.PARTITION_TOKEN , it does not allow for
splits (returns null). |
checkDone, currentRestriction, getProgress, isBounded, toString
public ReadChangeStreamPartitionRangeTracker(PartitionMetadata partition, OffsetRange range)
partition
- the partition that will use the trackerrange
- closed / open range interval representing the start / end times for a partitionpublic boolean tryClaim(java.lang.Long i)
Must be equal or larger than the last successfully claimed offset.
tryClaim
in class OffsetRangeTracker
true
if the offset was successfully claimed, false
if it is outside the
current OffsetRange
of this tracker (in that case this operation is a no-op).public SplitResult<OffsetRange> trySplit(double fractionOfRemainder)
InitialPartition.PARTITION_TOKEN
, it does not allow for
splits (returns null).trySplit
in class OffsetRangeTracker
fractionOfRemainder
- A hint as to the fraction of work the primary restriction should
represent based upon the current known remaining amount of work.SplitResult
if a split was possible, otherwise returns null
. If the
fractionOfRemainder == 0
, a null
result MUST imply that the restriction
tracker is done and there is no more work left to do.