Skip to content

Commit

Permalink
Handle exception when options file is not found
Browse files Browse the repository at this point in the history
Signed-off-by: Ameziane H. <[email protected]>
  • Loading branch information
ahamlat committed Dec 17, 2024
1 parent c33e5ff commit 49484ce
Showing 1 changed file with 31 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,7 @@ public RocksDBColumnarKeyValueStorage(
.forEach(trimmedSegments::remove);
columnDescriptors =
trimmedSegments.stream()
.map(
segment -> {
try {
return createColumnDescriptor(segment, configuration);
} catch (RocksDBException e) {
throw new RuntimeException(e);
}
})
.map(segment -> createColumnDescriptor(segment, configuration))
.collect(Collectors.toList());

setGlobalOptions(configuration, stats);
Expand All @@ -191,37 +184,39 @@ public RocksDBColumnarKeyValueStorage(
* @return a column family descriptor
*/
private ColumnFamilyDescriptor createColumnDescriptor(
final SegmentIdentifier segment, final RocksDBConfiguration configuration)
throws RocksDBException {

ConfigOptions configOptions = new ConfigOptions();
DBOptions dbOptions = new DBOptions();
List<ColumnFamilyDescriptor> cfDescriptors = new ArrayList<>();

String latestOptionsFileName =
OptionsUtil.getLatestOptionsFileName(
configuration.getDatabaseDir().toString(), Env.getDefault());
LOG.trace("Latest OPTIONS file detected: " + latestOptionsFileName);

String optionsFilePath =
configuration.getDatabaseDir().toString() + "/" + latestOptionsFileName;
OptionsUtil.loadOptionsFromFile(configOptions, optionsFilePath, dbOptions, cfDescriptors);

LOG.trace("RocksDB options loaded successfully from: " + optionsFilePath);

final SegmentIdentifier segment, final RocksDBConfiguration configuration) {
boolean dynamicLevelBytes = true;
if (!cfDescriptors.isEmpty()) {
Optional<ColumnFamilyOptions> matchedCfOptions = Optional.empty();
for (ColumnFamilyDescriptor descriptor : cfDescriptors) {
if (Arrays.equals(descriptor.getName(), segment.getId())) {
matchedCfOptions = Optional.of(descriptor.getOptions());
break;
try {
ConfigOptions configOptions = new ConfigOptions();
DBOptions dbOptions = new DBOptions();
List<ColumnFamilyDescriptor> cfDescriptors = new ArrayList<>();

String latestOptionsFileName =
OptionsUtil.getLatestOptionsFileName(
configuration.getDatabaseDir().toString(), Env.getDefault());
LOG.trace("Latest OPTIONS file detected: " + latestOptionsFileName);

String optionsFilePath =
configuration.getDatabaseDir().toString() + "/" + latestOptionsFileName;
OptionsUtil.loadOptionsFromFile(configOptions, optionsFilePath, dbOptions, cfDescriptors);

LOG.trace("RocksDB options loaded successfully from: " + optionsFilePath);

if (!cfDescriptors.isEmpty()) {
Optional<ColumnFamilyOptions> matchedCfOptions = Optional.empty();
for (ColumnFamilyDescriptor descriptor : cfDescriptors) {
if (Arrays.equals(descriptor.getName(), segment.getId())) {
matchedCfOptions = Optional.of(descriptor.getOptions());
break;
}
}
if (matchedCfOptions.isPresent()) {
dynamicLevelBytes = matchedCfOptions.get().levelCompactionDynamicLevelBytes();
LOG.trace("dynamicLevelBytes is set to an existing value : " + dynamicLevelBytes);
}
}
if (matchedCfOptions.isPresent()) {
dynamicLevelBytes = matchedCfOptions.get().levelCompactionDynamicLevelBytes();
LOG.trace("dynamicLevelBytes is set to an existing value : " + dynamicLevelBytes);
}
} catch (RocksDBException ex) {
// Options file is not found in the database
}
BlockBasedTableConfig basedTableConfig = createBlockBasedTableConfig(segment, configuration);

Expand Down

0 comments on commit 49484ce

Please sign in to comment.