创建上下文环境
val streamEnv = StreamExecutionEnvironment.getExecutionEnvironment
streamEnv.setStateBackend(RocksDBStateBackend)
flink 中的checkpoint 有三种配置:
1. MemoryStateBackend (flink默认配置)
2. FsStateBackend (需要手动配置)
3. RocksDBStateBackend (需要额外的包,如下gradle中的代码配置)
plugins {
id 'java'
id 'scala'
}
version 'unspecified'
sourceCompatibility = 1.8
repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public'}
mavenCentral()
}
dependencies {
// testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.apache.flink', name: 'flink-scala_2.11', version: '1.10.2'
compile group: 'org.apache.flink', name: 'flink-core', version: '1.10.2'
compile group: 'org.apache.flink', name: 'flink-streaming-scala_2.11', version: '1.10.2'
compile group: 'org.apache.flink', name: 'flink-clients_2.11', version: '1.10.2'
compile group: 'org.apache.flink', name: 'flink-table', version: '1.10.2', ext: 'pom'
compile group: 'org.apache.flink', name: 'flink-statebackend-rocksdb_2.11', version: '1.10.0'
}