public class OffsetRangeTracker extends RestrictionTracker<OffsetRange,java.lang.Long> implements Sizes.HasSize
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:
after this method returns, the tracker MUST refuse all future claim calls, and RestrictionTracker.checkDone() MUST succeed. |
OffsetRange |
currentRestriction()
Returns a restriction accurately describing the full range of work the current
DoFn.ProcessElement call will do, including already completed work. |
double |
getSize()
A representation for the amount of known work represented as a size.
|
java.lang.String |
toString() |
boolean |
tryClaim(java.lang.Long i)
Attempts to claim the given offset.
|
public OffsetRangeTracker(OffsetRange range)
public OffsetRange currentRestriction()
RestrictionTracker
DoFn.ProcessElement
call will do, including already completed work.currentRestriction
in class RestrictionTracker<OffsetRange,java.lang.Long>
public OffsetRange checkpoint()
RestrictionTracker
DoFn.ProcessElement
call should terminate as soon as possible:
after this method returns, the tracker MUST refuse all future claim calls, and RestrictionTracker.checkDone()
MUST succeed.
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 class RestrictionTracker<OffsetRange,java.lang.Long>
public boolean tryClaim(java.lang.Long i)
Must be larger than the last successfully claimed offset.
tryClaim
in class RestrictionTracker<OffsetRange,java.lang.Long>
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 checkDone() throws java.lang.IllegalStateException
RestrictionTracker
DoFn.ProcessElement
returns.
Must throw an exception with an informative error message, if there is still any unclaimed work remaining in the restriction.
checkDone
in class RestrictionTracker<OffsetRange,java.lang.Long>
java.lang.IllegalStateException
public java.lang.String toString()
toString
in class java.lang.Object
public double getSize()
Sizes.HasSize
double
representations should preferably represent a linear space and be comparable within the same
partition.
It is up to each restriction tracker to convert between their natural representation of outstanding work and this representation. For example:
message bytes
that have not been processed.
DoFn
s should provide a method annotated with DoFn.GetPartition
to report a
partition identifier if the element and restriction represent the size for a shared resource
such as a message queue topic. See DoFn.GetPartition
for additional details.
getSize
in interface Sizes.HasSize