public class SparkTimerInternals
extends java.lang.Object
implements org.apache.beam.runners.core.TimerInternals
TimerInternals
for the SparkRunner.Modifier and Type | Method and Description |
---|---|
void |
advanceWatermark()
Advances the watermark.
|
Instant |
currentInputWatermarkTime()
Return the current, local input watermark timestamp for this computation
in the
TimeDomain.EVENT_TIME time domain. |
Instant |
currentOutputWatermarkTime()
Return the current, local output watermark timestamp for this computation
in the
TimeDomain.EVENT_TIME time domain. |
Instant |
currentProcessingTime()
Returns the current timestamp in the
TimeDomain.PROCESSING_TIME time domain. |
Instant |
currentSynchronizedProcessingTime()
Returns the current timestamp in the
TimeDomain.SYNCHRONIZED_PROCESSING_TIME time
domain or null if unknown. |
void |
deleteTimer(org.apache.beam.runners.core.StateNamespace namespace,
java.lang.String timerId) |
void |
deleteTimer(org.apache.beam.runners.core.StateNamespace namespace,
java.lang.String timerId,
TimeDomain timeDomain)
Deletes the given timer.
|
void |
deleteTimer(org.apache.beam.runners.core.TimerInternals.TimerData timer) |
static java.lang.Iterable<org.apache.beam.runners.core.TimerInternals.TimerData> |
deserializeTimers(java.util.Collection<byte[]> serTimers,
org.apache.beam.runners.core.TimerInternals.TimerDataCoder timerDataCoder) |
static SparkTimerInternals |
forStreamFromSources(java.util.List<java.lang.Integer> sourceIds,
org.apache.spark.broadcast.Broadcast<java.util.Map<java.lang.Integer,GlobalWatermarkHolder.SparkWatermarks>> broadcast)
Build the
TimerInternals according to the feeding streams. |
static SparkTimerInternals |
global(org.apache.spark.broadcast.Broadcast<java.util.Map<java.lang.Integer,GlobalWatermarkHolder.SparkWatermarks>> broadcast)
Build a global
TimerInternals for all feeding streams. |
static java.util.Collection<byte[]> |
serializeTimers(java.util.Collection<org.apache.beam.runners.core.TimerInternals.TimerData> timers,
org.apache.beam.runners.core.TimerInternals.TimerDataCoder timerDataCoder) |
void |
setTimer(org.apache.beam.runners.core.StateNamespace namespace,
java.lang.String timerId,
Instant target,
TimeDomain timeDomain)
Sets a timer to be fired when the current time in the specified time domain reaches the
target timestamp.
|
void |
setTimer(org.apache.beam.runners.core.TimerInternals.TimerData timer) |
public static SparkTimerInternals forStreamFromSources(java.util.List<java.lang.Integer> sourceIds, @Nullable org.apache.spark.broadcast.Broadcast<java.util.Map<java.lang.Integer,GlobalWatermarkHolder.SparkWatermarks>> broadcast)
TimerInternals
according to the feeding streams.public static SparkTimerInternals global(@Nullable org.apache.spark.broadcast.Broadcast<java.util.Map<java.lang.Integer,GlobalWatermarkHolder.SparkWatermarks>> broadcast)
TimerInternals
for all feeding streams.public void setTimer(org.apache.beam.runners.core.TimerInternals.TimerData timer)
setTimer
in interface org.apache.beam.runners.core.TimerInternals
public void deleteTimer(org.apache.beam.runners.core.StateNamespace namespace, java.lang.String timerId, TimeDomain timeDomain)
org.apache.beam.runners.core.TimerInternals
A timer's ID is enforced to be unique in validation of a DoFn
, but runners
often manage timers for different time domains in very different ways, thus the
TimeDomain
is a required parameter.
deleteTimer
in interface org.apache.beam.runners.core.TimerInternals
public void deleteTimer(org.apache.beam.runners.core.TimerInternals.TimerData timer)
deleteTimer
in interface org.apache.beam.runners.core.TimerInternals
public Instant currentProcessingTime()
org.apache.beam.runners.core.TimerInternals
TimeDomain.PROCESSING_TIME
time domain.currentProcessingTime
in interface org.apache.beam.runners.core.TimerInternals
@Nullable public Instant currentSynchronizedProcessingTime()
org.apache.beam.runners.core.TimerInternals
TimeDomain.SYNCHRONIZED_PROCESSING_TIME
time
domain or null
if unknown.currentSynchronizedProcessingTime
in interface org.apache.beam.runners.core.TimerInternals
public Instant currentInputWatermarkTime()
org.apache.beam.runners.core.TimerInternals
TimeDomain.EVENT_TIME
time domain.
This value:
BoundedWindow.TIMESTAMP_MIN_VALUE
.
Note that because the local input watermark can be behind the global input watermark, it is possible for an element to be considered locally on-time even though it is globally late.
currentInputWatermarkTime
in interface org.apache.beam.runners.core.TimerInternals
public void advanceWatermark()
@Nullable public Instant currentOutputWatermarkTime()
org.apache.beam.runners.core.TimerInternals
TimeDomain.EVENT_TIME
time domain. Return null
if unknown.
This value:
TimerInternals.currentInputWatermarkTime()
as returned above.
In pictures:
| | | | |
| | D | C | B | A
| | | | |
GIWM <= GOWM <= LOWM <= LIWM <= GIWM
(next stage)
-------------------------------------------------> event time
where
Note that if a computation emits an element which is not before the current output watermark then that element will always appear locally on-time in all following computations. However, it is possible for an element emitted before the current output watermark to appear locally on-time in a following computation. Thus we must be careful to never assume locally late data viewed on the output of a computation remains locally late on the input of a following computation.
currentOutputWatermarkTime
in interface org.apache.beam.runners.core.TimerInternals
public void setTimer(org.apache.beam.runners.core.StateNamespace namespace, java.lang.String timerId, Instant target, TimeDomain timeDomain)
org.apache.beam.runners.core.TimerInternals
The combination of namespace
and timerId
uniquely identify a timer.
If a timer is set and then set again before it fires, later settings should clear the prior setting.
It is an error to set a timer for two different time domains.
setTimer
in interface org.apache.beam.runners.core.TimerInternals
public void deleteTimer(org.apache.beam.runners.core.StateNamespace namespace, java.lang.String timerId)
deleteTimer
in interface org.apache.beam.runners.core.TimerInternals
public static java.util.Collection<byte[]> serializeTimers(java.util.Collection<org.apache.beam.runners.core.TimerInternals.TimerData> timers, org.apache.beam.runners.core.TimerInternals.TimerDataCoder timerDataCoder)
public static java.lang.Iterable<org.apache.beam.runners.core.TimerInternals.TimerData> deserializeTimers(java.util.Collection<byte[]> serTimers, org.apache.beam.runners.core.TimerInternals.TimerDataCoder timerDataCoder)