use of org.apache.flink.runtime.checkpoint.metadata.CheckpointMetadata in project flink by apache.
the class CheckpointMetadataLoadingTest method createSavepointWithOperatorState.
// ------------------------------------------------------------------------
// setup utils
// ------------------------------------------------------------------------
private static CompletedCheckpointStorageLocation createSavepointWithOperatorState(final long checkpointId, final OperatorState state) throws IOException {
final CheckpointMetadata savepoint = new CheckpointMetadata(checkpointId, Collections.singletonList(state), Collections.emptyList());
final StreamStateHandle serializedMetadata;
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
Checkpoints.storeCheckpointMetadata(savepoint, os);
serializedMetadata = new ByteStreamStateHandle("checkpoint", os.toByteArray());
}
return new TestCompletedCheckpointStorageLocation(serializedMetadata, "dummy/pointer");
}
use of org.apache.flink.runtime.checkpoint.metadata.CheckpointMetadata in project flink by apache.
the class SavepointFormatITCase method testTriggerSavepointAndResumeWithFileBasedCheckpointsAndRelocateBasePath.
@ParameterizedTest(name = "[{index}] {0}, {1}")
@MethodSource("parameters")
public void testTriggerSavepointAndResumeWithFileBasedCheckpointsAndRelocateBasePath(SavepointFormatType formatType, StateBackendConfig stateBackendConfig) throws Exception {
final int numTaskManagers = 2;
final int numSlotsPerTaskManager = 2;
final Configuration config = stateBackendConfig.getConfiguration();
config.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointsDir.toUri().toString());
final MiniClusterWithClientResource miniClusterResource = new MiniClusterWithClientResource(new MiniClusterResourceConfiguration.Builder().setConfiguration(config).setNumberTaskManagers(numTaskManagers).setNumberSlotsPerTaskManager(numSlotsPerTaskManager).build());
miniClusterResource.before();
try {
final String savepointPath = submitJobAndTakeSavepoint(miniClusterResource, formatType, stateBackendConfig.getCheckpointsBeforeSavepoint(), config);
final CheckpointMetadata metadata = loadCheckpointMetadata(savepointPath);
final OperatorState operatorState = metadata.getOperatorStates().stream().filter(hasKeyedState()).findFirst().get();
operatorState.getStates().stream().flatMap(subtaskState -> subtaskState.getManagedKeyedState().stream()).forEach(handle -> validateState(handle, formatType, stateBackendConfig));
relocateAndVerify(miniClusterResource, savepointPath, renamedSavepointDir, config);
} finally {
miniClusterResource.after();
}
}
Aggregations