Search in sources :

Example 6 with FileSystemCheckpointStorage

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());
}
Also used : Path(org.apache.flink.core.fs.Path) MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) FileSystemCheckpointStorage(org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage) JobManagerCheckpointStorage(org.apache.flink.runtime.state.storage.JobManagerCheckpointStorage) FileSystemCheckpointStorage(org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage) Test(org.junit.Test)

Aggregations

FileSystemCheckpointStorage (org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage)6 PublicEvolving (org.apache.flink.annotation.PublicEvolving)3 Configuration (org.apache.flink.configuration.Configuration)3 Path (org.apache.flink.core.fs.Path)2 JobManagerCheckpointStorage (org.apache.flink.runtime.state.storage.JobManagerCheckpointStorage)2 Test (org.junit.Test)2 MemorySize (org.apache.flink.configuration.MemorySize)1 MiniClusterConfiguration (org.apache.flink.runtime.minicluster.MiniClusterConfiguration)1 HashMapStateBackend (org.apache.flink.runtime.state.hashmap.HashMapStateBackend)1 MiniClusterResourceConfiguration (org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration)1 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 StreamGraph (org.apache.flink.streaming.api.graph.StreamGraph)1