Class SparkTimerInternals
java.lang.Object
org.apache.beam.runners.spark.stateful.SparkTimerInternals
- All Implemented Interfaces:
org.apache.beam.runners.core.TimerInternals
public class SparkTimerInternals
extends Object
implements org.apache.beam.runners.core.TimerInternals
An implementation of
TimerInternals for the SparkRunner.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.beam.runners.core.TimerInternals
org.apache.beam.runners.core.TimerInternals.TimerData, org.apache.beam.runners.core.TimerInternals.TimerDataCoder, org.apache.beam.runners.core.TimerInternals.TimerDataCoderV2 -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidAdvances the watermark.voiddeleteTimer(org.apache.beam.runners.core.StateNamespace namespace, String timerId, String timerFamilyId) voiddeleteTimer(org.apache.beam.runners.core.StateNamespace namespace, String timerId, String timerFamilyId, TimeDomain timeDomain) voiddeleteTimer(org.apache.beam.runners.core.TimerInternals.TimerData timer) static Iterator<org.apache.beam.runners.core.TimerInternals.TimerData> deserializeTimers(Collection<byte[]> serTimers, org.apache.beam.runners.core.TimerInternals.TimerDataCoderV2 timerDataCoder) static SparkTimerInternalsforStreamFromSources(List<Integer> sourceIds, Map<Integer, GlobalWatermarkHolder.SparkWatermarks> watermarks) Build theTimerInternalsaccording to the feeding streams.@Nullable org.apache.beam.runners.core.TimerInternals.TimerDataFinds the latest timer inTimeDomain.PROCESSING_TIMEdomain that has expired based on the current processing time.Collection<org.apache.beam.runners.core.TimerInternals.TimerData> static SparkTimerInternalsglobal(Map<Integer, GlobalWatermarkHolder.SparkWatermarks> watermarks) Build a globalTimerInternalsfor all feeding streams.booleanChecks if there are any expired timers in theTimeDomain.PROCESSING_TIMEdomain.static Collection<byte[]> serializeTimers(Collection<org.apache.beam.runners.core.TimerInternals.TimerData> timers, org.apache.beam.runners.core.TimerInternals.TimerDataCoderV2 timerDataCoder) voidsetTimer(org.apache.beam.runners.core.StateNamespace namespace, String timerId, String timerFamilyId, Instant target, Instant outputTimestamp, TimeDomain timeDomain) voidsetTimer(org.apache.beam.runners.core.TimerInternals.TimerData timer) toString()
-
Method Details
-
forStreamFromSources
public static SparkTimerInternals forStreamFromSources(List<Integer> sourceIds, Map<Integer, GlobalWatermarkHolder.SparkWatermarks> watermarks) Build theTimerInternalsaccording to the feeding streams. -
global
public static SparkTimerInternals global(Map<Integer, GlobalWatermarkHolder.SparkWatermarks> watermarks) Build a globalTimerInternalsfor all feeding streams. -
getTimers
-
addTimers
-
setTimer
public void setTimer(org.apache.beam.runners.core.TimerInternals.TimerData timer) - Specified by:
setTimerin interfaceorg.apache.beam.runners.core.TimerInternals
-
deleteTimer
public void deleteTimer(org.apache.beam.runners.core.StateNamespace namespace, String timerId, String timerFamilyId, TimeDomain timeDomain) - Specified by:
deleteTimerin interfaceorg.apache.beam.runners.core.TimerInternals
-
deleteTimer
public void deleteTimer(org.apache.beam.runners.core.TimerInternals.TimerData timer) - Specified by:
deleteTimerin interfaceorg.apache.beam.runners.core.TimerInternals
-
currentProcessingTime
- Specified by:
currentProcessingTimein interfaceorg.apache.beam.runners.core.TimerInternals
-
currentSynchronizedProcessingTime
- Specified by:
currentSynchronizedProcessingTimein interfaceorg.apache.beam.runners.core.TimerInternals
-
currentInputWatermarkTime
- Specified by:
currentInputWatermarkTimein interfaceorg.apache.beam.runners.core.TimerInternals
-
advanceWatermark
public void advanceWatermark()Advances the watermark. -
currentOutputWatermarkTime
- Specified by:
currentOutputWatermarkTimein interfaceorg.apache.beam.runners.core.TimerInternals
-
setTimer
public void setTimer(org.apache.beam.runners.core.StateNamespace namespace, String timerId, String timerFamilyId, Instant target, Instant outputTimestamp, TimeDomain timeDomain) - Specified by:
setTimerin interfaceorg.apache.beam.runners.core.TimerInternals
-
deleteTimer
public void deleteTimer(org.apache.beam.runners.core.StateNamespace namespace, String timerId, String timerFamilyId) - Specified by:
deleteTimerin interfaceorg.apache.beam.runners.core.TimerInternals
-
serializeTimers
public static Collection<byte[]> serializeTimers(Collection<org.apache.beam.runners.core.TimerInternals.TimerData> timers, org.apache.beam.runners.core.TimerInternals.TimerDataCoderV2 timerDataCoder) -
deserializeTimers
public static Iterator<org.apache.beam.runners.core.TimerInternals.TimerData> deserializeTimers(Collection<byte[]> serTimers, org.apache.beam.runners.core.TimerInternals.TimerDataCoderV2 timerDataCoder) -
hasNextProcessingTimer
public boolean hasNextProcessingTimer()Checks if there are any expired timers in theTimeDomain.PROCESSING_TIMEdomain.A timer is considered expired when its timestamp is less than the current processing time.
- Returns:
trueif at least one expired processing timer exists,falseotherwise.
-
getNextProcessingTimer
Finds the latest timer inTimeDomain.PROCESSING_TIMEdomain that has expired based on the current processing time.A timer is considered expired when its timestamp is less than the current processing time. If multiple expired timers exist, the one with the latest timestamp will be returned.
- Returns:
- The expired processing timer with the latest timestamp if one exists, or
nullif no processing timers are ready to fire.
-
toString
-