use of org.apache.flink.streaming.api.datastream.DataStreamUtils in project flink by apache.
the class RegionFailoverITCase method createJobGraph.
private JobGraph createJobGraph() {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(NUM_OF_REGIONS);
env.setMaxParallelism(MAX_PARALLELISM);
env.enableCheckpointing(200, CheckpointingMode.EXACTLY_ONCE);
env.getCheckpointConfig().setExternalizedCheckpointCleanup(CheckpointConfig.ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION);
env.disableOperatorChaining();
// Use DataStreamUtils#reinterpretAsKeyed to avoid merge regions and this stream graph would
// exist num of 'NUM_OF_REGIONS' individual regions.
DataStreamUtils.reinterpretAsKeyedStream(env.addSource(new StringGeneratingSourceFunction(NUM_ELEMENTS, NUM_ELEMENTS / NUM_OF_RESTARTS)).name(MULTI_REGION_SOURCE_NAME).setParallelism(NUM_OF_REGIONS), (KeySelector<Tuple2<Integer, Integer>, Integer>) value -> value.f0, TypeInformation.of(Integer.class)).map(new FailingMapperFunction(NUM_OF_RESTARTS)).setParallelism(NUM_OF_REGIONS).addSink(new ValidatingSink()).setParallelism(NUM_OF_REGIONS);
// another stream graph totally disconnected with the above one.
env.addSource(new StringGeneratingSourceFunction(NUM_ELEMENTS, NUM_ELEMENTS / NUM_OF_RESTARTS)).name(SINGLE_REGION_SOURCE_NAME).setParallelism(1).map((MapFunction<Tuple2<Integer, Integer>, Object>) value -> value).setParallelism(1);
return env.getStreamGraph().getJobGraph();
}
Aggregations