Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.common.collect.Lists;
import java.io.File;
import java.net.URL;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;
import org.apache.bookkeeper.bookie.FileChannelProvider;
import org.apache.bookkeeper.bookie.InterleavedLedgerStorage;
Expand Down Expand Up @@ -4049,12 +4050,8 @@ public boolean isSkipReplayJournalInvalidRecord() {
* @return String configured default rocksdb conf.
*/
public String getDefaultRocksDBConf() {
String defaultPath = "conf/default_rocksdb.conf";
URL defURL = getClass().getClassLoader().getResource(defaultPath);
if (defURL != null) {
defaultPath = defURL.getPath();
}
return getString(DEFAULT_ROCKSDB_CONF, defaultPath);
String filePath = getFilePath("conf/default_rocksdb.conf");
return getString(DEFAULT_ROCKSDB_CONF, filePath);
}

/**
Expand All @@ -4073,12 +4070,8 @@ public ServerConfiguration setDefaultRocksDBConf(String defaultRocksdbConf) {
* @return String configured entry Location rocksdb conf.
*/
public String getEntryLocationRocksdbConf() {
String defaultPath = "conf/entry_location_rocksdb.conf";
URL defURL = getClass().getClassLoader().getResource(defaultPath);
if (defURL != null) {
defaultPath = defURL.getPath();
}
return getString(ENTRY_LOCATION_ROCKSDB_CONF, defaultPath);
String filePath = getFilePath("conf/entry_location_rocksdb.conf");
return getString(ENTRY_LOCATION_ROCKSDB_CONF, filePath);
}

/**
Expand All @@ -4097,12 +4090,8 @@ public ServerConfiguration setEntryLocationRocksdbConf(String entryLocationRocks
* @return String configured ledger metadata rocksdb conf.
*/
public String getLedgerMetadataRocksdbConf() {
String defaultPath = "conf/ledger_metadata_rocksdb.conf";
URL defURL = getClass().getClassLoader().getResource(defaultPath);
if (defURL != null) {
defaultPath = defURL.getPath();
}
return getString(LEDGER_METADATA_ROCKSDB_CONF, defaultPath);
String filePath = getFilePath("conf/ledger_metadata_rocksdb.conf");
return getString(LEDGER_METADATA_ROCKSDB_CONF, filePath);
}

/**
Expand Down Expand Up @@ -4155,4 +4144,18 @@ public ServerConfiguration setMaxBatchReadSize(long maxBatchReadSize) {
public long getMaxBatchReadSize() {
return this.getLong(MAX_BATCH_READ_SIZE, DEFAULT_MAX_BATCH_READ_SIZE);
}

/**
* Get the path of a file from resources.
*
* @param fileName the name of the file to get the path for.
* @return String the absolute path of the file.
*/
private String getFilePath(String fileName) {
URL resourceURL = getClass().getClassLoader().getResource(fileName);
if (resourceURL != null) {
return Paths.get(resourceURL.getPath()).toString();
}
return "";
}
}