Search in sources :

Example 1 with RocksObject

use of org.rocksdb.RocksObject in project flink by apache.

the class RocksDBStateBackendTest method testRunningSnapshotAfterBackendClosed.

@Test
public void testRunningSnapshotAfterBackendClosed() throws Exception {
    setupRocksKeyedStateBackend();
    RunnableFuture<KeyGroupsStateHandle> snapshot = keyedStateBackend.snapshot(0L, 0L, testStreamFactory, CheckpointOptions.forFullCheckpoint());
    RocksDB spyDB = keyedStateBackend.db;
    verify(spyDB, times(1)).getSnapshot();
    verify(spyDB, times(0)).releaseSnapshot(any(Snapshot.class));
    this.keyedStateBackend.dispose();
    verify(spyDB, times(1)).close();
    assertEquals(null, keyedStateBackend.db);
    //Ensure every RocksObjects not closed yet
    for (RocksObject rocksCloseable : allCreatedCloseables) {
        verify(rocksCloseable, times(0)).close();
    }
    Thread asyncSnapshotThread = new Thread(snapshot);
    asyncSnapshotThread.start();
    try {
        snapshot.get();
        fail();
    } catch (Exception ignored) {
    }
    asyncSnapshotThread.join();
    //Ensure every RocksObject was closed exactly once
    for (RocksObject rocksCloseable : allCreatedCloseables) {
        verify(rocksCloseable, times(1)).close();
    }
}
Also used : Snapshot(org.rocksdb.Snapshot) RocksDB(org.rocksdb.RocksDB) RocksObject(org.rocksdb.RocksObject) KeyGroupsStateHandle(org.apache.flink.runtime.state.KeyGroupsStateHandle) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with RocksObject

use of org.rocksdb.RocksObject in project flink by apache.

the class RocksDBStateBackendTest method verifyRocksObjectsReleased.

private void verifyRocksObjectsReleased() {
    //Ensure every RocksObject was closed exactly once
    for (RocksObject rocksCloseable : allCreatedCloseables) {
        verify(rocksCloseable, times(1)).close();
    }
    assertNotNull(null, keyedStateBackend.db);
    RocksDB spyDB = keyedStateBackend.db;
    verify(spyDB, times(1)).getSnapshot();
    verify(spyDB, times(1)).releaseSnapshot(any(Snapshot.class));
    keyedStateBackend.dispose();
    verify(spyDB, times(1)).close();
    assertEquals(null, keyedStateBackend.db);
}
Also used : Snapshot(org.rocksdb.Snapshot) RocksDB(org.rocksdb.RocksDB) RocksObject(org.rocksdb.RocksObject)

Example 3 with RocksObject

use of org.rocksdb.RocksObject in project flink by apache.

the class RocksDBStateBackendTest method testReleasingSnapshotAfterBackendClosed.

@Test
public void testReleasingSnapshotAfterBackendClosed() throws Exception {
    setupRocksKeyedStateBackend();
    RunnableFuture<KeyGroupsStateHandle> snapshot = keyedStateBackend.snapshot(0L, 0L, testStreamFactory, CheckpointOptions.forFullCheckpoint());
    RocksDB spyDB = keyedStateBackend.db;
    verify(spyDB, times(1)).getSnapshot();
    verify(spyDB, times(0)).releaseSnapshot(any(Snapshot.class));
    this.keyedStateBackend.dispose();
    verify(spyDB, times(1)).close();
    assertEquals(null, keyedStateBackend.db);
    //Ensure every RocksObjects not closed yet
    for (RocksObject rocksCloseable : allCreatedCloseables) {
        verify(rocksCloseable, times(0)).close();
    }
    snapshot.cancel(true);
    //Ensure every RocksObjects was closed exactly once
    for (RocksObject rocksCloseable : allCreatedCloseables) {
        verify(rocksCloseable, times(1)).close();
    }
}
Also used : Snapshot(org.rocksdb.Snapshot) RocksDB(org.rocksdb.RocksDB) RocksObject(org.rocksdb.RocksObject) KeyGroupsStateHandle(org.apache.flink.runtime.state.KeyGroupsStateHandle) Test(org.junit.Test)

Aggregations

RocksDB (org.rocksdb.RocksDB)3 RocksObject (org.rocksdb.RocksObject)3 Snapshot (org.rocksdb.Snapshot)3 KeyGroupsStateHandle (org.apache.flink.runtime.state.KeyGroupsStateHandle)2 Test (org.junit.Test)2 IOException (java.io.IOException)1