public void fireTimer(InternalTimer<?, TimerData> timer) { TimerInternals.TimerData timerData = timer.getNamespace(); StateNamespace namespace = timerData.getNamespace(); // This is a user timer, so namespace must be WindowNamespace checkArgument(namespace instanceof WindowNamespace); BoundedWindow window = ((WindowNamespace) namespace).getWindow(); pushbackDoFnRunner.onTimer(timerData.getTimerId(), window, timerData.getTimestamp(), timerData.getDomain()); }
public void fireTimer(InternalTimer<?, TimerData> timer) { TimerInternals.TimerData timerData = timer.getNamespace(); StateNamespace namespace = timerData.getNamespace(); // This is a user timer, so namespace must be WindowNamespace checkArgument(namespace instanceof WindowNamespace); BoundedWindow window = ((WindowNamespace) namespace).getWindow(); timerInternals.cleanupPendingTimer(timerData); pushbackDoFnRunner.onTimer( timerData.getTimerId(), window, timerData.getTimestamp(), timerData.getDomain()); }
public void fireTimer(InternalTimer<?, TimerData> timer) { TimerInternals.TimerData timerData = timer.getNamespace(); StateNamespace namespace = timerData.getNamespace(); // This is a user timer, so namespace must be WindowNamespace checkArgument(namespace instanceof WindowNamespace); BoundedWindow window = ((WindowNamespace) namespace).getWindow(); timerInternals.cleanupPendingTimer(timer.getNamespace()); pushbackDoFnRunner.onTimer( timerData.getTimerId(), window, timerData.getTimestamp(), timerData.getDomain()); }
@Override public void fireTimer(Object key, Collection<TimerData> timerDataSet) { pushbackDoFnRunner.startBundle(); @SuppressWarnings("unchecked") Coder<Object> keyCoder = (Coder) currentKeyStateInternals.getKeyCoder(); ((StateInternalsProxy) currentKeyStateInternals).setKey(key); currentKeyTimerInternals.setContext( key, keyCoder, new Instant(this.currentInputWatermark), new Instant(this.currentOutputWatermark)); for (TimerData timerData : timerDataSet) { StateNamespace namespace = timerData.getNamespace(); checkArgument(namespace instanceof WindowNamespace); BoundedWindow window = ((WindowNamespace<?>) namespace).getWindow(); pushbackDoFnRunner.onTimer( timerData.getTimerId(), window, timerData.getTimestamp(), timerData.getDomain()); } pushbackDoFnRunner.finishBundle(); }
/** Tests that a call to onTimer gets delegated. */ @Test public void testOnTimerCalled() { PushbackSideInputDoFnRunner<Integer, Integer> runner = createRunner(ImmutableList.of()); String timerId = "fooTimer"; IntervalWindow window = new IntervalWindow(new Instant(4), new Instant(16)); Instant timestamp = new Instant(72); // Mocking is not easily compatible with annotation analysis, so we manually record // the method call. runner.onTimer(timerId, window, new Instant(timestamp), TimeDomain.EVENT_TIME); assertThat( underlying.firedTimers, contains( TimerData.of( timerId, StateNamespaces.window(IntervalWindow.getCoder(), window), timestamp, TimeDomain.EVENT_TIME))); }