public StreamGraph(StreamExecutionEnvironment environment) { this.environment = environment; this.executionConfig = environment.getConfig(); this.checkpointConfig = environment.getCheckpointConfig(); // create an empty new stream graph. clear(); }
@Test public void testCheckpointConfigDefault() throws Exception { StreamExecutionEnvironment streamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment(); Assert.assertTrue(streamExecutionEnvironment.getCheckpointConfig().isFailOnCheckpointingErrors()); }
env.getCheckpointConfig().setMaxConcurrentCheckpoints(1); env.getCheckpointConfig().setMinPauseBetweenCheckpoints(0);
public void doTestPropagationFromCheckpointConfig(boolean failTaskOnCheckpointErrors) throws Exception { StreamExecutionEnvironment streamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment(); streamExecutionEnvironment.setParallelism(1); streamExecutionEnvironment.getCheckpointConfig().setCheckpointInterval(1000); streamExecutionEnvironment.getCheckpointConfig().setFailOnCheckpointingErrors(failTaskOnCheckpointErrors); streamExecutionEnvironment.addSource(new SourceFunction<Integer>() { @Override public void run(SourceContext<Integer> ctx) throws Exception { } @Override public void cancel() { } }).addSink(new DiscardingSink<>()); StreamGraph streamGraph = streamExecutionEnvironment.getStreamGraph(); JobGraph jobGraph = StreamingJobGraphGenerator.createJobGraph(streamGraph); SerializedValue<ExecutionConfig> serializedExecutionConfig = jobGraph.getSerializedExecutionConfig(); ExecutionConfig executionConfig = serializedExecutionConfig.deserializeValue(Thread.currentThread().getContextClassLoader()); Assert.assertEquals(failTaskOnCheckpointErrors, executionConfig.isFailTaskOnCheckpointError()); } }
env.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, pt.getInt("restartDelay", 0))); if (pt.getBoolean("externalizedCheckpoints", false)) { env.getCheckpointConfig().enableExternalizedCheckpoints(CheckpointConfig.ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION);
env.getCheckpointConfig().enableExternalizedCheckpoints(cleanupMode);
env.setParallelism(Parallelism); env.enableCheckpointing(checkpointingInterval); env.getCheckpointConfig() .enableExternalizedCheckpoints(CheckpointConfig.ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION);
public StreamGraph(StreamExecutionEnvironment environment) { this.environment = environment; this.executionConfig = environment.getConfig(); this.checkpointConfig = environment.getCheckpointConfig(); // create an empty new stream graph. clear(); }
public StreamGraph(StreamExecutionEnvironment environment) { this.environment = environment; this.executionConfig = environment.getConfig(); this.checkpointConfig = environment.getCheckpointConfig(); // create an empty new stream graph. clear(); }
public StreamGraph(StreamExecutionEnvironment environment) { this.environment = environment; this.executionConfig = environment.getConfig(); this.checkpointConfig = environment.getCheckpointConfig(); // create an empty new stream graph. clear(); }
if(checkMode != null){ if(checkMode.equalsIgnoreCase("EXACTLY_ONCE")){ env.getCheckpointConfig().setCheckpointingMode(CheckpointingMode.EXACTLY_ONCE); }else if(checkMode.equalsIgnoreCase("AT_LEAST_ONCE")){ env.getCheckpointConfig().setCheckpointingMode(CheckpointingMode.AT_LEAST_ONCE); }else{ throw new RuntimeException("not support of FLINK_CHECKPOINT_MODE_KEY :" + checkMode); Long checkpointTimeout = Long.valueOf(checkpointTimeoutStr); env.getCheckpointConfig().setCheckpointTimeout(checkpointTimeout); Integer maxConcurrCheckpoints = Integer.valueOf(maxConcurrCheckpointsStr); env.getCheckpointConfig().setMaxConcurrentCheckpoints(maxConcurrCheckpoints); if(cleanupModeStr != null){//设置在cancel job情况下checkpoint是否被保存 if("true".equalsIgnoreCase(cleanupModeStr)){ env.getCheckpointConfig().enableExternalizedCheckpoints( CheckpointConfig.ExternalizedCheckpointCleanup.DELETE_ON_CANCELLATION); }else if("false".equalsIgnoreCase(cleanupModeStr)){ env.getCheckpointConfig().enableExternalizedCheckpoints( CheckpointConfig.ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION); }else{
flinkStreamEnv.getCheckpointConfig().setCheckpointTimeout( options.getCheckpointTimeoutMillis()); boolean externalizedCheckpoint = options.isExternalizedCheckpointsEnabled(); boolean retainOnCancellation = options.getRetainExternalizedCheckpointsOnCancellation(); if (externalizedCheckpoint) { flinkStreamEnv.getCheckpointConfig().enableExternalizedCheckpoints( retainOnCancellation ? ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION : ExternalizedCheckpointCleanup.DELETE_ON_CANCELLATION);
if (options.getCheckpointTimeoutMillis() != -1) { flinkStreamEnv .getCheckpointConfig() .setCheckpointTimeout(options.getCheckpointTimeoutMillis()); if (externalizedCheckpoint) { flinkStreamEnv .getCheckpointConfig() .enableExternalizedCheckpoints( retainOnCancellation if (minPauseBetweenCheckpoints != -1) { flinkStreamEnv .getCheckpointConfig() .setMinPauseBetweenCheckpoints(minPauseBetweenCheckpoints);
public static void main(String argsp[]) throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime); // 设置checkpoint env.enableCheckpointing(60000); CheckpointConfig checkpointConf = env.getCheckpointConfig(); checkpointConf.setMinPauseBetweenCheckpoints(30000L); checkpointConf.setCheckpointTimeout(10000L); checkpointConf.enableExternalizedCheckpoints(CheckpointConfig.ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION); env.fromElements(1L,2L,3L,4L,5L,1L,3L,4L,5L,6L,7L,1L,4L,5L,3L,9L,9L,2L,1L) .flatMap(new CountWithOperatorState()) .addSink(new SinkFunction<String>() { @Override public void invoke(String s) throws Exception { } }); }
if (options.getCheckpointTimeoutMillis() != -1) { flinkStreamEnv .getCheckpointConfig() .setCheckpointTimeout(options.getCheckpointTimeoutMillis()); if (externalizedCheckpoint) { flinkStreamEnv .getCheckpointConfig() .enableExternalizedCheckpoints( retainOnCancellation if (minPauseBetweenCheckpoints != -1) { flinkStreamEnv .getCheckpointConfig() .setMinPauseBetweenCheckpoints(minPauseBetweenCheckpoints); flinkStreamEnv.getCheckpointConfig().setFailOnCheckpointingErrors(failOnCheckpointingErrors);
public static void main(String argsp[]) throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime); // 设置checkpoint env.enableCheckpointing(60000); CheckpointConfig checkpointConf = env.getCheckpointConfig(); checkpointConf.setMinPauseBetweenCheckpoints(30000L); checkpointConf.setCheckpointTimeout(10000L); checkpointConf.enableExternalizedCheckpoints(CheckpointConfig.ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION); env.fromElements(Tuple2.of(1L, 3L), Tuple2.of(1L, 5L), Tuple2.of(1L, 7L), Tuple2.of(1L, 4L), Tuple2.of(1L, 2L)) .keyBy(0) .flatMap(new CountWithKeyedState()) .addSink(new SinkFunction<Tuple2<Long, Long>>() { @Override public void invoke(Tuple2<Long, Long> longLongTuple2) throws Exception { } }); env.execute("CountOnlyState"); } }
private StreamExecutionEnvironment createJobGraph(int parallelism, Function<DataStream<String>, DataStream<String>> pipelinerBuilder) throws Exception { final Path checkpointDir = getCheckpointDir(); final Path savepointRootDir = getSavepointDir(); checkpointDir.getFileSystem().mkdirs(checkpointDir); savepointRootDir.getFileSystem().mkdirs(savepointRootDir); StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.getConfig().disableSysoutLogging(); env.getCheckpointConfig().enableExternalizedCheckpoints(ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION); env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime); env.setBufferTimeout(0); env.setParallelism(parallelism); env.enableCheckpointing(500, CheckpointingMode.EXACTLY_ONCE); env.setStateBackend((StateBackend) new RocksDBStateBackend(checkpointDir.toString(), true)); DataStream<String> sourceData = env .addSource(new TestPipelineSource()) .uid("TestSource") .name("TestSource") .setParallelism(1); pipelinerBuilder.apply(sourceData) .addSink(new CollectingSink()).name("Output").uid("Output") .setParallelism(1); return env; }