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));
}
}
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;
}
}
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();
}
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());
}
}
Aggregations