use of org.apache.flink.state.api.runtime.metadata.SavepointMetadataV2 in project flink by apache.
the class SavepointWriter method fromExistingSavepoint.
/**
* Loads an existing savepoint. Useful if you want to modify or extend the state of an existing
* application. The savepoint will be written using the state backend defined via the clusters
* configuration.
*
* @param path The path to an existing savepoint on disk.
* @return A {@link SavepointWriter}.
* @see #fromExistingSavepoint(String, StateBackend)
* @see #withConfiguration(ConfigOption, Object)
*/
public static SavepointWriter fromExistingSavepoint(String path) throws IOException {
CheckpointMetadata metadata = SavepointLoader.loadSavepointMetadata(path);
int maxParallelism = metadata.getOperatorStates().stream().map(OperatorState::getMaxParallelism).max(Comparator.naturalOrder()).orElseThrow(() -> new RuntimeException("Savepoint must contain at least one operator state."));
SavepointMetadataV2 savepointMetadata = new SavepointMetadataV2(maxParallelism, metadata.getMasterStates(), metadata.getOperatorStates());
return new SavepointWriter(savepointMetadata, null);
}
Aggregations