Flink Checkpoint 设置

Flink Checkpoint 设置 Demo


Pom

1
2
3
4
5
6
7
8
9
10
11
<!-- checkpoint 依赖 -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-statebackend-rocksdb_2.12</artifactId>
<version>1.12.0</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>2.7.6</version>
</dependency>

配置 Checkpoint

1
2
3
4
5
6
7
// Checkpoint 间隔 10s
env.enableCheckpointing(10000);
// 模式为 exactly-once(默认值)
env.getCheckpointConfig().setCheckpointingMode(CheckpointingMode.EXACTLY_ONCE);
env.getCheckpointConfig().setCheckpointTimeout(60000);
env.getCheckpointConfig().setMinPauseBetweenCheckpoints(10000);
env.setStateBackend(new RocksDBStateBackend("file:///Users/emerk/Documents//flink-demo/checkpoint"));