@Override public long getCurrentProcessingTime() { return internalTimerService.currentProcessingTime(); } };
private boolean isLate(long timestamp) { long currentWatermark = internalTimerService.currentWatermark(); return currentWatermark != Long.MIN_VALUE && timestamp < currentWatermark; }
@Override public void registerProcessingTimeTimer(long time) { internalTimerService.registerProcessingTimeTimer(VoidNamespace.INSTANCE, time); }
/** * Registers a timer for {@code current watermark + 1}, this means that we get triggered * whenever the watermark advances, which is what we want for working off the queue of * buffered elements. */ private void saveRegisterWatermarkTimer() { long currentWatermark = timerService.currentWatermark(); // protect against overflow if (currentWatermark + 1 > currentWatermark) { timerService.registerEventTimeTimer(VoidNamespace.INSTANCE, currentWatermark + 1); } }
updateNFA(nfaState); } else { long currentTime = timerService.currentProcessingTime(); bufferEvent(element.getValue(), currentTime); timerService.registerProcessingTimeTimer(VoidNamespace.INSTANCE, currentTime + 1);
new DropwizardMeterWrapper(new com.codahale.metrics.Meter())); this.watermarkLatency = metrics.gauge(WATERMARK_LATENCY_METRIC_NAME, () -> { long watermark = internalTimerService.currentWatermark(); if (watermark < 0) { return 0L; } else { return internalTimerService.currentProcessingTime() - watermark;
@Override public void processElement(StreamRecord<Tuple2<Integer, String>> element) throws Exception { String[] command = element.getValue().f1.split(":"); switch (command[0]) { case "SET_STATE": getPartitionedState(stateDescriptor).update(command[1]); break; case "DELETE_STATE": getPartitionedState(stateDescriptor).clear(); break; case "SET_EVENT_TIME_TIMER": timerService.registerEventTimeTimer(VoidNamespace.INSTANCE, Long.parseLong(command[1])); break; case "SET_PROC_TIME_TIMER": timerService.registerProcessingTimeTimer(VoidNamespace.INSTANCE, Long.parseLong(command[1])); break; case "EMIT_STATE": String stateValue = getPartitionedState(stateDescriptor).value(); output.collect(new StreamRecord<>("ON_ELEMENT:" + element.getValue().f0 + ":" + stateValue)); break; default: throw new IllegalArgumentException(); } }
@Override public void registerEventTimeTimer(long time) { internalTimerService.registerEventTimeTimer(VoidNamespace.INSTANCE, time); }
@Override public void deleteEventTimeTimer(long time) { internalTimerService.deleteEventTimeTimer(VoidNamespace.INSTANCE, time); } }
@Override public void deleteProcessingTimeTimer(long time) { internalTimerService.deleteProcessingTimeTimer(VoidNamespace.INSTANCE, time); }
@Override public void processElement(StreamRecord<WindowedValue<ValueWithRecordId<T>>> streamRecord) throws Exception { ValueState<Long> dedupingState = getPartitionedState(dedupingStateDescriptor); Long lastSeenTimestamp = dedupingState.value(); if (lastSeenTimestamp == null) { // we have never seen this, emit WindowedValue<ValueWithRecordId<T>> value = streamRecord.getValue(); output.collect(streamRecord.replace(value.withValue(value.getValue().getValue()))); } long currentProcessingTime = timerService.currentProcessingTime(); dedupingState.update(currentProcessingTime); timerService.registerProcessingTimeTimer( VoidNamespace.INSTANCE, currentProcessingTime + MAX_RETENTION_SINCE_ACCESS); }
/** * Registers a timer for {@code current watermark + 1}, this means that we get triggered * whenever the watermark advances, which is what we want for working off the queue of * buffered elements. */ private void saveRegisterWatermarkTimer() { long currentWatermark = timerService.currentWatermark(); // protect against overflow if (currentWatermark + 1 > currentWatermark) { timerService.registerEventTimeTimer(VoidNamespace.INSTANCE, currentWatermark + 1); } }
public void reregisterStateFromLegacyWindowOperator() { // if we restore from an older version, // we have to re-register the recovered state. if (restoredFromLegacyEventTimeTimers != null && !restoredFromLegacyEventTimeTimers.isEmpty()) { LOG.info("{} (taskIdx={}) re-registering event-time timers from an older Flink version.", getClass().getSimpleName(), getRuntimeContext().getIndexOfThisSubtask()); for (Timer<K, W> timer : restoredFromLegacyEventTimeTimers) { setCurrentKey(timer.key); internalTimerService.registerEventTimeTimer(timer.window, timer.timestamp); } } if (restoredFromLegacyProcessingTimeTimers != null && !restoredFromLegacyProcessingTimeTimers.isEmpty()) { LOG.info("{} (taskIdx={}) re-registering processing-time timers from an older Flink version.", getClass().getSimpleName(), getRuntimeContext().getIndexOfThisSubtask()); for (Timer<K, W> timer : restoredFromLegacyProcessingTimeTimers) { setCurrentKey(timer.key); internalTimerService.registerProcessingTimeTimer(timer.window, timer.timestamp); } } // gc friendliness restoredFromLegacyEventTimeTimers = null; restoredFromLegacyProcessingTimeTimers = null; }
@Override public void registerEventTimeTimer(long time) { timerService.registerEventTimeTimer(window, time); }
@Override public void deleteEventTimeTimer(long time) { timerService.deleteEventTimeTimer(window, time); }
@Override public void deleteProcessingTimeTimer(long time) { timerService.deleteProcessingTimeTimer(window, time); }
@Override public long currentWatermark() { return internalTimerService.currentWatermark(); }
@Override public void processElement(StreamRecord<WindowedValue<ValueWithRecordId<T>>> streamRecord) throws Exception { ValueState<Long> dedupingState = getPartitionedState(dedupingStateDescriptor); Long lastSeenTimestamp = dedupingState.value(); if (lastSeenTimestamp == null) { // we have never seen this, emit WindowedValue<ValueWithRecordId<T>> value = streamRecord.getValue(); output.collect(streamRecord.replace(value.withValue(value.getValue().getValue()))); } long currentProcessingTime = timerService.currentProcessingTime(); dedupingState.update(currentProcessingTime); timerService.registerProcessingTimeTimer( VoidNamespace.INSTANCE, currentProcessingTime + MAX_RETENTION_SINCE_ACCESS); }
/** * Registers a timer for {@code current watermark + 1}, this means that we get triggered * whenever the watermark advances, which is what we want for working off the queue of * buffered elements. */ private void saveRegisterWatermarkTimer() { long currentWatermark = timerService.currentWatermark(); // protect against overflow if (currentWatermark + 1 > currentWatermark) { timerService.registerEventTimeTimer(VoidNamespace.INSTANCE, currentWatermark + 1); } }
@Override public long currentProcessingTime() { return internalTimerService.currentProcessingTime(); }