Java Code Examples for org.apache.flink.runtime.checkpoint.Checkpoints#storeCheckpointMetadata()

The following examples show how to use org.apache.flink.runtime.checkpoint.Checkpoints#storeCheckpointMetadata() . 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: JobMasterTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private File createSavepointWithOperatorState(long savepointId, OperatorID... operatorIds) throws IOException {
	final File savepointFile = temporaryFolder.newFile();
	final Collection<OperatorState> operatorStates = createOperatorState(operatorIds);
	final SavepointV2 savepoint = new SavepointV2(savepointId, operatorStates, Collections.emptyList());

	try (FileOutputStream fileOutputStream = new FileOutputStream(savepointFile)) {
		Checkpoints.storeCheckpointMetadata(savepoint, fileOutputStream);
	}

	return savepointFile;
}
 
Example 5
Source File: JobMasterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private File createSavepointWithOperatorState(long savepointId, OperatorID... operatorIds) throws IOException {
	final File savepointFile = temporaryFolder.newFile();
	final Collection<OperatorState> operatorStates = createOperatorState(operatorIds);
	final SavepointV2 savepoint = new SavepointV2(savepointId, operatorStates, Collections.emptyList());

	try (FileOutputStream fileOutputStream = new FileOutputStream(savepointFile)) {
		Checkpoints.storeCheckpointMetadata(savepoint, fileOutputStream);
	}

	return savepointFile;
}
 
Example 6
Source File: JobMasterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private File createSavepointWithOperatorState(long savepointId, OperatorID... operatorIds) throws IOException {
	final File savepointFile = temporaryFolder.newFile();
	final Collection<OperatorState> operatorStates = createOperatorState(operatorIds);
	final CheckpointMetadata savepoint = new CheckpointMetadata(savepointId, operatorStates, Collections.emptyList());

	try (FileOutputStream fileOutputStream = new FileOutputStream(savepointFile)) {
		Checkpoints.storeCheckpointMetadata(savepoint, fileOutputStream);
	}

	return savepointFile;
}
 
Example 7
Source File: OperatorCoordinatorSchedulerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static byte[] serializeAsCheckpointMetadata(OperatorID id, byte[] coordinatorState) throws IOException {
	final OperatorState state = createOperatorState(id, coordinatorState);
	final CheckpointMetadata metadata = new CheckpointMetadata(
		1337L, Collections.singletonList(state), Collections.emptyList());

	final ByteArrayOutputStream out = new ByteArrayOutputStream();
	Checkpoints.storeCheckpointMetadata(metadata, out);
	return out.toByteArray();
}
 
Example 8
Source File: StateMetadataUtils.java    From bravo with Apache License 2.0 4 votes vote down vote up
public static Path writeSavepointMetadata(Path newCheckpointBasePath, Savepoint savepoint) throws IOException {
	Path p = new Path(newCheckpointBasePath, AbstractFsCheckpointStorage.METADATA_FILE_NAME);
	Checkpoints.storeCheckpointMetadata(savepoint,
			newCheckpointBasePath.getFileSystem().create(p, WriteMode.NO_OVERWRITE));
	return p;
}