Java Code Examples for org.apache.flink.runtime.state.StateBackend

The following examples show how to use org.apache.flink.runtime.state.StateBackend. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private JobGraph createJobGraph(ExecutionMode mode) {
	StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.enableCheckpointing(500, CheckpointingMode.EXACTLY_ONCE);
	env.setRestartStrategy(RestartStrategies.noRestart());
	env.setStateBackend((StateBackend) new MemoryStateBackend());

	switch (mode) {
		case MIGRATE:
			createMigrationJob(env);
			break;
		case RESTORE:
			createRestoredJob(env);
			break;
	}

	return StreamingJobGraphGenerator.createJobGraph(env.getStreamGraph());
}
 
Example 2
Source Project: flink   Source File: JobCheckpointingSettings.java    License: Apache License 2.0 6 votes vote down vote up
public JobCheckpointingSettings(
		List<JobVertexID> verticesToTrigger,
		List<JobVertexID> verticesToAcknowledge,
		List<JobVertexID> verticesToConfirm,
		CheckpointCoordinatorConfiguration checkpointCoordinatorConfiguration,
		@Nullable SerializedValue<StateBackend> defaultStateBackend,
		@Nullable SerializedValue<MasterTriggerRestoreHook.Factory[]> masterHooks) {


	this.verticesToTrigger = requireNonNull(verticesToTrigger);
	this.verticesToAcknowledge = requireNonNull(verticesToAcknowledge);
	this.verticesToConfirm = requireNonNull(verticesToConfirm);
	this.checkpointCoordinatorConfiguration = Preconditions.checkNotNull(checkpointCoordinatorConfiguration);
	this.defaultStateBackend = defaultStateBackend;
	this.masterHooks = masterHooks;
}
 
Example 3
Source Project: flink   Source File: DispatcherTest.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
private URI createTestingSavepoint() throws IOException, URISyntaxException {
	final StateBackend stateBackend = Checkpoints.loadStateBackend(configuration, Thread.currentThread().getContextClassLoader(), log);
	final CheckpointStorageCoordinatorView checkpointStorage = stateBackend.createCheckpointStorage(jobGraph.getJobID());
	final File savepointFile = temporaryFolder.newFolder();
	final long checkpointId = 1L;

	final CheckpointStorageLocation checkpointStorageLocation = checkpointStorage.initializeLocationForSavepoint(checkpointId, savepointFile.getAbsolutePath());

	final CheckpointMetadataOutputStream metadataOutputStream = checkpointStorageLocation.createMetadataOutputStream();
	Checkpoints.storeCheckpointMetadata(new SavepointV2(checkpointId, Collections.emptyList(), Collections.emptyList()), metadataOutputStream);

	final CompletedCheckpointStorageLocation completedCheckpointStorageLocation = metadataOutputStream.closeAndFinalizeCheckpoint();

	return new URI(completedCheckpointStorageLocation.getExternalPointer());

}
 
Example 4
Source Project: Flink-CEPplus   Source File: JobCheckpointingSettings.java    License: Apache License 2.0 6 votes vote down vote up
public JobCheckpointingSettings(
		List<JobVertexID> verticesToTrigger,
		List<JobVertexID> verticesToAcknowledge,
		List<JobVertexID> verticesToConfirm,
		CheckpointCoordinatorConfiguration checkpointCoordinatorConfiguration,
		@Nullable SerializedValue<StateBackend> defaultStateBackend,
		@Nullable SerializedValue<MasterTriggerRestoreHook.Factory[]> masterHooks) {


	this.verticesToTrigger = requireNonNull(verticesToTrigger);
	this.verticesToAcknowledge = requireNonNull(verticesToAcknowledge);
	this.verticesToConfirm = requireNonNull(verticesToConfirm);
	this.checkpointCoordinatorConfiguration = Preconditions.checkNotNull(checkpointCoordinatorConfiguration);
	this.defaultStateBackend = defaultStateBackend;
	this.masterHooks = masterHooks;
}
 
Example 5
Source Project: Flink-CEPplus   Source File: DispatcherTest.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
private URI createTestingSavepoint() throws IOException, URISyntaxException {
	final StateBackend stateBackend = Checkpoints.loadStateBackend(configuration, Thread.currentThread().getContextClassLoader(), log);
	final CheckpointStorage checkpointStorage = stateBackend.createCheckpointStorage(jobGraph.getJobID());
	final File savepointFile = temporaryFolder.newFolder();
	final long checkpointId = 1L;

	final CheckpointStorageLocation checkpointStorageLocation = checkpointStorage.initializeLocationForSavepoint(checkpointId, savepointFile.getAbsolutePath());

	final CheckpointMetadataOutputStream metadataOutputStream = checkpointStorageLocation.createMetadataOutputStream();
	Checkpoints.storeCheckpointMetadata(new SavepointV2(checkpointId, Collections.emptyList(), Collections.emptyList()), metadataOutputStream);

	final CompletedCheckpointStorageLocation completedCheckpointStorageLocation = metadataOutputStream.closeAndFinalizeCheckpoint();

	return new URI(completedCheckpointStorageLocation.getExternalPointer());

}
 
Example 6
Source Project: flink   Source File: ResumeCheckpointManuallyITCase.java    License: Apache License 2.0 6 votes vote down vote up
private static JobGraph getJobGraph(StateBackend backend, @Nullable String externalCheckpoint) {
	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

	env.enableCheckpointing(500);
	env.setStateBackend(backend);
	env.setStreamTimeCharacteristic(TimeCharacteristic.IngestionTime);
	env.setParallelism(PARALLELISM);
	env.getCheckpointConfig().enableExternalizedCheckpoints(CheckpointConfig.ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION);

	env.addSource(new NotifyingInfiniteTupleSource(10_000))
		.keyBy(0)
		.timeWindow(Time.seconds(3))
		.reduce((value1, value2) -> Tuple2.of(value1.f0, value1.f1 + value2.f1))
		.filter(value -> value.f0.startsWith("Tuple 0"));

	StreamGraph streamGraph = env.getStreamGraph("Test");

	JobGraph jobGraph = streamGraph.getJobGraph();

	// recover from previous iteration?
	if (externalCheckpoint != null) {
		jobGraph.setSavepointRestoreSettings(SavepointRestoreSettings.forPath(externalCheckpoint));
	}

	return jobGraph;
}
 
Example 7
Source Project: flink   Source File: JobCheckpointingSettings.java    License: Apache License 2.0 6 votes vote down vote up
public JobCheckpointingSettings(
		List<JobVertexID> verticesToTrigger,
		List<JobVertexID> verticesToAcknowledge,
		List<JobVertexID> verticesToConfirm,
		CheckpointCoordinatorConfiguration checkpointCoordinatorConfiguration,
		@Nullable SerializedValue<StateBackend> defaultStateBackend,
		@Nullable SerializedValue<MasterTriggerRestoreHook.Factory[]> masterHooks) {


	this.verticesToTrigger = requireNonNull(verticesToTrigger);
	this.verticesToAcknowledge = requireNonNull(verticesToAcknowledge);
	this.verticesToConfirm = requireNonNull(verticesToConfirm);
	this.checkpointCoordinatorConfiguration = Preconditions.checkNotNull(checkpointCoordinatorConfiguration);
	this.defaultStateBackend = defaultStateBackend;
	this.masterHooks = masterHooks;
}
 
Example 8
Source Project: flink   Source File: KeyedStateInputFormat.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates an input format for reading partitioned state from an operator in a savepoint.
 *
 * @param operatorState The state to be queried.
 * @param stateBackend  The state backed used to snapshot the operator.
 * @param configuration The underlying Flink configuration used to configure the state backend.
 */
public KeyedStateInputFormat(
	OperatorState operatorState,
	StateBackend stateBackend,
	Configuration configuration,
	StateReaderOperator<?, K, N, OUT> operator) {
	Preconditions.checkNotNull(operatorState, "The operator state cannot be null");
	Preconditions.checkNotNull(stateBackend, "The state backend cannot be null");
	Preconditions.checkNotNull(configuration, "The configuration cannot be null");
	Preconditions.checkNotNull(operator, "The operator cannot be null");

	this.operatorState = operatorState;
	this.stateBackend = stateBackend;
	// Eagerly deep copy the configuration object
	// otherwise there will be undefined behavior
	// when executing pipelines with multiple input formats
	this.configuration = new Configuration(configuration);
	this.operator = operator;
}
 
Example 9
@Test
public void testBlockingNonInterruptibleCheckpoint() throws Exception {

	StateBackend lockingStateBackend = new BackendForTestStream(LockingOutputStream::new);

	Task task =
		createTask(new TestOperator(), lockingStateBackend, mock(CheckpointResponder.class), true);

	// start the task and wait until it is in "restore"
	task.startTaskThread();
	IN_CHECKPOINT_LATCH.await();

	// cancel the task and wait. unless cancellation properly closes
	// the streams, this will never terminate
	task.cancelExecution();
	task.getExecutingThread().join();

	assertEquals(ExecutionState.CANCELED, task.getExecutionState());
	assertNull(task.getFailureCause());
}
 
Example 10
Source Project: flink   Source File: AbstractOperatorRestoreTestBase.java    License: Apache License 2.0 6 votes vote down vote up
private JobGraph createJobGraph(ExecutionMode mode) {
	StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	env.enableCheckpointing(500, CheckpointingMode.EXACTLY_ONCE);
	env.setRestartStrategy(RestartStrategies.noRestart());
	env.setStateBackend((StateBackend) new MemoryStateBackend());

	switch (mode) {
		case MIGRATE:
			createMigrationJob(env);
			break;
		case RESTORE:
			createRestoredJob(env);
			break;
	}

	return StreamingJobGraphGenerator.createJobGraph(env.getStreamGraph());
}
 
Example 11
Source Project: flink   Source File: KeyedStateInputFormat.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates an input format for reading partitioned state from an operator in a savepoint.
 *
 * @param operatorState The state to be queried.
 * @param stateBackend  The state backed used to snapshot the operator.
 * @param keyType       The type information describing the key type.
 * @param userFunction  The {@link KeyedStateReaderFunction} called for each key in the operator.
 */
public KeyedStateInputFormat(
	OperatorState operatorState,
	StateBackend stateBackend,
	TypeInformation<K> keyType,
	KeyedStateReaderFunction<K, OUT> userFunction) {
	Preconditions.checkNotNull(operatorState, "The operator state cannot be null");
	Preconditions.checkNotNull(stateBackend, "The state backend cannot be null");
	Preconditions.checkNotNull(keyType, "The key type information cannot be null");
	Preconditions.checkNotNull(userFunction, "The userfunction cannot be null");

	this.operatorState = operatorState;
	this.stateBackend = stateBackend;
	this.keyType = keyType;
	this.userFunction = userFunction;
}
 
Example 12
Source Project: flink   Source File: BootstrapTransformation.java    License: Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
StreamConfig getConfig(OperatorID operatorID, StateBackend stateBackend, StreamOperator<TaggedOperatorSubtaskState> operator) {
	// Eagerly perform a deep copy of the configuration, otherwise it will result in undefined behavior
	// when deploying with multiple bootstrap transformations.
	Configuration deepCopy = new Configuration(dataSet.getExecutionEnvironment().getConfiguration());
	final StreamConfig config = new StreamConfig(deepCopy);
	config.setChainStart();
	config.setCheckpointingEnabled(true);
	config.setCheckpointMode(CheckpointingMode.EXACTLY_ONCE);

	if (keyType != null) {
		TypeSerializer<?> keySerializer = keyType.createSerializer(dataSet.getExecutionEnvironment().getConfig());

		config.setStateKeySerializer(keySerializer);
		config.setStatePartitioner(0, originalKeySelector);
	}

	config.setStreamOperator(operator);
	config.setOperatorName(operatorID.toHexString());
	config.setOperatorID(operatorID);
	config.setStateBackend(stateBackend);
	return config;
}
 
Example 13
Source Project: flink   Source File: DataStreamAllroundTestJobFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static void setupStateBackend(final StreamExecutionEnvironment env, final ParameterTool pt) throws IOException {
	final String stateBackend = pt.get(
		STATE_BACKEND.key(),
		STATE_BACKEND.defaultValue());

	final String checkpointDir = pt.getRequired(STATE_BACKEND_CHECKPOINT_DIR.key());

	if ("file".equalsIgnoreCase(stateBackend)) {
		boolean asyncCheckpoints = pt.getBoolean(
			STATE_BACKEND_FILE_ASYNC.key(),
			STATE_BACKEND_FILE_ASYNC.defaultValue());

		env.setStateBackend((StateBackend) new FsStateBackend(checkpointDir, asyncCheckpoints));
	} else if ("rocks".equalsIgnoreCase(stateBackend)) {
		boolean incrementalCheckpoints = pt.getBoolean(
			STATE_BACKEND_ROCKS_INCREMENTAL.key(),
			STATE_BACKEND_ROCKS_INCREMENTAL.defaultValue());

		env.setStateBackend((StateBackend) new RocksDBStateBackend(checkpointDir, incrementalCheckpoints));
	} else {
		throw new IllegalArgumentException("Unknown backend requested: " + stateBackend);
	}
}
 
Example 14
private static JobGraph getJobGraph(StateBackend backend, @Nullable String externalCheckpoint) {
	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

	env.enableCheckpointing(500);
	env.setStateBackend(backend);
	env.setStreamTimeCharacteristic(TimeCharacteristic.IngestionTime);
	env.setParallelism(PARALLELISM);
	env.getCheckpointConfig().enableExternalizedCheckpoints(CheckpointConfig.ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION);

	env.addSource(new NotifyingInfiniteTupleSource(10_000))
		.keyBy(0)
		.timeWindow(Time.seconds(3))
		.reduce((value1, value2) -> Tuple2.of(value1.f0, value1.f1 + value2.f1))
		.filter(value -> value.f0.startsWith("Tuple 0"));

	StreamGraph streamGraph = env.getStreamGraph();
	streamGraph.setJobName("Test");

	JobGraph jobGraph = streamGraph.getJobGraph();

	// recover from previous iteration?
	if (externalCheckpoint != null) {
		jobGraph.setSavepointRestoreSettings(SavepointRestoreSettings.forPath(externalCheckpoint));
	}

	return jobGraph;
}
 
Example 15
Source Project: flink   Source File: MockStreamTaskBuilder.java    License: Apache License 2.0 5 votes vote down vote up
public MockStreamTaskBuilder(Environment environment) throws Exception {
	this.environment = environment;
	this.config = new StreamConfig(environment.getTaskConfiguration());

	StateBackend stateBackend = new MemoryStateBackend();
	this.checkpointStorage = stateBackend.createCheckpointStorage(new JobID());
	this.streamTaskStateInitializer = new StreamTaskStateInitializerImpl(environment, stateBackend);
}
 
Example 16
Source Project: flink   Source File: DataStreamStateTTLTestProgram.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the state backend to a new {@link StubStateBackend} which has a {@link MonotonicTTLTimeProvider}.
 *
 * @param env The {@link StreamExecutionEnvironment} of the job.
 */
private static void setBackendWithCustomTTLTimeProvider(StreamExecutionEnvironment env) {
	final MonotonicTTLTimeProvider ttlTimeProvider = new MonotonicTTLTimeProvider();

	final StateBackend configuredBackend = env.getStateBackend();
	final StateBackend stubBackend = new StubStateBackend(configuredBackend, ttlTimeProvider);
	env.setStateBackend(stubBackend);
}
 
Example 17
@Test
public void testLoadingStateBackendFromConfiguration() {
	StreamExecutionEnvironment envFromConfiguration = StreamExecutionEnvironment.getExecutionEnvironment();

	Configuration configuration = new Configuration();
	configuration.setString("state.backend", "jobmanager");

	// mutate config according to configuration
	envFromConfiguration.configure(configuration, Thread.currentThread().getContextClassLoader());

	StateBackend actualStateBackend = envFromConfiguration.getStateBackend();
	assertThat(actualStateBackend, instanceOf(MemoryStateBackend.class));
}
 
Example 18
public StreamTaskStateInitializerImpl(
	Environment environment,
	StateBackend stateBackend,
	ProcessingTimeService processingTimeService) {

	this.environment = environment;
	this.taskStateManager = Preconditions.checkNotNull(environment.getTaskStateManager());
	this.stateBackend = Preconditions.checkNotNull(stateBackend);
	this.processingTimeService = processingTimeService;
}
 
Example 19
Source Project: flink   Source File: MockTtlStateTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected StateBackendTestContext createStateBackendTestContext(TtlTimeProvider timeProvider) {
	return new StateBackendTestContext(timeProvider) {
		@Override
		protected StateBackend createStateBackend() {
			return new MockStateBackend();
		}
	};
}
 
Example 20
Source Project: flink   Source File: RocksDBTtlStateTestBase.java    License: Apache License 2.0 5 votes vote down vote up
StateBackend createStateBackend(TernaryBoolean enableIncrementalCheckpointing) {
	String dbPath;
	String checkpointPath;
	try {
		dbPath = tempFolder.newFolder().getAbsolutePath();
		checkpointPath = tempFolder.newFolder().toURI().toString();
	} catch (IOException e) {
		throw new FlinkRuntimeException("Failed to init rocksdb test state backend");
	}
	RocksDBStateBackend backend = new RocksDBStateBackend(new FsStateBackend(checkpointPath), enableIncrementalCheckpointing);
	Configuration config = new Configuration();
	backend = backend.configure(config, Thread.currentThread().getContextClassLoader());
	backend.setDbStoragePath(dbPath);
	return backend;
}
 
Example 21
Source Project: Flink-CEPplus   Source File: StreamTask.java    License: Apache License 2.0 5 votes vote down vote up
private StateBackend createStateBackend() throws Exception {
	final StateBackend fromApplication = configuration.getStateBackend(getUserCodeClassLoader());

	return StateBackendLoader.fromApplicationOrConfigOrDefault(
			fromApplication,
			getEnvironment().getTaskManagerInfo().getConfiguration(),
			getUserCodeClassLoader(),
			LOG);
}
 
Example 22
Source Project: flink   Source File: JobCheckpointingSettings.java    License: Apache License 2.0 5 votes vote down vote up
public JobCheckpointingSettings(
		List<JobVertexID> verticesToTrigger,
		List<JobVertexID> verticesToAcknowledge,
		List<JobVertexID> verticesToConfirm,
		CheckpointCoordinatorConfiguration checkpointCoordinatorConfiguration,
		@Nullable SerializedValue<StateBackend> defaultStateBackend) {

	this(
		verticesToTrigger,
		verticesToAcknowledge,
		verticesToConfirm,
		checkpointCoordinatorConfiguration,
		defaultStateBackend,
		null);
}
 
Example 23
Source Project: flink   Source File: StreamConfig.java    License: Apache License 2.0 5 votes vote down vote up
public StateBackend getStateBackend(ClassLoader cl) {
	try {
		return InstantiationUtil.readObjectFromConfig(this.config, STATE_BACKEND, cl);
	} catch (Exception e) {
		throw new StreamTaskException("Could not instantiate statehandle provider.", e);
	}
}
 
Example 24
Source Project: flink   Source File: ExistingSavepoint.java    License: Apache License 2.0 5 votes vote down vote up
ExistingSavepoint(ExecutionEnvironment env, SavepointMetadata metadata, StateBackend stateBackend) throws IOException {
	super(metadata, stateBackend);
	Preconditions.checkNotNull(env, "The execution environment must not be null");
	Preconditions.checkNotNull(metadata, "The savepoint metadata must not be null");
	Preconditions.checkNotNull(stateBackend, "The state backend must not be null");

	this.env = env;
	this.metadata = metadata;
	this.stateBackend = stateBackend;
}
 
Example 25
Source Project: flink-learning   Source File: EnableCheckpointMain.java    License: Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    //创建流运行环境
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    env.getConfig().setGlobalJobParameters(ParameterTool.fromArgs(args));
    env.setParallelism(1);

    env.addSource(new SourceFunction<Long>() {
        @Override
        public void run(SourceContext<Long> sourceContext) throws Exception {
            while (true) {
                sourceContext.collect(null);
            }
        }
        @Override
        public void cancel() {
        }
    })
            .map((MapFunction<Long, Long>) aLong -> aLong / 1)
            .print();

    //开启 checkpoint
    StateBackend stateBackend = new MemoryStateBackend(5 * 1024 * 1024 * 100);
    env.enableCheckpointing(10000);
    env.setStateBackend(stateBackend);

    env.execute("zhisheng default RestartStrategy enable checkpoint example");
}
 
Example 26
Source Project: flink   Source File: ResumeCheckpointManuallyITCase.java    License: Apache License 2.0 5 votes vote down vote up
private static String runJobAndGetExternalizedCheckpoint(StateBackend backend, File checkpointDir, @Nullable String externalCheckpoint, ClusterClient<?> client) throws Exception {
	JobGraph initialJobGraph = getJobGraph(backend, externalCheckpoint);
	NotifyingInfiniteTupleSource.countDownLatch = new CountDownLatch(PARALLELISM);

	client.submitJob(initialJobGraph, ResumeCheckpointManuallyITCase.class.getClassLoader());

	// wait until all sources have been started
	NotifyingInfiniteTupleSource.countDownLatch.await();

	waitUntilExternalizedCheckpointCreated(checkpointDir, initialJobGraph.getJobID());
	client.cancel(initialJobGraph.getJobID());
	waitUntilCanceled(initialJobGraph.getJobID(), client);

	return getExternalizedCheckpointCheckpointPath(checkpointDir, initialJobGraph.getJobID());
}
 
Example 27
Source Project: flink-learning   Source File: EnableCheckpointMain.java    License: Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    //创建流运行环境
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    env.getConfig().setGlobalJobParameters(ParameterTool.fromArgs(args));
    env.setParallelism(1);

    env.addSource(new SourceFunction<Long>() {
        @Override
        public void run(SourceContext<Long> sourceContext) throws Exception {
            while (true) {
                sourceContext.collect(null);
            }
        }
        @Override
        public void cancel() {
        }
    })
            .map((MapFunction<Long, Long>) aLong -> aLong / 1)
            .print();

    //开启 checkpoint
    StateBackend stateBackend = new MemoryStateBackend(5 * 1024 * 1024 * 100);
    env.enableCheckpointing(10000);
    env.setStateBackend(stateBackend);

    env.execute("zhisheng default RestartStrategy enable checkpoint example");
}
 
Example 28
Source Project: flink   Source File: AbstractStreamOperatorTestHarness.java    License: Apache License 2.0 5 votes vote down vote up
protected StreamTaskStateInitializer createStreamTaskStateManager(
	Environment env,
	StateBackend stateBackend,
	TtlTimeProvider ttlTimeProvider) {
	return new StreamTaskStateInitializerImpl(
		env,
		stateBackend,
		ttlTimeProvider);
}
 
Example 29
Source Project: flink   Source File: SchedulerTestingUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static void enableCheckpointing(final JobGraph jobGraph, @Nullable StateBackend stateBackend) {
	final List<JobVertexID> triggerVertices = new ArrayList<>();
	final List<JobVertexID> allVertices = new ArrayList<>();

	for (JobVertex vertex : jobGraph.getVertices()) {
		if (vertex.isInputVertex()) {
			triggerVertices.add(vertex.getID());
		}
		allVertices.add(vertex.getID());
	}

	final CheckpointCoordinatorConfiguration config = new CheckpointCoordinatorConfiguration(
		Long.MAX_VALUE, // disable periodical checkpointing
		DEFAULT_CHECKPOINT_TIMEOUT_MS,
		0,
		1,
		CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION,
		false,
		false,
		false,
		0);

	SerializedValue<StateBackend> serializedStateBackend = null;
	if (stateBackend != null) {
		try {
			serializedStateBackend = new SerializedValue<>(stateBackend);
		} catch (IOException e) {
			throw new RuntimeException("could not serialize state backend", e);
		}
	}

	jobGraph.setSnapshotSettings(new JobCheckpointingSettings(
			triggerVertices, allVertices, allVertices,
			config, serializedStateBackend));
}
 
Example 30
@Test
public void testNotOverridingStateBackendWithDefaultsFromConfiguration() {
	StreamExecutionEnvironment envFromConfiguration = StreamExecutionEnvironment.getExecutionEnvironment();
	envFromConfiguration.setStateBackend(new MemoryStateBackend());

	// mutate config according to configuration
	envFromConfiguration.configure(new Configuration(), Thread.currentThread().getContextClassLoader());

	StateBackend actualStateBackend = envFromConfiguration.getStateBackend();
	assertThat(actualStateBackend, instanceOf(MemoryStateBackend.class));
}