use of org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage in project flink by apache.
the class CheckpointStorageLoaderTest method testLoadFileSystemCheckpointStorage.
// ------------------------------------------------------------------------
// File System Checkpoint Storage
// ------------------------------------------------------------------------
/**
* Validates loading a file system checkpoint storage with additional parameters from the
* cluster configuration.
*/
@Test
public void testLoadFileSystemCheckpointStorage() throws Exception {
final String checkpointDir = new Path(tmp.newFolder().toURI()).toString();
final String savepointDir = new Path(tmp.newFolder().toURI()).toString();
final Path expectedCheckpointsPath = new Path(checkpointDir);
final Path expectedSavepointsPath = new Path(savepointDir);
final MemorySize threshold = MemorySize.parse("900kb");
final int minWriteBufferSize = 1024;
// we configure with the explicit string (rather than
// AbstractStateBackend#X_STATE_BACKEND_NAME)
// to guard against config-breaking changes of the name
final Configuration config1 = new Configuration();
config1.set(CheckpointingOptions.CHECKPOINT_STORAGE, "filesystem");
config1.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir);
config1.set(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir);
config1.set(CheckpointingOptions.FS_SMALL_FILE_THRESHOLD, threshold);
config1.setInteger(CheckpointingOptions.FS_WRITE_BUFFER_SIZE, minWriteBufferSize);
CheckpointStorage storage1 = CheckpointStorageLoader.fromConfig(config1, cl, null).get();
Assert.assertThat(storage1, Matchers.instanceOf(FileSystemCheckpointStorage.class));
FileSystemCheckpointStorage fs1 = (FileSystemCheckpointStorage) storage1;
Assert.assertThat(fs1.getCheckpointPath(), normalizedPath(expectedCheckpointsPath));
Assert.assertThat(fs1.getSavepointPath(), normalizedPath(expectedSavepointsPath));
Assert.assertEquals(threshold.getBytes(), fs1.getMinFileSizeThreshold());
Assert.assertEquals(Math.max(threshold.getBytes(), minWriteBufferSize), fs1.getWriteBufferSize());
}
Aggregations