Search in sources :

Example 6 with WriteBufferManager

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

the class RocksDBResourceContainerTest method getWriteBufferManager.

private WriteBufferManager getWriteBufferManager(DBOptions dbOptions) {
    Field writeBufferManagerField = null;
    try {
        writeBufferManagerField = DBOptions.class.getDeclaredField("writeBufferManager_");
    } catch (NoSuchFieldException e) {
        fail("writeBufferManager_ is not defined.");
    }
    writeBufferManagerField.setAccessible(true);
    try {
        return (WriteBufferManager) writeBufferManagerField.get(dbOptions);
    } catch (IllegalAccessException e) {
        fail("Cannot access writeBufferManager_ field.");
        return null;
    }
}
Also used : Field(java.lang.reflect.Field) WriteBufferManager(org.rocksdb.WriteBufferManager) DBOptions(org.rocksdb.DBOptions)

Example 7 with WriteBufferManager

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

the class RocksDBResourceContainerTest method testGetDbOptionsWithSharedResources.

/**
 * Guard that {@link RocksDBResourceContainer#getDbOptions()} shares the same {@link
 * WriteBufferManager} instance if the {@link RocksDBResourceContainer} instance is initiated
 * with {@link OpaqueMemoryResource}.
 *
 * @throws Exception if unexpected error happened.
 */
@Test
public void testGetDbOptionsWithSharedResources() throws Exception {
    final int optionNumber = 20;
    OpaqueMemoryResource<RocksDBSharedResources> sharedResources = getSharedResources();
    RocksDBResourceContainer container = new RocksDBResourceContainer(PredefinedOptions.DEFAULT, null, sharedResources);
    HashSet<WriteBufferManager> writeBufferManagers = new HashSet<>();
    for (int i = 0; i < optionNumber; i++) {
        DBOptions dbOptions = container.getDbOptions();
        WriteBufferManager writeBufferManager = getWriteBufferManager(dbOptions);
        writeBufferManagers.add(writeBufferManager);
    }
    assertThat(writeBufferManagers.size(), is(1));
    assertThat(writeBufferManagers.iterator().next(), is(sharedResources.getResourceHandle().getWriteBufferManager()));
    container.close();
}
Also used : WriteBufferManager(org.rocksdb.WriteBufferManager) DBOptions(org.rocksdb.DBOptions) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

WriteBufferManager (org.rocksdb.WriteBufferManager)7 LRUCache (org.rocksdb.LRUCache)5 Test (org.junit.Test)4 IOException (java.io.IOException)3 OpaqueMemoryResource (org.apache.flink.runtime.memory.OpaqueMemoryResource)3 DBOptions (org.rocksdb.DBOptions)3 Cache (org.rocksdb.Cache)2 Field (java.lang.reflect.Field)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 CoreMatchers.is (org.hamcrest.CoreMatchers.is)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1 TemporaryFolder (org.junit.rules.TemporaryFolder)1 RunWith (org.junit.runner.RunWith)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1