Java Code Examples for org.apache.flink.runtime.state.StateBackendLoader#loadStateBackendFromConfig()
The following examples show how to use
org.apache.flink.runtime.state.StateBackendLoader#loadStateBackendFromConfig() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamExecutionEnvironment.java From flink with Apache License 2.0 | 5 votes |
private StateBackend loadStateBackend(ReadableConfig configuration, ClassLoader classLoader) { try { return StateBackendLoader.loadStateBackendFromConfig( configuration, classLoader, null); } catch (DynamicCodeLoadingException | IOException e) { throw new WrappingRuntimeException(e); } }
Example 2
Source File: PojoSerializerUpgradeTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public PojoSerializerUpgradeTest(String backendType) throws IOException, DynamicCodeLoadingException { Configuration config = new Configuration(); config.setString(CheckpointingOptions.STATE_BACKEND, backendType); config.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, temporaryFolder.newFolder().toURI().toString()); stateBackend = StateBackendLoader.loadStateBackendFromConfig(config, Thread.currentThread().getContextClassLoader(), null); }
Example 3
Source File: RocksDBStateBackendFactoryTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Validates loading a file system state backend with additional parameters from the cluster configuration. */ @Test public void testLoadFileSystemStateBackend() throws Exception { final String checkpointDir = new Path(tmp.newFolder().toURI()).toString(); final String savepointDir = new Path(tmp.newFolder().toURI()).toString(); final String localDir1 = tmp.newFolder().getAbsolutePath(); final String localDir2 = tmp.newFolder().getAbsolutePath(); final String localDirs = localDir1 + File.pathSeparator + localDir2; final boolean incremental = !CheckpointingOptions.INCREMENTAL_CHECKPOINTS.defaultValue(); final Path expectedCheckpointsPath = new Path(checkpointDir); final Path expectedSavepointsPath = new Path(savepointDir); // 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.setString(backendKey, "rocksdb"); config1.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir); config1.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir); config1.setString(RocksDBOptions.LOCAL_DIRECTORIES, localDirs); config1.setBoolean(CheckpointingOptions.INCREMENTAL_CHECKPOINTS, incremental); final Configuration config2 = new Configuration(); config2.setString(backendKey, RocksDBStateBackendFactory.class.getName()); config2.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir); config2.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir); config2.setString(RocksDBOptions.LOCAL_DIRECTORIES, localDirs); config2.setBoolean(CheckpointingOptions.INCREMENTAL_CHECKPOINTS, incremental); StateBackend backend1 = StateBackendLoader.loadStateBackendFromConfig(config1, cl, null); StateBackend backend2 = StateBackendLoader.loadStateBackendFromConfig(config2, cl, null); assertTrue(backend1 instanceof RocksDBStateBackend); assertTrue(backend2 instanceof RocksDBStateBackend); RocksDBStateBackend fs1 = (RocksDBStateBackend) backend1; RocksDBStateBackend fs2 = (RocksDBStateBackend) backend2; AbstractFileStateBackend fs1back = (AbstractFileStateBackend) fs1.getCheckpointBackend(); AbstractFileStateBackend fs2back = (AbstractFileStateBackend) fs2.getCheckpointBackend(); assertEquals(expectedCheckpointsPath, fs1back.getCheckpointPath()); assertEquals(expectedCheckpointsPath, fs2back.getCheckpointPath()); assertEquals(expectedSavepointsPath, fs1back.getSavepointPath()); assertEquals(expectedSavepointsPath, fs2back.getSavepointPath()); assertEquals(incremental, fs1.isIncrementalCheckpointsEnabled()); assertEquals(incremental, fs2.isIncrementalCheckpointsEnabled()); checkPaths(fs1.getDbStoragePaths(), localDir1, localDir2); checkPaths(fs2.getDbStoragePaths(), localDir1, localDir2); }
Example 4
Source File: PojoSerializerUpgradeTest.java From flink with Apache License 2.0 | 4 votes |
public PojoSerializerUpgradeTest(String backendType) throws IOException, DynamicCodeLoadingException { Configuration config = new Configuration(); config.setString(CheckpointingOptions.STATE_BACKEND, backendType); config.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, temporaryFolder.newFolder().toURI().toString()); stateBackend = StateBackendLoader.loadStateBackendFromConfig(config, Thread.currentThread().getContextClassLoader(), null); }
Example 5
Source File: RocksDBStateBackendFactoryTest.java From flink with Apache License 2.0 | 4 votes |
/** * Validates loading a file system state backend with additional parameters from the cluster configuration. */ @Test public void testLoadFileSystemStateBackend() throws Exception { final String checkpointDir = new Path(tmp.newFolder().toURI()).toString(); final String savepointDir = new Path(tmp.newFolder().toURI()).toString(); final String localDir1 = tmp.newFolder().getAbsolutePath(); final String localDir2 = tmp.newFolder().getAbsolutePath(); final String localDirs = localDir1 + File.pathSeparator + localDir2; final boolean incremental = !CheckpointingOptions.INCREMENTAL_CHECKPOINTS.defaultValue(); final Path expectedCheckpointsPath = new Path(checkpointDir); final Path expectedSavepointsPath = new Path(savepointDir); // 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.setString(backendKey, "rocksdb"); config1.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir); config1.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir); config1.setString(RocksDBOptions.LOCAL_DIRECTORIES, localDirs); config1.setBoolean(CheckpointingOptions.INCREMENTAL_CHECKPOINTS, incremental); final Configuration config2 = new Configuration(); config2.setString(backendKey, RocksDBStateBackendFactory.class.getName()); config2.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir); config2.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir); config2.setString(RocksDBOptions.LOCAL_DIRECTORIES, localDirs); config2.setBoolean(CheckpointingOptions.INCREMENTAL_CHECKPOINTS, incremental); StateBackend backend1 = StateBackendLoader.loadStateBackendFromConfig(config1, cl, null); StateBackend backend2 = StateBackendLoader.loadStateBackendFromConfig(config2, cl, null); assertTrue(backend1 instanceof RocksDBStateBackend); assertTrue(backend2 instanceof RocksDBStateBackend); RocksDBStateBackend fs1 = (RocksDBStateBackend) backend1; RocksDBStateBackend fs2 = (RocksDBStateBackend) backend2; AbstractFileStateBackend fs1back = (AbstractFileStateBackend) fs1.getCheckpointBackend(); AbstractFileStateBackend fs2back = (AbstractFileStateBackend) fs2.getCheckpointBackend(); assertEquals(expectedCheckpointsPath, fs1back.getCheckpointPath()); assertEquals(expectedCheckpointsPath, fs2back.getCheckpointPath()); assertEquals(expectedSavepointsPath, fs1back.getSavepointPath()); assertEquals(expectedSavepointsPath, fs2back.getSavepointPath()); assertEquals(incremental, fs1.isIncrementalCheckpointsEnabled()); assertEquals(incremental, fs2.isIncrementalCheckpointsEnabled()); checkPaths(fs1.getDbStoragePaths(), localDir1, localDir2); checkPaths(fs2.getDbStoragePaths(), localDir1, localDir2); }
Example 6
Source File: PojoSerializerUpgradeTest.java From flink with Apache License 2.0 | 4 votes |
public PojoSerializerUpgradeTest(String backendType) throws IOException, DynamicCodeLoadingException { Configuration config = new Configuration(); config.setString(CheckpointingOptions.STATE_BACKEND, backendType); config.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, temporaryFolder.newFolder().toURI().toString()); stateBackend = StateBackendLoader.loadStateBackendFromConfig(config, Thread.currentThread().getContextClassLoader(), null); }
Example 7
Source File: RocksDBStateBackendFactoryTest.java From flink with Apache License 2.0 | 4 votes |
/** * Validates loading a file system state backend with additional parameters from the cluster configuration. */ @Test public void testLoadFileSystemStateBackend() throws Exception { final String checkpointDir = new Path(tmp.newFolder().toURI()).toString(); final String savepointDir = new Path(tmp.newFolder().toURI()).toString(); final String localDir1 = tmp.newFolder().getAbsolutePath(); final String localDir2 = tmp.newFolder().getAbsolutePath(); final String localDirs = localDir1 + File.pathSeparator + localDir2; final boolean incremental = !CheckpointingOptions.INCREMENTAL_CHECKPOINTS.defaultValue(); final Path expectedCheckpointsPath = new Path(checkpointDir); final Path expectedSavepointsPath = new Path(savepointDir); // 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.setString(backendKey, "rocksdb"); config1.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir); config1.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir); config1.setString(RocksDBOptions.LOCAL_DIRECTORIES, localDirs); config1.setBoolean(CheckpointingOptions.INCREMENTAL_CHECKPOINTS, incremental); final Configuration config2 = new Configuration(); config2.setString(backendKey, RocksDBStateBackendFactory.class.getName()); config2.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, checkpointDir); config2.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir); config2.setString(RocksDBOptions.LOCAL_DIRECTORIES, localDirs); config2.setBoolean(CheckpointingOptions.INCREMENTAL_CHECKPOINTS, incremental); StateBackend backend1 = StateBackendLoader.loadStateBackendFromConfig(config1, cl, null); StateBackend backend2 = StateBackendLoader.loadStateBackendFromConfig(config2, cl, null); assertTrue(backend1 instanceof RocksDBStateBackend); assertTrue(backend2 instanceof RocksDBStateBackend); RocksDBStateBackend fs1 = (RocksDBStateBackend) backend1; RocksDBStateBackend fs2 = (RocksDBStateBackend) backend2; AbstractFileStateBackend fs1back = (AbstractFileStateBackend) fs1.getCheckpointBackend(); AbstractFileStateBackend fs2back = (AbstractFileStateBackend) fs2.getCheckpointBackend(); assertEquals(expectedCheckpointsPath, fs1back.getCheckpointPath()); assertEquals(expectedCheckpointsPath, fs2back.getCheckpointPath()); assertEquals(expectedSavepointsPath, fs1back.getSavepointPath()); assertEquals(expectedSavepointsPath, fs2back.getSavepointPath()); assertEquals(incremental, fs1.isIncrementalCheckpointsEnabled()); assertEquals(incremental, fs2.isIncrementalCheckpointsEnabled()); checkPaths(fs1.getDbStoragePaths(), localDir1, localDir2); checkPaths(fs2.getDbStoragePaths(), localDir1, localDir2); }