org.apache.flink.streaming.api.operators.TestInternalTimerService Java Examples
The following examples show how to use
org.apache.flink.streaming.api.operators.TestInternalTimerService.
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: TriggerTestHarness.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Advanced processing time and processes any timers that fire because of this. The * window and {@link TriggerResult} for each firing are returned. */ public Collection<Tuple2<W, TriggerResult>> advanceProcessingTime(long time) throws Exception { Collection<TestInternalTimerService.Timer<Integer, W>> firedTimers = internalTimerService.advanceProcessingTime(time); Collection<Tuple2<W, TriggerResult>> result = new ArrayList<>(); for (TestInternalTimerService.Timer<Integer, W> timer : firedTimers) { TestTriggerContext<Integer, W> triggerContext = new TestTriggerContext<>( KEY, timer.getNamespace(), internalTimerService, stateBackend, windowSerializer); TriggerResult triggerResult = trigger.onProcessingTime(timer.getTimestamp(), timer.getNamespace(), triggerContext); result.add(new Tuple2<>(timer.getNamespace(), triggerResult)); } return result; }
Example #2
Source File: TriggerTestHarness.java From flink with Apache License 2.0 | 6 votes |
/** * Advanced processing time and processes any timers that fire because of this. The * window and {@link TriggerResult} for each firing are returned. */ public Collection<Tuple2<W, TriggerResult>> advanceProcessingTime(long time) throws Exception { Collection<TestInternalTimerService.Timer<Integer, W>> firedTimers = internalTimerService.advanceProcessingTime(time); Collection<Tuple2<W, TriggerResult>> result = new ArrayList<>(); for (TestInternalTimerService.Timer<Integer, W> timer : firedTimers) { TestTriggerContext<Integer, W> triggerContext = new TestTriggerContext<>( KEY, timer.getNamespace(), internalTimerService, stateBackend, windowSerializer); TriggerResult triggerResult = trigger.onProcessingTime(timer.getTimestamp(), timer.getNamespace(), triggerContext); result.add(new Tuple2<>(timer.getNamespace(), triggerResult)); } return result; }
Example #3
Source File: TriggerTestHarness.java From flink with Apache License 2.0 | 6 votes |
/** * Advanced processing time and processes any timers that fire because of this. The * window and {@link TriggerResult} for each firing are returned. */ public Collection<Tuple2<W, TriggerResult>> advanceProcessingTime(long time) throws Exception { Collection<TestInternalTimerService.Timer<Integer, W>> firedTimers = internalTimerService.advanceProcessingTime(time); Collection<Tuple2<W, TriggerResult>> result = new ArrayList<>(); for (TestInternalTimerService.Timer<Integer, W> timer : firedTimers) { TestTriggerContext<Integer, W> triggerContext = new TestTriggerContext<>( KEY, timer.getNamespace(), internalTimerService, stateBackend, windowSerializer); TriggerResult triggerResult = trigger.onProcessingTime(timer.getTimestamp(), timer.getNamespace(), triggerContext); result.add(new Tuple2<>(timer.getNamespace(), triggerResult)); } return result; }
Example #4
Source File: TriggerTestHarness.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public TriggerTestHarness( Trigger<T, W> trigger, TypeSerializer<W> windowSerializer) throws Exception { this.trigger = trigger; this.windowSerializer = windowSerializer; // we only ever use one key, other tests make sure that windows work across different // keys DummyEnvironment dummyEnv = new DummyEnvironment("test", 1, 0); MemoryStateBackend backend = new MemoryStateBackend(); @SuppressWarnings("unchecked") HeapKeyedStateBackend<Integer> stateBackend = (HeapKeyedStateBackend<Integer>) backend.createKeyedStateBackend( dummyEnv, new JobID(), "test_op", IntSerializer.INSTANCE, 1, new KeyGroupRange(0, 0), new KvStateRegistry().createTaskRegistry(new JobID(), new JobVertexID()), TtlTimeProvider.DEFAULT, new UnregisteredMetricsGroup(), Collections.emptyList(), new CloseableRegistry()); this.stateBackend = stateBackend; this.stateBackend.setCurrentKey(KEY); this.internalTimerService = new TestInternalTimerService<>(new KeyContext() { @Override public void setCurrentKey(Object key) { // ignore } @Override public Object getCurrentKey() { return KEY; } }); }
Example #5
Source File: TriggerTestHarness.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Advanced the watermark and processes any timers that fire because of this. The * window and {@link TriggerResult} for each firing are returned. */ public Collection<Tuple2<W, TriggerResult>> advanceWatermark(long time) throws Exception { Collection<TestInternalTimerService.Timer<Integer, W>> firedTimers = internalTimerService.advanceWatermark(time); Collection<Tuple2<W, TriggerResult>> result = new ArrayList<>(); for (TestInternalTimerService.Timer<Integer, W> timer : firedTimers) { TriggerResult triggerResult = invokeOnEventTime(timer); result.add(new Tuple2<>(timer.getNamespace(), triggerResult)); } return result; }
Example #6
Source File: TriggerTestHarness.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private TriggerResult invokeOnEventTime(TestInternalTimerService.Timer<Integer, W> timer) throws Exception { TestTriggerContext<Integer, W> triggerContext = new TestTriggerContext<>( KEY, timer.getNamespace(), internalTimerService, stateBackend, windowSerializer); return trigger.onEventTime(timer.getTimestamp(), timer.getNamespace(), triggerContext); }
Example #7
Source File: TriggerTestHarness.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Manually invoke {@link Trigger#onEventTime(long, Window, Trigger.TriggerContext)} with * the given parameters. */ public TriggerResult invokeOnEventTime(long timestamp, W window) throws Exception { TestInternalTimerService.Timer<Integer, W> timer = new TestInternalTimerService.Timer<>(timestamp, KEY, window); return invokeOnEventTime(timer); }
Example #8
Source File: TriggerTestHarness.java From flink with Apache License 2.0 | 5 votes |
public TriggerTestHarness( Trigger<T, W> trigger, TypeSerializer<W> windowSerializer) throws Exception { this.trigger = trigger; this.windowSerializer = windowSerializer; // we only ever use one key, other tests make sure that windows work across different // keys DummyEnvironment dummyEnv = new DummyEnvironment("test", 1, 0); MemoryStateBackend backend = new MemoryStateBackend(); @SuppressWarnings("unchecked") HeapKeyedStateBackend<Integer> stateBackend = (HeapKeyedStateBackend<Integer>) backend.createKeyedStateBackend( dummyEnv, new JobID(), "test_op", IntSerializer.INSTANCE, 1, new KeyGroupRange(0, 0), new KvStateRegistry().createTaskRegistry(new JobID(), new JobVertexID()), TtlTimeProvider.DEFAULT, new UnregisteredMetricsGroup(), Collections.emptyList(), new CloseableRegistry()); this.stateBackend = stateBackend; this.stateBackend.setCurrentKey(KEY); this.internalTimerService = new TestInternalTimerService<>(new KeyContext() { @Override public void setCurrentKey(Object key) { // ignore } @Override public Object getCurrentKey() { return KEY; } }); }
Example #9
Source File: TriggerTestHarness.java From flink with Apache License 2.0 | 5 votes |
/** * Advanced the watermark and processes any timers that fire because of this. The * window and {@link TriggerResult} for each firing are returned. */ public Collection<Tuple2<W, TriggerResult>> advanceWatermark(long time) throws Exception { Collection<TestInternalTimerService.Timer<Integer, W>> firedTimers = internalTimerService.advanceWatermark(time); Collection<Tuple2<W, TriggerResult>> result = new ArrayList<>(); for (TestInternalTimerService.Timer<Integer, W> timer : firedTimers) { TriggerResult triggerResult = invokeOnEventTime(timer); result.add(new Tuple2<>(timer.getNamespace(), triggerResult)); } return result; }
Example #10
Source File: TriggerTestHarness.java From flink with Apache License 2.0 | 5 votes |
private TriggerResult invokeOnEventTime(TestInternalTimerService.Timer<Integer, W> timer) throws Exception { TestTriggerContext<Integer, W> triggerContext = new TestTriggerContext<>( KEY, timer.getNamespace(), internalTimerService, stateBackend, windowSerializer); return trigger.onEventTime(timer.getTimestamp(), timer.getNamespace(), triggerContext); }
Example #11
Source File: TriggerTestHarness.java From flink with Apache License 2.0 | 5 votes |
/** * Manually invoke {@link Trigger#onEventTime(long, Window, Trigger.TriggerContext)} with * the given parameters. */ public TriggerResult invokeOnEventTime(long timestamp, W window) throws Exception { TestInternalTimerService.Timer<Integer, W> timer = new TestInternalTimerService.Timer<>(timestamp, KEY, window); return invokeOnEventTime(timer); }
Example #12
Source File: TriggerTestHarness.java From flink with Apache License 2.0 | 5 votes |
public TriggerTestHarness( Trigger<T, W> trigger, TypeSerializer<W> windowSerializer) throws Exception { this.trigger = trigger; this.windowSerializer = windowSerializer; // we only ever use one key, other tests make sure that windows work across different // keys DummyEnvironment dummyEnv = new DummyEnvironment("test", 1, 0); MemoryStateBackend backend = new MemoryStateBackend(); @SuppressWarnings("unchecked") HeapKeyedStateBackend<Integer> stateBackend = (HeapKeyedStateBackend<Integer>) backend.createKeyedStateBackend( dummyEnv, new JobID(), "test_op", IntSerializer.INSTANCE, 1, new KeyGroupRange(0, 0), new KvStateRegistry().createTaskRegistry(new JobID(), new JobVertexID()), TtlTimeProvider.DEFAULT, new UnregisteredMetricsGroup(), Collections.emptyList(), new CloseableRegistry()); this.stateBackend = stateBackend; this.stateBackend.setCurrentKey(KEY); this.internalTimerService = new TestInternalTimerService<>(new KeyContext() { @Override public void setCurrentKey(Object key) { // ignore } @Override public Object getCurrentKey() { return KEY; } }); }
Example #13
Source File: TriggerTestHarness.java From flink with Apache License 2.0 | 5 votes |
/** * Advanced the watermark and processes any timers that fire because of this. The * window and {@link TriggerResult} for each firing are returned. */ public Collection<Tuple2<W, TriggerResult>> advanceWatermark(long time) throws Exception { Collection<TestInternalTimerService.Timer<Integer, W>> firedTimers = internalTimerService.advanceWatermark(time); Collection<Tuple2<W, TriggerResult>> result = new ArrayList<>(); for (TestInternalTimerService.Timer<Integer, W> timer : firedTimers) { TriggerResult triggerResult = invokeOnEventTime(timer); result.add(new Tuple2<>(timer.getNamespace(), triggerResult)); } return result; }
Example #14
Source File: TriggerTestHarness.java From flink with Apache License 2.0 | 5 votes |
private TriggerResult invokeOnEventTime(TestInternalTimerService.Timer<Integer, W> timer) throws Exception { TestTriggerContext<Integer, W> triggerContext = new TestTriggerContext<>( KEY, timer.getNamespace(), internalTimerService, stateBackend, windowSerializer); return trigger.onEventTime(timer.getTimestamp(), timer.getNamespace(), triggerContext); }
Example #15
Source File: TriggerTestHarness.java From flink with Apache License 2.0 | 5 votes |
/** * Manually invoke {@link Trigger#onEventTime(long, Window, Trigger.TriggerContext)} with * the given parameters. */ public TriggerResult invokeOnEventTime(long timestamp, W window) throws Exception { TestInternalTimerService.Timer<Integer, W> timer = new TestInternalTimerService.Timer<>(timestamp, KEY, window); return invokeOnEventTime(timer); }