Help Center> Cloud Stream Service> FAQ> Job Related FAQs> How Do I Save Checkpoints to OBS for a Custom Flink Job?

How Do I Save Checkpoints to OBS for a Custom Flink Job?

CS can save checkpoints of a custom Flink job to OBS. The code example is as follows:

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.runtime.state.filesystem.FsStateBackend;
import org.apache.flink.contrib.streaming.state.RocksDBStateBackend;

StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
RocksDBStateBackend rocksDbBackend = new RocksDBStateBackend(new FsStateBackend("OBS path"), true);
env.setStateBackend(rocksDbBackend);

The OBS path is obs://ak:sk@OBS endpoint/bucket name/bucket directory. ak and sk are the AK/SK of the account owning the OBS bucket to be uploaded.