|
@@ -22,11 +22,13 @@ package org.apache.hadoop.hdds.utils.db;
|
|
|
import com.google.common.base.Preconditions;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
|
|
|
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
|
|
|
import org.apache.hadoop.hdfs.DFSUtil;
|
|
|
import org.eclipse.jetty.util.StringUtil;
|
|
|
import org.rocksdb.ColumnFamilyDescriptor;
|
|
|
import org.rocksdb.ColumnFamilyOptions;
|
|
|
import org.rocksdb.DBOptions;
|
|
|
+import org.rocksdb.InfoLogLevel;
|
|
|
import org.rocksdb.RocksDB;
|
|
|
import org.rocksdb.Statistics;
|
|
|
import org.rocksdb.StatsLevel;
|
|
@@ -54,6 +56,8 @@ import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_METADATA_STORE_ROCKS
|
|
|
public final class DBStoreBuilder {
|
|
|
private static final Logger LOG =
|
|
|
LoggerFactory.getLogger(DBStoreBuilder.class);
|
|
|
+ public static final Logger ROCKS_DB_LOGGER =
|
|
|
+ LoggerFactory.getLogger(RocksDB.class);
|
|
|
private Set<TableConfig> tables;
|
|
|
private DBProfile dbProfile;
|
|
|
private DBOptions rocksDBOption;
|
|
@@ -63,8 +67,9 @@ public final class DBStoreBuilder {
|
|
|
private Configuration configuration;
|
|
|
private CodecRegistry registry;
|
|
|
private String rocksDbStat;
|
|
|
+ private RocksDBConfiguration rocksDBConfiguration;
|
|
|
|
|
|
- private DBStoreBuilder(Configuration configuration) {
|
|
|
+ private DBStoreBuilder(OzoneConfiguration configuration) {
|
|
|
tables = new HashSet<>();
|
|
|
tableNames = new LinkedList<>();
|
|
|
this.configuration = configuration;
|
|
@@ -72,9 +77,11 @@ public final class DBStoreBuilder {
|
|
|
this.rocksDbStat = configuration.getTrimmed(
|
|
|
OZONE_METADATA_STORE_ROCKSDB_STATISTICS,
|
|
|
OZONE_METADATA_STORE_ROCKSDB_STATISTICS_DEFAULT);
|
|
|
+ this.rocksDBConfiguration =
|
|
|
+ configuration.getObject(RocksDBConfiguration.class);
|
|
|
}
|
|
|
|
|
|
- public static DBStoreBuilder newBuilder(Configuration configuration) {
|
|
|
+ public static DBStoreBuilder newBuilder(OzoneConfiguration configuration) {
|
|
|
return new DBStoreBuilder(configuration);
|
|
|
}
|
|
|
|
|
@@ -199,6 +206,19 @@ public final class DBStoreBuilder {
|
|
|
option = dbProfile.getDBOptions();
|
|
|
}
|
|
|
|
|
|
+ if (rocksDBConfiguration.isRocksdbLoggingEnabled()) {
|
|
|
+ org.rocksdb.Logger logger = new org.rocksdb.Logger(option) {
|
|
|
+ @Override
|
|
|
+ protected void log(InfoLogLevel infoLogLevel, String s) {
|
|
|
+ ROCKS_DB_LOGGER.info(s);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ InfoLogLevel level = InfoLogLevel.valueOf(rocksDBConfiguration
|
|
|
+ .getRocksdbLogLevel() + "_LEVEL");
|
|
|
+ logger.setInfoLogLevel(level);
|
|
|
+ option.setLogger(logger);
|
|
|
+ }
|
|
|
+
|
|
|
if (!rocksDbStat.equals(OZONE_METADATA_STORE_ROCKSDB_STATISTICS_OFF)) {
|
|
|
Statistics statistics = new Statistics();
|
|
|
statistics.setStatsLevel(StatsLevel.valueOf(rocksDbStat));
|