Search in sources :

Example 1 with FileSystemCheckpointStorage

use of org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage in project flink by apache.

the class CheckpointStorageLoaderTest method testLoadFileSystemCheckpointStorageMixed.

/**
 * Validates taking the application-defined file system state backend and adding with additional
 * parameters from the cluster configuration, but giving precedence to application-defined
 * parameters over configuration-defined parameters.
 */
@Test
public void testLoadFileSystemCheckpointStorageMixed() throws Exception {
    final Path appCheckpointDir = new Path(tmp.newFolder().toURI());
    final String checkpointDir = new Path(tmp.newFolder().toURI()).toString();
    final String savepointDir = new Path(tmp.newFolder().toURI()).toString();
    final Path expectedSavepointsPath = new Path(savepointDir);
    final int threshold = 1000000;
    final int writeBufferSize = 4000000;
    final FileSystemCheckpointStorage storage = new FileSystemCheckpointStorage(appCheckpointDir, threshold, writeBufferSize);
    final Configuration config = new Configuration();
    config.set(CheckpointingOptions.CHECKPOINT_STORAGE, // this should not be picked up
    "jobmanager");
    config.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, // this should not be picked up
    checkpointDir);
    config.set(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir);
    config.set(CheckpointingOptions.FS_SMALL_FILE_THRESHOLD, // this should not be picked up
    MemorySize.parse("20"));
    config.setInteger(CheckpointingOptions.FS_WRITE_BUFFER_SIZE, // this should not be picked up
    3000000);
    final CheckpointStorage loadedStorage = CheckpointStorageLoader.load(storage, null, new ModernStateBackend(), config, cl, log);
    Assert.assertThat(loadedStorage, Matchers.instanceOf(FileSystemCheckpointStorage.class));
    final FileSystemCheckpointStorage fs = (FileSystemCheckpointStorage) loadedStorage;
    Assert.assertThat(fs.getCheckpointPath(), normalizedPath(appCheckpointDir));
    Assert.assertThat(fs.getSavepointPath(), normalizedPath(expectedSavepointsPath));
    Assert.assertEquals(threshold, fs.getMinFileSizeThreshold());
    Assert.assertEquals(writeBufferSize, fs.getWriteBufferSize());
}
Also used : Path(org.apache.flink.core.fs.Path) Configuration(org.apache.flink.configuration.Configuration) FileSystemCheckpointStorage(org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage) FileSystemCheckpointStorage(org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage) JobManagerCheckpointStorage(org.apache.flink.runtime.state.storage.JobManagerCheckpointStorage) Test(org.junit.Test)

Example 2 with FileSystemCheckpointStorage

use of org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage in project flink by apache.

the class CheckpointConfig method setCheckpointStorage.

/**
 * Configures the application to write out checkpoint snapshots to the configured directory. See
 * {@link FileSystemCheckpointStorage} for more details on checkpointing to a file system.
 *
 * @param checkpointDirectory The path to write checkpoint metadata to.
 * @see #setCheckpointStorage(String)
 */
@PublicEvolving
public void setCheckpointStorage(Path checkpointDirectory) {
    Preconditions.checkNotNull(checkpointDirectory, "Checkpoint directory must not be null");
    this.storage = new FileSystemCheckpointStorage(checkpointDirectory);
}
Also used : FileSystemCheckpointStorage(org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage) PublicEvolving(org.apache.flink.annotation.PublicEvolving)

Example 3 with FileSystemCheckpointStorage

use of org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage in project flink by apache.

the class FileSinkCompactionSwitchITCase method createJobGraph.

private JobGraph createJobGraph(String path, String cpPath, boolean compactionEnabled, boolean isFinite, SharedReference<ConcurrentHashMap<Integer, Integer>> sendCountMap) {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    Configuration config = new Configuration();
    config.set(ExecutionOptions.RUNTIME_MODE, RuntimeExecutionMode.STREAMING);
    // disable changelog state in case it's randomly enabled, since it will fail the savepoint
    config.set(StateChangelogOptions.ENABLE_STATE_CHANGE_LOG, false);
    env.configure(config, getClass().getClassLoader());
    env.enableCheckpointing(100, CheckpointingMode.EXACTLY_ONCE);
    env.setRestartStrategy(RestartStrategies.noRestart());
    env.getCheckpointConfig().setCheckpointStorage(new FileSystemCheckpointStorage(cpPath));
    env.setStateBackend(new HashMapStateBackend());
    env.addSource(new CountingTestSource(latchId, NUM_RECORDS, isFinite, sendCountMap)).setParallelism(NUM_SOURCES).sinkTo(createFileSink(path, compactionEnabled)).uid("sink").setParallelism(NUM_SINKS);
    StreamGraph streamGraph = env.getStreamGraph();
    return streamGraph.getJobGraph();
}
Also used : MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) MiniClusterResourceConfiguration(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration) Configuration(org.apache.flink.configuration.Configuration) FileSystemCheckpointStorage(org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage) StreamGraph(org.apache.flink.streaming.api.graph.StreamGraph) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) HashMapStateBackend(org.apache.flink.runtime.state.hashmap.HashMapStateBackend)

Example 4 with FileSystemCheckpointStorage

use of org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage in project flink by apache.

the class CheckpointConfig method setCheckpointStorage.

/**
 * Configures the application to write out checkpoint snapshots to the configured directory. See
 * {@link FileSystemCheckpointStorage} for more details on checkpointing to a file system.
 *
 * @param checkpointDirectory The path to write checkpoint metadata to.
 * @see #setCheckpointStorage(CheckpointStorage)
 */
@PublicEvolving
public void setCheckpointStorage(String checkpointDirectory) {
    Preconditions.checkNotNull(checkpointDirectory, "Checkpoint directory must not be null");
    this.storage = new FileSystemCheckpointStorage(checkpointDirectory);
}
Also used : FileSystemCheckpointStorage(org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage) PublicEvolving(org.apache.flink.annotation.PublicEvolving)

Example 5 with FileSystemCheckpointStorage

use of org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage in project flink by apache.

the class CheckpointConfig method setCheckpointStorage.

/**
 * Configures the application to write out checkpoint snapshots to the configured directory. See
 * {@link FileSystemCheckpointStorage} for more details on checkpointing to a file system.
 *
 * @param checkpointDirectory The path to write checkpoint metadata to.
 * @see #setCheckpointStorage(CheckpointStorage)
 */
@PublicEvolving
public void setCheckpointStorage(URI checkpointDirectory) {
    Preconditions.checkNotNull(checkpointDirectory, "Checkpoint directory must not be null");
    this.storage = new FileSystemCheckpointStorage(checkpointDirectory);
}
Also used : FileSystemCheckpointStorage(org.apache.flink.runtime.state.storage.FileSystemCheckpointStorage) PublicEvolving(org.apache.flink.annotation.PublicEvolving)

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