public class ByteKeyRangeTracker extends RestrictionTracker<ByteKeyRange,ByteKey> implements Backlogs.HasBacklog
RestrictionTracker
for claiming ByteKey
s in a ByteKeyRange
in a
monotonically increasing fashion. The range is a semi-open bounded interval [startKey, endKey)
where the limits are both represented by ByteKey.EMPTY
.
Note, one can complete a range by claiming the ByteKey.EMPTY
once one runs out of keys
to process.
RestrictionTracker.ClaimObserver<PositionT>
Modifier and Type | Method and Description |
---|---|
void |
checkDone()
Called by the runner after
DoFn.ProcessElement returns. |
ByteKeyRange |
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. |
ByteKeyRange |
currentRestriction()
Returns a restriction accurately describing the full range of work the current
DoFn.ProcessElement call will do, including already completed work. |
Backlog |
getBacklog() |
static ByteKeyRangeTracker |
of(ByteKeyRange range) |
java.lang.String |
toString() |
protected boolean |
tryClaimImpl(ByteKey key)
Attempts to claim the given key.
|
setClaimObserver, tryClaim
public static ByteKeyRangeTracker of(ByteKeyRange range)
public ByteKeyRange currentRestriction()
RestrictionTracker
DoFn.ProcessElement
call will do, including already completed work.currentRestriction
in class RestrictionTracker<ByteKeyRange,ByteKey>
public ByteKeyRange 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. Must not be called before the first
successful RestrictionTracker.tryClaim(PositionT)
call.
checkpoint
in class RestrictionTracker<ByteKeyRange,ByteKey>
protected boolean tryClaimImpl(ByteKey key)
Must be larger than the last attempted key. Since this restriction tracker represents a
range over a semi-open bounded interval [start, end)
, the last key that was attempted
may have failed but still have consumed the interval [lastAttemptedKey, end)
since this
range tracker processes keys in a monotonically increasing order. Note that passing in ByteKey.EMPTY
claims all keys to the end of range and can only be claimed once.
tryClaimImpl
in class RestrictionTracker<ByteKeyRange,ByteKey>
true
if the key was successfully claimed, false
if it is outside the
current ByteKeyRange
of this tracker.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<ByteKeyRange,ByteKey>
java.lang.IllegalStateException
public java.lang.String toString()
toString
in class java.lang.Object
public Backlog getBacklog()
getBacklog
in interface Backlogs.HasBacklog