Java Code Examples for org.apache.flink.runtime.state.StateBackend#createCheckpointStorage()

The following examples show how to use org.apache.flink.runtime.state.StateBackend#createCheckpointStorage() . 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
Source File: DispatcherTest.java    From Flink-CEPplus with 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 2
Source File: DispatcherTest.java    From flink with 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 3
Source File: DispatcherTest.java    From flink with 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 CheckpointMetadata(checkpointId, Collections.emptyList(), Collections.emptyList()), metadataOutputStream);

	final CompletedCheckpointStorageLocation completedCheckpointStorageLocation = metadataOutputStream.closeAndFinalizeCheckpoint();

	return new URI(completedCheckpointStorageLocation.getExternalPointer());

}
 
Example 4
Source File: MockStreamTaskBuilder.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public MockStreamTaskBuilder(Environment environment) throws Exception {
	this.environment = environment;

	StateBackend stateBackend = new MemoryStateBackend();
	this.checkpointStorage = stateBackend.createCheckpointStorage(new JobID());
	this.streamTaskStateInitializer = new StreamTaskStateInitializerImpl(environment, stateBackend, processingTimeService);
}
 
Example 5
Source File: AbstractStreamOperatorTestHarness.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public void setStateBackend(StateBackend stateBackend) {
	this.stateBackend = stateBackend;

	try {
		this.checkpointStorage = stateBackend.createCheckpointStorage(new JobID());
	} catch (IOException e) {
		throw new RuntimeException(e.getMessage(), e);
	}
}
 
Example 6
Source File: MockStreamTaskBuilder.java    From flink with Apache License 2.0 5 votes vote down vote up
public MockStreamTaskBuilder(Environment environment) throws Exception {
	this.environment = environment;

	StateBackend stateBackend = new MemoryStateBackend();
	this.checkpointStorage = stateBackend.createCheckpointStorage(new JobID());
	this.streamTaskStateInitializer = new StreamTaskStateInitializerImpl(environment, stateBackend, processingTimeService);
}
 
Example 7
Source File: AbstractStreamOperatorTestHarness.java    From flink with Apache License 2.0 5 votes vote down vote up
public void setStateBackend(StateBackend stateBackend) {
	this.stateBackend = stateBackend;

	try {
		this.checkpointStorage = stateBackend.createCheckpointStorage(new JobID());
	} catch (IOException e) {
		throw new RuntimeException(e.getMessage(), e);
	}
}
 
Example 8
Source File: MockStreamTaskBuilder.java    From flink with 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 9
Source File: AbstractStreamOperatorTestHarness.java    From flink with Apache License 2.0 5 votes vote down vote up
public void setStateBackend(StateBackend stateBackend) {
	this.stateBackend = stateBackend;

	try {
		this.checkpointStorage = stateBackend.createCheckpointStorage(new JobID());
	} catch (IOException e) {
		throw new RuntimeException(e.getMessage(), e);
	}
}