HDDS-395. TestOzoneRestWithMiniCluster fails with "Unable to read ROCKDB config".

Contributed by Dinesh Chitlangia.
This commit is contained in:
Anu Engineer 2018-09-12 14:09:15 -07:00
parent 8e9afbfb66
commit c18eb97801

View File

@ -26,6 +26,8 @@
import org.rocksdb.Env;
import org.rocksdb.OptionsUtil;
import org.rocksdb.RocksDBException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@ -44,6 +46,9 @@
* responsibility.
*/
public final class DBConfigFromFile {
private static final Logger LOG =
LoggerFactory.getLogger(DBConfigFromFile.class);
public static final String CONFIG_DIR = "HADOOP_CONF_DIR";
private DBConfigFromFile() {
@ -59,8 +64,11 @@ public static File getConfigLocation() throws IOException {
}
if (StringUtil.isBlank(path)) {
throw new IOException("Unable to find the configuration directory. "
+ "Please make sure that HADOOP_CONF_DIR is setup correctly ");
LOG.debug("Unable to find the configuration directory. "
+ "Please make sure that HADOOP_CONF_DIR is setup correctly.");
}
if(StringUtil.isBlank(path)){
return null;
}
return new File(path);
@ -115,7 +123,10 @@ public static DBOptions readFromFile(String dbFileName,
//TODO: Add Documentation on how to support RocksDB Mem Env.
Env env = Env.getDefault();
DBOptions options = null;
Path optionsFile = Paths.get(getConfigLocation().toString(),
File configLocation = getConfigLocation();
if(configLocation != null &&
StringUtil.isNotBlank(configLocation.toString())){
Path optionsFile = Paths.get(configLocation.toString(),
getOptionsFileNameFromDB(dbFileName));
if (optionsFile.toFile().exists()) {
@ -128,6 +139,7 @@ public static DBOptions readFromFile(String dbFileName,
RDBTable.toIOException("Unable to find/open Options file.", rdEx);
}
}
}
return options;
}