Search in sources :

Example 26 with DBOptions

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

the class RocksDBResourceContainerTest method testFreeMultipleDBOptionsAfterClose.

@Test
public void testFreeMultipleDBOptionsAfterClose() throws Exception {
    RocksDBResourceContainer container = new RocksDBResourceContainer();
    final int optionNumber = 20;
    ArrayList<DBOptions> dbOptions = new ArrayList<>(optionNumber);
    for (int i = 0; i < optionNumber; i++) {
        dbOptions.add(container.getDbOptions());
    }
    container.close();
    for (DBOptions dbOption : dbOptions) {
        assertThat(dbOption.isOwningHandle(), is(false));
    }
}
Also used : ArrayList(java.util.ArrayList) DBOptions(org.rocksdb.DBOptions) Test(org.junit.Test)

Example 27 with DBOptions

use of org.rocksdb.DBOptions 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 28 with DBOptions

use of org.rocksdb.DBOptions 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)

Example 29 with DBOptions

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

the class RocksDBStateBackendConfigTest method testPredefinedAndOptionsFactory.

@Test
public void testPredefinedAndOptionsFactory() throws Exception {
    final RocksDBOptionsFactory optionsFactory = new RocksDBOptionsFactory() {

        @Override
        public DBOptions createDBOptions(DBOptions currentOptions, Collection<AutoCloseable> handlesToClose) {
            return currentOptions;
        }

        @Override
        public ColumnFamilyOptions createColumnOptions(ColumnFamilyOptions currentOptions, Collection<AutoCloseable> handlesToClose) {
            return currentOptions.setCompactionStyle(CompactionStyle.UNIVERSAL);
        }
    };
    try (final RocksDBResourceContainer optionsContainer = new RocksDBResourceContainer(PredefinedOptions.SPINNING_DISK_OPTIMIZED, optionsFactory)) {
        final ColumnFamilyOptions columnFamilyOptions = optionsContainer.getColumnOptions();
        assertNotNull(columnFamilyOptions);
        assertEquals(CompactionStyle.UNIVERSAL, columnFamilyOptions.compactionStyle());
    }
}
Also used : ColumnFamilyOptions(org.rocksdb.ColumnFamilyOptions) Collection(java.util.Collection) DBOptions(org.rocksdb.DBOptions) Test(org.junit.Test)

Aggregations

DBOptions (org.rocksdb.DBOptions)29 ColumnFamilyOptions (org.rocksdb.ColumnFamilyOptions)19 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)10 ColumnFamilyDescriptor (org.rocksdb.ColumnFamilyDescriptor)10 ColumnFamilyHandle (org.rocksdb.ColumnFamilyHandle)9 File (java.io.File)7 RocksDB (org.rocksdb.RocksDB)7 RocksDBException (org.rocksdb.RocksDBException)5 WriteOptions (org.rocksdb.WriteOptions)5 IOException (java.io.IOException)4 FlushOptions (org.rocksdb.FlushOptions)4 Options (org.rocksdb.Options)3 RocksDbOptionsFactory (com.alibaba.jstorm.cache.rocksdb.RocksDbOptionsFactory)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Collection (java.util.Collection)2 List (java.util.List)2 Map (java.util.Map)2 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)2 JobID (org.apache.flink.api.common.JobID)2