use of org.apache.flink.streaming.api.windowing.evictors.Evictor in project flink by apache.
the class SavepointWindowReaderITCase method testProcessEvictorWindowStateReader.
@Test
public void testProcessEvictorWindowStateReader() throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setStateBackend(getStateBackend());
env.setParallelism(4);
env.addSource(createSource(numbers)).rebalance().assignTimestampsAndWatermarks(WatermarkStrategy.<Integer>noWatermarks().withTimestampAssigner((event, timestamp) -> 0)).keyBy(id -> id).window(TumblingEventTimeWindows.of(Time.milliseconds(10))).evictor(new NoOpEvictor<>()).process(new NoOpProcessWindowFunction()).uid(uid).addSink(new DiscardingSink<>());
String savepointPath = takeSavepoint(env);
SavepointReader savepoint = SavepointReader.read(env, savepointPath, getStateBackend());
List<Integer> results = JobResultRetriever.collect(savepoint.window(TumblingEventTimeWindows.of(Time.milliseconds(10))).evictor().process(uid, new BasicReaderFunction(), Types.INT, Types.INT, Types.INT));
Assert.assertThat("Unexpected results from keyed state", results, Matchers.containsInAnyOrder(numbers));
}
use of org.apache.flink.streaming.api.windowing.evictors.Evictor in project flink by apache.
the class SavepointWindowReaderITCase method testAggregateEvictorWindowStateReader.
@Test
public void testAggregateEvictorWindowStateReader() throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setStateBackend(getStateBackend());
env.setParallelism(4);
env.addSource(createSource(numbers)).rebalance().assignTimestampsAndWatermarks(WatermarkStrategy.<Integer>noWatermarks().withTimestampAssigner((event, timestamp) -> 0)).keyBy(id -> id).window(TumblingEventTimeWindows.of(Time.milliseconds(10))).evictor(new NoOpEvictor<>()).aggregate(new AggregateSum()).uid(uid).addSink(new DiscardingSink<>());
String savepointPath = takeSavepoint(env);
SavepointReader savepoint = SavepointReader.read(env, savepointPath, getStateBackend());
List<Integer> results = JobResultRetriever.collect(savepoint.window(TumblingEventTimeWindows.of(Time.milliseconds(10))).evictor().aggregate(uid, new AggregateSum(), Types.INT, Types.INT, Types.INT));
Assert.assertThat("Unexpected results from keyed state", results, Matchers.containsInAnyOrder(numbers));
}
use of org.apache.flink.streaming.api.windowing.evictors.Evictor in project flink by apache.
the class SavepointWindowReaderITCase method testApplyEvictorWindowStateReader.
@Test
public void testApplyEvictorWindowStateReader() throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setStateBackend(getStateBackend());
env.setParallelism(4);
env.addSource(createSource(numbers)).rebalance().assignTimestampsAndWatermarks(WatermarkStrategy.<Integer>noWatermarks().withTimestampAssigner((event, timestamp) -> 0)).keyBy(id -> id).window(TumblingEventTimeWindows.of(Time.milliseconds(10))).evictor(new NoOpEvictor<>()).apply(new NoOpWindowFunction()).uid(uid).addSink(new DiscardingSink<>());
String savepointPath = takeSavepoint(env);
SavepointReader savepoint = SavepointReader.read(env, savepointPath, getStateBackend());
List<Integer> results = JobResultRetriever.collect(savepoint.window(TumblingEventTimeWindows.of(Time.milliseconds(1))).evictor().process(uid, new BasicReaderFunction(), Types.INT, Types.INT, Types.INT));
Assert.assertThat("Unexpected results from keyed state", results, Matchers.containsInAnyOrder(numbers));
}
use of org.apache.flink.streaming.api.windowing.evictors.Evictor in project flink by apache.
the class DataSetSavepointWindowReaderITCase method testAggregateEvictorWindowStateReader.
@Test
public void testAggregateEvictorWindowStateReader() throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setStateBackend(getStateBackend());
env.setParallelism(4);
env.addSource(createSource(numbers)).rebalance().assignTimestampsAndWatermarks(WatermarkStrategy.<Integer>noWatermarks().withTimestampAssigner((event, timestamp) -> 0)).keyBy(id -> id).window(TumblingEventTimeWindows.of(Time.milliseconds(10))).evictor(new NoOpEvictor<>()).aggregate(new AggregateSum()).uid(uid).addSink(new DiscardingSink<>());
String savepointPath = takeSavepoint(env);
ExecutionEnvironment batchEnv = ExecutionEnvironment.getExecutionEnvironment();
ExistingSavepoint savepoint = Savepoint.load(batchEnv, savepointPath, getStateBackend());
List<Integer> results = savepoint.window(TumblingEventTimeWindows.of(Time.milliseconds(10))).evictor().aggregate(uid, new AggregateSum(), Types.INT, Types.INT, Types.INT).collect();
Assert.assertThat("Unexpected results from keyed state", results, Matchers.containsInAnyOrder(numbers));
}
use of org.apache.flink.streaming.api.windowing.evictors.Evictor in project flink by apache.
the class DataSetSavepointWindowReaderITCase method testReduceEvictorWindowStateReader.
@Test
public void testReduceEvictorWindowStateReader() throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setStateBackend(getStateBackend());
env.setParallelism(4);
env.addSource(createSource(numbers)).rebalance().assignTimestampsAndWatermarks(WatermarkStrategy.<Integer>noWatermarks().withTimestampAssigner((event, timestamp) -> 0)).keyBy(id -> id).window(TumblingEventTimeWindows.of(Time.milliseconds(10))).evictor(new NoOpEvictor<>()).reduce(new ReduceSum()).uid(uid).addSink(new DiscardingSink<>());
String savepointPath = takeSavepoint(env);
ExecutionEnvironment batchEnv = ExecutionEnvironment.getExecutionEnvironment();
ExistingSavepoint savepoint = Savepoint.load(batchEnv, savepointPath, getStateBackend());
List<Integer> results = savepoint.window(TumblingEventTimeWindows.of(Time.milliseconds(10))).evictor().reduce(uid, new ReduceSum(), Types.INT, Types.INT).collect();
Assert.assertThat("Unexpected results from keyed state", results, Matchers.containsInAnyOrder(numbers));
}
Aggregations