Search in sources :

Example 26 with ColumnFamilyOptions

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

the class RocksDBResourceContainerTest method testFreeMultipleColumnOptionsAfterClose.

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

Example 27 with ColumnFamilyOptions

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

the class RocksDBResourceContainerTest method testFreeColumnOptionsAfterClose.

@Test
public void testFreeColumnOptionsAfterClose() throws Exception {
    RocksDBResourceContainer container = new RocksDBResourceContainer();
    ColumnFamilyOptions columnFamilyOptions = container.getColumnOptions();
    assertThat(columnFamilyOptions.isOwningHandle(), is(true));
    container.close();
    assertThat(columnFamilyOptions.isOwningHandle(), is(false));
}
Also used : ColumnFamilyOptions(org.rocksdb.ColumnFamilyOptions) Test(org.junit.Test)

Example 28 with ColumnFamilyOptions

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

Example 29 with ColumnFamilyOptions

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

the class RocksDBStateBackendConfigTest method testPredefinedAndConfigurableOptions.

@Test
public void testPredefinedAndConfigurableOptions() throws Exception {
    Configuration configuration = new Configuration();
    configuration.set(RocksDBConfigurableOptions.COMPACTION_STYLE, CompactionStyle.UNIVERSAL);
    try (final RocksDBResourceContainer optionsContainer = new RocksDBResourceContainer(configuration, PredefinedOptions.SPINNING_DISK_OPTIMIZED, null, null)) {
        final ColumnFamilyOptions columnFamilyOptions = optionsContainer.getColumnOptions();
        assertNotNull(columnFamilyOptions);
        assertEquals(CompactionStyle.UNIVERSAL, columnFamilyOptions.compactionStyle());
    }
    try (final RocksDBResourceContainer optionsContainer = new RocksDBResourceContainer(new Configuration(), PredefinedOptions.SPINNING_DISK_OPTIMIZED, null, null)) {
        final ColumnFamilyOptions columnFamilyOptions = optionsContainer.getColumnOptions();
        assertNotNull(columnFamilyOptions);
        assertEquals(CompactionStyle.LEVEL, columnFamilyOptions.compactionStyle());
    }
}
Also used : ColumnFamilyOptions(org.rocksdb.ColumnFamilyOptions) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Aggregations

ColumnFamilyOptions (org.rocksdb.ColumnFamilyOptions)29 DBOptions (org.rocksdb.DBOptions)19 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)9 ColumnFamilyDescriptor (org.rocksdb.ColumnFamilyDescriptor)9 File (java.io.File)8 ColumnFamilyHandle (org.rocksdb.ColumnFamilyHandle)8 RocksDB (org.rocksdb.RocksDB)8 WriteOptions (org.rocksdb.WriteOptions)6 IOException (java.io.IOException)4 FlushOptions (org.rocksdb.FlushOptions)4 RocksDBException (org.rocksdb.RocksDBException)4 LRUCache (org.rocksdb.LRUCache)3 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