public class OffsetRangeTracker extends java.lang.Object implements RestrictionTracker<OffsetRange>
RestrictionTracker for claiming offsets in an OffsetRange in a monotonically
increasing fashion.| Constructor and Description |
|---|
OffsetRangeTracker(OffsetRange range) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkDone()
Called by the runner after
DoFn.ProcessElement returns. |
OffsetRange |
checkpoint()
Signals that the current
DoFn.ProcessElement call should terminate as soon as possible. |
OffsetRange |
currentRestriction()
Returns a restriction accurately describing the full range of work the current
DoFn.ProcessElement call will do, including already completed work. |
void |
markDone()
Marks that there are no more offsets to be claimed in the range.
|
boolean |
tryClaim(long i)
Attempts to claim the given offset.
|
public OffsetRangeTracker(OffsetRange range)
public OffsetRange currentRestriction()
RestrictionTrackerDoFn.ProcessElement call will do, including already completed work.currentRestriction in interface RestrictionTracker<OffsetRange>public OffsetRange checkpoint()
RestrictionTrackerDoFn.ProcessElement call should terminate as soon as possible.
Modifies RestrictionTracker.currentRestriction(). Returns a restriction representing the rest of the work:
the old value of RestrictionTracker.currentRestriction() is equivalent to the new value and the return
value of this method combined. Must be called at most once on a given object.checkpoint in interface RestrictionTracker<OffsetRange>public boolean tryClaim(long i)
Must be larger than the last successfully claimed offset.
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 void markDone()
E.g., a DoFn reading a file and claiming the offset of each record in the file might
call this if it hits EOF - even though the last attempted claim was before the end of the
range, there are no more offsets to claim.
public void checkDone()
throws java.lang.IllegalStateException
RestrictionTrackerDoFn.ProcessElement returns.
Must throw an exception with an informative error message, if there is still any unclaimed work remaining in the restriction.
checkDone in interface RestrictionTracker<OffsetRange>java.lang.IllegalStateException