use of org.apache.flink.runtime.checkpoint.OperatorState in project flink by apache.
the class TestUtils method createSavepointWithOperatorState.
public static File createSavepointWithOperatorState(File savepointFile, long savepointId, OperatorID... operatorIds) throws IOException {
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;
}
use of org.apache.flink.runtime.checkpoint.OperatorState in project flink by apache.
the class OperatorCoordinatorSchedulerTest method testTakeCheckpoint.
// ------------------------------------------------------------------------
// tests for checkpointing
// ------------------------------------------------------------------------
@Test
public void testTakeCheckpoint() throws Exception {
final byte[] checkpointData = new byte[656];
new Random().nextBytes(checkpointData);
final DefaultScheduler scheduler = createSchedulerAndDeployTasks();
final TestingOperatorCoordinator coordinator = getCoordinator(scheduler);
final CompletableFuture<CompletedCheckpoint> checkpointFuture = triggerCheckpoint(scheduler);
coordinator.getLastTriggeredCheckpoint().complete(checkpointData);
acknowledgeCurrentCheckpoint(scheduler);
final OperatorState state = checkpointFuture.get().getOperatorStates().get(testOperatorId);
assertArrayEquals(checkpointData, getStateHandleContents(state.getCoordinatorState()));
}
use of org.apache.flink.runtime.checkpoint.OperatorState 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