use of org.apache.flink.runtime.state.filesystem.FsStateBackend in project flink by apache.
the class CustomKvStateProgram method main.
public static void main(String[] args) throws Exception {
final int parallelism = Integer.parseInt(args[0]);
final String checkpointPath = args[1];
final int checkpointingInterval = Integer.parseInt(args[2]);
final String outputPath = args[3];
final Optional<Boolean> unalignedCheckpoints = args.length > 4 ? Optional.of(Boolean.parseBoolean(args[4])) : Optional.empty();
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(parallelism);
env.enableCheckpointing(checkpointingInterval);
unalignedCheckpoints.ifPresent(value -> env.getCheckpointConfig().enableUnalignedCheckpoints(value));
env.setStateBackend(new FsStateBackend(checkpointPath));
DataStream<Integer> source = env.addSource(new InfiniteIntegerSource());
source.map(new MapFunction<Integer, Tuple2<Integer, Integer>>() {
private static final long serialVersionUID = 1L;
@Override
public Tuple2<Integer, Integer> map(Integer value) throws Exception {
return new Tuple2<>(ThreadLocalRandom.current().nextInt(parallelism), value);
}
}).keyBy(new KeySelector<Tuple2<Integer, Integer>, Integer>() {
private static final long serialVersionUID = 1L;
@Override
public Integer getKey(Tuple2<Integer, Integer> value) throws Exception {
return value.f0;
}
}).flatMap(new ReducingStateFlatMap()).writeAsText(outputPath);
env.execute();
}
use of org.apache.flink.runtime.state.filesystem.FsStateBackend in project flink by apache.
the class KeyedStateCheckpointingITCase method testWithFsBackendAsync.
@Test
public void testWithFsBackendAsync() throws Exception {
FsStateBackend asyncFsBackend = new FsStateBackend(tmpFolder.newFolder().toURI().toString(), true);
testProgramWithBackend(asyncFsBackend);
}
use of org.apache.flink.runtime.state.filesystem.FsStateBackend in project flink by apache.
the class KeyedStateCheckpointingITCase method testWithFsBackendSync.
@Test
public void testWithFsBackendSync() throws Exception {
FsStateBackend syncFsBackend = new FsStateBackend(tmpFolder.newFolder().toURI().toString(), false);
testProgramWithBackend(syncFsBackend);
}
Aggregations