コード例 #1
0
  /**
   * This tests whether the RocksDB backends uses the temp directories that are provided from the
   * {@link Environment} when no db storage path is set.
   *
   * @throws Exception
   */
  @Test
  public void testUseTempDirectories() throws Exception {
    String checkpointPath = tempFolder.newFolder().toURI().toString();
    RocksDBStateBackend rocksDbBackend = new RocksDBStateBackend(checkpointPath);

    File dir1 = tempFolder.newFolder();
    File dir2 = tempFolder.newFolder();

    File[] tempDirs = new File[] {dir1, dir2};

    assertNull(rocksDbBackend.getDbStoragePaths());

    Environment env = getMockEnvironment(tempDirs);
    RocksDBKeyedStateBackend<Integer> keyedBackend =
        (RocksDBKeyedStateBackend<Integer>)
            rocksDbBackend.createKeyedStateBackend(
                env,
                env.getJobID(),
                "test_op",
                IntSerializer.INSTANCE,
                1,
                new KeyGroupRange(0, 0),
                env.getTaskKvStateRegistry());

    File instanceBasePath = keyedBackend.getInstanceBasePath();
    assertThat(
        instanceBasePath.getAbsolutePath(),
        anyOf(startsWith(dir1.getAbsolutePath()), startsWith(dir2.getAbsolutePath())));
  }
コード例 #2
0
  @Test
  public void testSetDbPath() throws Exception {
    String checkpointPath = tempFolder.newFolder().toURI().toString();
    File testDir1 = tempFolder.newFolder();
    File testDir2 = tempFolder.newFolder();

    RocksDBStateBackend rocksDbBackend = new RocksDBStateBackend(checkpointPath);

    assertNull(rocksDbBackend.getDbStoragePaths());

    rocksDbBackend.setDbStoragePath(testDir1.getAbsolutePath());
    assertArrayEquals(
        new String[] {testDir1.getAbsolutePath()}, rocksDbBackend.getDbStoragePaths());

    rocksDbBackend.setDbStoragePath(null);
    assertNull(rocksDbBackend.getDbStoragePaths());

    rocksDbBackend.setDbStoragePaths(testDir1.getAbsolutePath(), testDir2.getAbsolutePath());
    assertArrayEquals(
        new String[] {testDir1.getAbsolutePath(), testDir2.getAbsolutePath()},
        rocksDbBackend.getDbStoragePaths());

    Environment env = getMockEnvironment(new File[] {});
    RocksDBKeyedStateBackend<Integer> keyedBackend =
        (RocksDBKeyedStateBackend<Integer>)
            rocksDbBackend.createKeyedStateBackend(
                env,
                env.getJobID(),
                "test_op",
                IntSerializer.INSTANCE,
                1,
                new KeyGroupRange(0, 0),
                env.getTaskKvStateRegistry());

    File instanceBasePath = keyedBackend.getInstanceBasePath();
    assertThat(
        instanceBasePath.getAbsolutePath(),
        anyOf(startsWith(testDir1.getAbsolutePath()), startsWith(testDir2.getAbsolutePath())));

    //noinspection NullArgumentToVariableArgMethod
    rocksDbBackend.setDbStoragePaths(null);
    assertNull(rocksDbBackend.getDbStoragePaths());
  }