Java Code Examples for org.apache.flink.streaming.api.operators.InternalTimer#getNamespace()
The following examples show how to use
org.apache.flink.streaming.api.operators.InternalTimer#getNamespace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WindowOperator.java From flink with Apache License 2.0 | 6 votes |
@Override public void onProcessingTime(InternalTimer<K, W> timer) throws Exception { if (functionsClosed) { return; } setCurrentKey(timer.getKey()); triggerContext.window = timer.getNamespace(); if (triggerContext.onProcessingTime(timer.getTimestamp())) { // fire emitWindowResult(triggerContext.window); } if (!windowAssigner.isEventTime()) { windowFunction.cleanWindowIfNeeded(triggerContext.window, timer.getTimestamp()); } }
Example 2
Source File: WindowOperator.java From flink with Apache License 2.0 | 5 votes |
@Override public void onEventTime(InternalTimer<K, W> timer) throws Exception { setCurrentKey(timer.getKey()); triggerContext.window = timer.getNamespace(); if (triggerContext.onEventTime(timer.getTimestamp())) { // fire emitWindowResult(triggerContext.window); } if (windowAssigner.isEventTime()) { windowFunction.cleanWindowIfNeeded(triggerContext.window, timer.getTimestamp()); } }
Example 3
Source File: WindowOperator.java From flink with Apache License 2.0 | 5 votes |
@Override public void onProcessingTime(InternalTimer<K, W> timer) throws Exception { setCurrentKey(timer.getKey()); triggerContext.window = timer.getNamespace(); if (triggerContext.onProcessingTime(timer.getTimestamp())) { // fire emitWindowResult(triggerContext.window); } if (!windowAssigner.isEventTime()) { windowFunction.cleanWindowIfNeeded(triggerContext.window, timer.getTimestamp()); } }
Example 4
Source File: WindowOperator.java From flink with Apache License 2.0 | 5 votes |
@Override public void onEventTime(InternalTimer<K, W> timer) throws Exception { setCurrentKey(timer.getKey()); triggerContext.window = timer.getNamespace(); if (triggerContext.onEventTime(timer.getTimestamp())) { // fire emitWindowResult(triggerContext.window); } if (windowAssigner.isEventTime()) { windowFunction.cleanWindowIfNeeded(triggerContext.window, timer.getTimestamp()); } }
Example 5
Source File: DoFnOperator.java From beam with Apache License 2.0 | 5 votes |
/** * Processes all pending processing timers. This is intended for use during shutdown. From Flink * 1.10 on, processing timer execution is stopped when the operator is closed. This leads to * problems for applications which assume all pending timers will be completed. Although Flink * does drain the remaining timers after close(), this is not sufficient because no new timers * are allowed to be scheduled anymore. This breaks Beam pipelines which rely on all processing * timers to be scheduled and executed. */ void processPendingProcessingTimeTimers() { final KeyedStateBackend<Object> keyedStateBackend = getKeyedStateBackend(); final InternalPriorityQueue<InternalTimer<Object, TimerData>> processingTimeTimersQueue = Workarounds.retrieveInternalProcessingTimerQueue(timerService); InternalTimer<Object, TimerData> internalTimer; while ((internalTimer = processingTimeTimersQueue.poll()) != null) { keyedStateBackend.setCurrentKey(internalTimer.getKey()); TimerData timer = internalTimer.getNamespace(); checkInvokeStartBundle(); fireTimer(timer); } }
Example 6
Source File: WindowOperator.java From flink with Apache License 2.0 | 4 votes |
@Override public void onEventTime(InternalTimer<K, W> timer) throws Exception { triggerContext.key = timer.getKey(); triggerContext.window = timer.getNamespace(); MergingWindowSet<W> mergingWindows; if (windowAssigner instanceof MergingWindowAssigner) { mergingWindows = getMergingWindowSet(); W stateWindow = mergingWindows.getStateWindow(triggerContext.window); if (stateWindow == null) { // Timer firing for non-existent window, this can only happen if a // trigger did not clean up timers. We have already cleared the merging // window and therefore the Trigger state, however, so nothing to do. return; } else { windowState.setCurrentNamespace(stateWindow); } } else { windowState.setCurrentNamespace(triggerContext.window); mergingWindows = null; } TriggerResult triggerResult = triggerContext.onEventTime(timer.getTimestamp()); if (triggerResult.isFire()) { ACC contents = windowState.get(); if (contents != null) { emitWindowContents(triggerContext.window, contents); } } if (triggerResult.isPurge()) { windowState.clear(); } if (windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) { clearAllState(triggerContext.window, windowState, mergingWindows); } if (mergingWindows != null) { // need to make sure to update the merging state in state mergingWindows.persist(); } }
Example 7
Source File: WindowOperator.java From flink with Apache License 2.0 | 4 votes |
@Override public void onProcessingTime(InternalTimer<K, W> timer) throws Exception { triggerContext.key = timer.getKey(); triggerContext.window = timer.getNamespace(); MergingWindowSet<W> mergingWindows; if (windowAssigner instanceof MergingWindowAssigner) { mergingWindows = getMergingWindowSet(); W stateWindow = mergingWindows.getStateWindow(triggerContext.window); if (stateWindow == null) { // Timer firing for non-existent window, this can only happen if a // trigger did not clean up timers. We have already cleared the merging // window and therefore the Trigger state, however, so nothing to do. return; } else { windowState.setCurrentNamespace(stateWindow); } } else { windowState.setCurrentNamespace(triggerContext.window); mergingWindows = null; } TriggerResult triggerResult = triggerContext.onProcessingTime(timer.getTimestamp()); if (triggerResult.isFire()) { ACC contents = windowState.get(); if (contents != null) { emitWindowContents(triggerContext.window, contents); } } if (triggerResult.isPurge()) { windowState.clear(); } if (!windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) { clearAllState(triggerContext.window, windowState, mergingWindows); } if (mergingWindows != null) { // need to make sure to update the merging state in state mergingWindows.persist(); } }
Example 8
Source File: WindowOperator.java From flink with Apache License 2.0 | 4 votes |
@Override public void onEventTime(InternalTimer<K, W> timer) throws Exception { triggerContext.key = timer.getKey(); triggerContext.window = timer.getNamespace(); MergingWindowSet<W> mergingWindows; if (windowAssigner instanceof MergingWindowAssigner) { mergingWindows = getMergingWindowSet(); W stateWindow = mergingWindows.getStateWindow(triggerContext.window); if (stateWindow == null) { // Timer firing for non-existent window, this can only happen if a // trigger did not clean up timers. We have already cleared the merging // window and therefore the Trigger state, however, so nothing to do. return; } else { windowState.setCurrentNamespace(stateWindow); } } else { windowState.setCurrentNamespace(triggerContext.window); mergingWindows = null; } TriggerResult triggerResult = triggerContext.onEventTime(timer.getTimestamp()); if (triggerResult.isFire()) { ACC contents = windowState.get(); if (contents != null) { emitWindowContents(triggerContext.window, contents); } } if (triggerResult.isPurge()) { windowState.clear(); } if (windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) { clearAllState(triggerContext.window, windowState, mergingWindows); } if (mergingWindows != null) { // need to make sure to update the merging state in state mergingWindows.persist(); } }
Example 9
Source File: EvictingWindowOperator.java From flink with Apache License 2.0 | 4 votes |
@Override public void onProcessingTime(InternalTimer<K, W> timer) throws Exception { triggerContext.key = timer.getKey(); triggerContext.window = timer.getNamespace(); evictorContext.key = timer.getKey(); evictorContext.window = timer.getNamespace(); MergingWindowSet<W> mergingWindows = null; if (windowAssigner instanceof MergingWindowAssigner) { mergingWindows = getMergingWindowSet(); W stateWindow = mergingWindows.getStateWindow(triggerContext.window); if (stateWindow == null) { // Timer firing for non-existent window, this can only happen if a // trigger did not clean up timers. We have already cleared the merging // window and therefore the Trigger state, however, so nothing to do. return; } else { evictingWindowState.setCurrentNamespace(stateWindow); } } else { evictingWindowState.setCurrentNamespace(triggerContext.window); } TriggerResult triggerResult = triggerContext.onProcessingTime(timer.getTimestamp()); if (triggerResult.isFire()) { Iterable<StreamRecord<IN>> contents = evictingWindowState.get(); if (contents != null) { emitWindowContents(triggerContext.window, contents, evictingWindowState); } } if (triggerResult.isPurge()) { evictingWindowState.clear(); } if (!windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) { clearAllState(triggerContext.window, evictingWindowState, mergingWindows); } if (mergingWindows != null) { // need to make sure to update the merging state in state mergingWindows.persist(); } }
Example 10
Source File: EvictingWindowOperator.java From flink with Apache License 2.0 | 4 votes |
@Override public void onEventTime(InternalTimer<K, W> timer) throws Exception { triggerContext.key = timer.getKey(); triggerContext.window = timer.getNamespace(); evictorContext.key = timer.getKey(); evictorContext.window = timer.getNamespace(); MergingWindowSet<W> mergingWindows = null; if (windowAssigner instanceof MergingWindowAssigner) { mergingWindows = getMergingWindowSet(); W stateWindow = mergingWindows.getStateWindow(triggerContext.window); if (stateWindow == null) { // Timer firing for non-existent window, this can only happen if a // trigger did not clean up timers. We have already cleared the merging // window and therefore the Trigger state, however, so nothing to do. return; } else { evictingWindowState.setCurrentNamespace(stateWindow); } } else { evictingWindowState.setCurrentNamespace(triggerContext.window); } TriggerResult triggerResult = triggerContext.onEventTime(timer.getTimestamp()); if (triggerResult.isFire()) { Iterable<StreamRecord<IN>> contents = evictingWindowState.get(); if (contents != null) { emitWindowContents(triggerContext.window, contents, evictingWindowState); } } if (triggerResult.isPurge()) { evictingWindowState.clear(); } if (windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) { clearAllState(triggerContext.window, evictingWindowState, mergingWindows); } if (mergingWindows != null) { // need to make sure to update the merging state in state mergingWindows.persist(); } }
Example 11
Source File: WindowOperator.java From flink with Apache License 2.0 | 4 votes |
@Override public void onProcessingTime(InternalTimer<K, W> timer) throws Exception { triggerContext.key = timer.getKey(); triggerContext.window = timer.getNamespace(); MergingWindowSet<W> mergingWindows; if (windowAssigner instanceof MergingWindowAssigner) { mergingWindows = getMergingWindowSet(); W stateWindow = mergingWindows.getStateWindow(triggerContext.window); if (stateWindow == null) { // Timer firing for non-existent window, this can only happen if a // trigger did not clean up timers. We have already cleared the merging // window and therefore the Trigger state, however, so nothing to do. return; } else { windowState.setCurrentNamespace(stateWindow); } } else { windowState.setCurrentNamespace(triggerContext.window); mergingWindows = null; } TriggerResult triggerResult = triggerContext.onProcessingTime(timer.getTimestamp()); if (triggerResult.isFire()) { ACC contents = windowState.get(); if (contents != null) { emitWindowContents(triggerContext.window, contents); } } if (triggerResult.isPurge()) { windowState.clear(); } if (!windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) { clearAllState(triggerContext.window, windowState, mergingWindows); } if (mergingWindows != null) { // need to make sure to update the merging state in state mergingWindows.persist(); } }
Example 12
Source File: EvictingWindowOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public void onEventTime(InternalTimer<K, W> timer) throws Exception { triggerContext.key = timer.getKey(); triggerContext.window = timer.getNamespace(); evictorContext.key = timer.getKey(); evictorContext.window = timer.getNamespace(); MergingWindowSet<W> mergingWindows = null; if (windowAssigner instanceof MergingWindowAssigner) { mergingWindows = getMergingWindowSet(); W stateWindow = mergingWindows.getStateWindow(triggerContext.window); if (stateWindow == null) { // Timer firing for non-existent window, this can only happen if a // trigger did not clean up timers. We have already cleared the merging // window and therefore the Trigger state, however, so nothing to do. return; } else { evictingWindowState.setCurrentNamespace(stateWindow); } } else { evictingWindowState.setCurrentNamespace(triggerContext.window); } TriggerResult triggerResult = triggerContext.onEventTime(timer.getTimestamp()); if (triggerResult.isFire()) { Iterable<StreamRecord<IN>> contents = evictingWindowState.get(); if (contents != null) { emitWindowContents(triggerContext.window, contents, evictingWindowState); } } if (triggerResult.isPurge()) { evictingWindowState.clear(); } if (windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) { clearAllState(triggerContext.window, evictingWindowState, mergingWindows); } if (mergingWindows != null) { // need to make sure to update the merging state in state mergingWindows.persist(); } }
Example 13
Source File: EvictingWindowOperator.java From flink with Apache License 2.0 | 4 votes |
@Override public void onProcessingTime(InternalTimer<K, W> timer) throws Exception { triggerContext.key = timer.getKey(); triggerContext.window = timer.getNamespace(); evictorContext.key = timer.getKey(); evictorContext.window = timer.getNamespace(); MergingWindowSet<W> mergingWindows = null; if (windowAssigner instanceof MergingWindowAssigner) { mergingWindows = getMergingWindowSet(); W stateWindow = mergingWindows.getStateWindow(triggerContext.window); if (stateWindow == null) { // Timer firing for non-existent window, this can only happen if a // trigger did not clean up timers. We have already cleared the merging // window and therefore the Trigger state, however, so nothing to do. return; } else { evictingWindowState.setCurrentNamespace(stateWindow); } } else { evictingWindowState.setCurrentNamespace(triggerContext.window); } TriggerResult triggerResult = triggerContext.onProcessingTime(timer.getTimestamp()); if (triggerResult.isFire()) { Iterable<StreamRecord<IN>> contents = evictingWindowState.get(); if (contents != null) { emitWindowContents(triggerContext.window, contents, evictingWindowState); } } if (triggerResult.isPurge()) { evictingWindowState.clear(); } if (!windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) { clearAllState(triggerContext.window, evictingWindowState, mergingWindows); } if (mergingWindows != null) { // need to make sure to update the merging state in state mergingWindows.persist(); } }
Example 14
Source File: EvictingWindowOperator.java From flink with Apache License 2.0 | 4 votes |
@Override public void onEventTime(InternalTimer<K, W> timer) throws Exception { triggerContext.key = timer.getKey(); triggerContext.window = timer.getNamespace(); evictorContext.key = timer.getKey(); evictorContext.window = timer.getNamespace(); MergingWindowSet<W> mergingWindows = null; if (windowAssigner instanceof MergingWindowAssigner) { mergingWindows = getMergingWindowSet(); W stateWindow = mergingWindows.getStateWindow(triggerContext.window); if (stateWindow == null) { // Timer firing for non-existent window, this can only happen if a // trigger did not clean up timers. We have already cleared the merging // window and therefore the Trigger state, however, so nothing to do. return; } else { evictingWindowState.setCurrentNamespace(stateWindow); } } else { evictingWindowState.setCurrentNamespace(triggerContext.window); } TriggerResult triggerResult = triggerContext.onEventTime(timer.getTimestamp()); if (triggerResult.isFire()) { Iterable<StreamRecord<IN>> contents = evictingWindowState.get(); if (contents != null) { emitWindowContents(triggerContext.window, contents, evictingWindowState); } } if (triggerResult.isPurge()) { evictingWindowState.clear(); } if (windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) { clearAllState(triggerContext.window, evictingWindowState, mergingWindows); } if (mergingWindows != null) { // need to make sure to update the merging state in state mergingWindows.persist(); } }
Example 15
Source File: WindowOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public void onProcessingTime(InternalTimer<K, W> timer) throws Exception { triggerContext.key = timer.getKey(); triggerContext.window = timer.getNamespace(); MergingWindowSet<W> mergingWindows; if (windowAssigner instanceof MergingWindowAssigner) { mergingWindows = getMergingWindowSet(); W stateWindow = mergingWindows.getStateWindow(triggerContext.window); if (stateWindow == null) { // Timer firing for non-existent window, this can only happen if a // trigger did not clean up timers. We have already cleared the merging // window and therefore the Trigger state, however, so nothing to do. return; } else { windowState.setCurrentNamespace(stateWindow); } } else { windowState.setCurrentNamespace(triggerContext.window); mergingWindows = null; } TriggerResult triggerResult = triggerContext.onProcessingTime(timer.getTimestamp()); if (triggerResult.isFire()) { ACC contents = windowState.get(); if (contents != null) { emitWindowContents(triggerContext.window, contents); } } if (triggerResult.isPurge()) { windowState.clear(); } if (!windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) { clearAllState(triggerContext.window, windowState, mergingWindows); } if (mergingWindows != null) { // need to make sure to update the merging state in state mergingWindows.persist(); } }
Example 16
Source File: WindowOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public void onEventTime(InternalTimer<K, W> timer) throws Exception { triggerContext.key = timer.getKey(); triggerContext.window = timer.getNamespace(); MergingWindowSet<W> mergingWindows; if (windowAssigner instanceof MergingWindowAssigner) { mergingWindows = getMergingWindowSet(); W stateWindow = mergingWindows.getStateWindow(triggerContext.window); if (stateWindow == null) { // Timer firing for non-existent window, this can only happen if a // trigger did not clean up timers. We have already cleared the merging // window and therefore the Trigger state, however, so nothing to do. return; } else { windowState.setCurrentNamespace(stateWindow); } } else { windowState.setCurrentNamespace(triggerContext.window); mergingWindows = null; } TriggerResult triggerResult = triggerContext.onEventTime(timer.getTimestamp()); if (triggerResult.isFire()) { ACC contents = windowState.get(); if (contents != null) { emitWindowContents(triggerContext.window, contents); } } if (triggerResult.isPurge()) { windowState.clear(); } if (windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) { clearAllState(triggerContext.window, windowState, mergingWindows); } if (mergingWindows != null) { // need to make sure to update the merging state in state mergingWindows.persist(); } }
Example 17
Source File: EvictingWindowOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public void onProcessingTime(InternalTimer<K, W> timer) throws Exception { triggerContext.key = timer.getKey(); triggerContext.window = timer.getNamespace(); evictorContext.key = timer.getKey(); evictorContext.window = timer.getNamespace(); MergingWindowSet<W> mergingWindows = null; if (windowAssigner instanceof MergingWindowAssigner) { mergingWindows = getMergingWindowSet(); W stateWindow = mergingWindows.getStateWindow(triggerContext.window); if (stateWindow == null) { // Timer firing for non-existent window, this can only happen if a // trigger did not clean up timers. We have already cleared the merging // window and therefore the Trigger state, however, so nothing to do. return; } else { evictingWindowState.setCurrentNamespace(stateWindow); } } else { evictingWindowState.setCurrentNamespace(triggerContext.window); } TriggerResult triggerResult = triggerContext.onProcessingTime(timer.getTimestamp()); if (triggerResult.isFire()) { Iterable<StreamRecord<IN>> contents = evictingWindowState.get(); if (contents != null) { emitWindowContents(triggerContext.window, contents, evictingWindowState); } } if (triggerResult.isPurge()) { evictingWindowState.clear(); } if (!windowAssigner.isEventTime() && isCleanupTime(triggerContext.window, timer.getTimestamp())) { clearAllState(triggerContext.window, evictingWindowState, mergingWindows); } if (mergingWindows != null) { // need to make sure to update the merging state in state mergingWindows.persist(); } }