HDDS-395. TestOzoneRestWithMiniCluster fails with "Unable to read ROCKDB config".
Contributed by Dinesh Chitlangia.
This commit is contained in:
parent
8e9afbfb66
commit
c18eb97801
|
@ -26,6 +26,8 @@ import org.rocksdb.DBOptions;
|
||||||
import org.rocksdb.Env;
|
import org.rocksdb.Env;
|
||||||
import org.rocksdb.OptionsUtil;
|
import org.rocksdb.OptionsUtil;
|
||||||
import org.rocksdb.RocksDBException;
|
import org.rocksdb.RocksDBException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -44,6 +46,9 @@ import java.util.List;
|
||||||
* responsibility.
|
* responsibility.
|
||||||
*/
|
*/
|
||||||
public final class DBConfigFromFile {
|
public final class DBConfigFromFile {
|
||||||
|
private static final Logger LOG =
|
||||||
|
LoggerFactory.getLogger(DBConfigFromFile.class);
|
||||||
|
|
||||||
public static final String CONFIG_DIR = "HADOOP_CONF_DIR";
|
public static final String CONFIG_DIR = "HADOOP_CONF_DIR";
|
||||||
|
|
||||||
private DBConfigFromFile() {
|
private DBConfigFromFile() {
|
||||||
|
@ -59,8 +64,11 @@ public final class DBConfigFromFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtil.isBlank(path)) {
|
if (StringUtil.isBlank(path)) {
|
||||||
throw new IOException("Unable to find the configuration directory. "
|
LOG.debug("Unable to find the configuration directory. "
|
||||||
+ "Please make sure that HADOOP_CONF_DIR is setup correctly ");
|
+ "Please make sure that HADOOP_CONF_DIR is setup correctly.");
|
||||||
|
}
|
||||||
|
if(StringUtil.isBlank(path)){
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return new File(path);
|
return new File(path);
|
||||||
|
|
||||||
|
@ -115,17 +123,21 @@ public final class DBConfigFromFile {
|
||||||
//TODO: Add Documentation on how to support RocksDB Mem Env.
|
//TODO: Add Documentation on how to support RocksDB Mem Env.
|
||||||
Env env = Env.getDefault();
|
Env env = Env.getDefault();
|
||||||
DBOptions options = null;
|
DBOptions options = null;
|
||||||
Path optionsFile = Paths.get(getConfigLocation().toString(),
|
File configLocation = getConfigLocation();
|
||||||
getOptionsFileNameFromDB(dbFileName));
|
if(configLocation != null &&
|
||||||
|
StringUtil.isNotBlank(configLocation.toString())){
|
||||||
|
Path optionsFile = Paths.get(configLocation.toString(),
|
||||||
|
getOptionsFileNameFromDB(dbFileName));
|
||||||
|
|
||||||
if (optionsFile.toFile().exists()) {
|
if (optionsFile.toFile().exists()) {
|
||||||
options = new DBOptions();
|
options = new DBOptions();
|
||||||
try {
|
try {
|
||||||
OptionsUtil.loadOptionsFromFile(optionsFile.toString(),
|
OptionsUtil.loadOptionsFromFile(optionsFile.toString(),
|
||||||
env, options, cfDescs, true);
|
env, options, cfDescs, true);
|
||||||
|
|
||||||
} catch (RocksDBException rdEx) {
|
} catch (RocksDBException rdEx) {
|
||||||
RDBTable.toIOException("Unable to find/open Options file.", rdEx);
|
RDBTable.toIOException("Unable to find/open Options file.", rdEx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
|
|
Loading…
Reference in New Issue