Java Code Examples for org.rocksdb.Statistics#setStatsLevel()

The following examples show how to use org.rocksdb.Statistics#setStatsLevel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestTypedRDBTableStore.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  options = new DBOptions();
  options.setCreateIfMissing(true);
  options.setCreateMissingColumnFamilies(true);

  Statistics statistics = new Statistics();
  statistics.setStatsLevel(StatsLevel.ALL);
  options = options.setStatistics(statistics);

  Set<TableConfig> configSet = new HashSet<>();
  for (String name : families) {
    TableConfig newConfig = new TableConfig(name, new ColumnFamilyOptions());
    configSet.add(newConfig);
  }
  rdbStore = new RDBStore(folder.newFolder(), options, configSet);

  codecRegistry = new CodecRegistry();

}
 
Example 2
Source File: TestRDBStore.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  options = new DBOptions();
  options.setCreateIfMissing(true);
  options.setCreateMissingColumnFamilies(true);

  Statistics statistics = new Statistics();
  statistics.setStatsLevel(StatsLevel.ALL);
  options = options.setStatistics(statistics);
  configSet = new HashSet<>();
  for(String name : families) {
    TableConfig newConfig = new TableConfig(name, new ColumnFamilyOptions());
    configSet.add(newConfig);
  }
  rdbStore = new RDBStore(folder.newFolder(), options, configSet);
}
 
Example 3
Source File: TestRDBTableStore.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  options = new DBOptions();
  options.setCreateIfMissing(true);
  options.setCreateMissingColumnFamilies(true);

  Statistics statistics = new Statistics();
  statistics.setStatsLevel(StatsLevel.ALL);
  options = options.setStatistics(statistics);

  Set<TableConfig> configSet = new HashSet<>();
  for(String name : families) {
    TableConfig newConfig = new TableConfig(name, new ColumnFamilyOptions());
    configSet.add(newConfig);
  }
  rdbStore = new RDBStore(folder.newFolder(), options, configSet);
}
 
Example 4
Source File: ByteStoreManager.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
private void registerMetrics(DBOptions dbOptions) {
  // calling DBOptions.statisticsPtr() will create a Statistics object that will collect various stats from RocksDB and
  // will introduce a 5-10% overhead
  if(!COLLECT_METRICS) {
    return;
  }

  final Statistics statistics = new Statistics();
  statistics.setStatsLevel(StatsLevel.ALL);
  dbOptions.setStatistics(statistics);
  // for now, let's add all ticker stats as gauge metrics
  for (TickerType tickerType : TickerType.values()) {
    if (tickerType == TickerType.TICKER_ENUM_MAX) {
      continue;
    }

    Metrics.newGauge(Metrics.join(METRICS_PREFIX, tickerType.name()), () -> statistics.getTickerCount(tickerType));
  }
  // Note that Statistics also contains various histogram metrics, but those cannot be easily tracked through our metrics
}
 
Example 5
Source File: DBStoreBuilder.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
private DBOptions getDbProfile() {
  if (rocksDBOption != null) {
    return rocksDBOption;
  }
  DBOptions option = null;
  if (StringUtil.isNotBlank(dbname)) {
    List<ColumnFamilyDescriptor> columnFamilyDescriptors = new LinkedList<>();

    for (TableConfig tc : tables) {
      columnFamilyDescriptors.add(tc.getDescriptor());
    }

    if (columnFamilyDescriptors.size() > 0) {
      try {
        option = DBConfigFromFile.readFromFile(dbname,
            columnFamilyDescriptors);
        if(option != null) {
          LOG.info("Using Configs from {}.ini file", dbname);
        }
      } catch (IOException ex) {
        LOG.info("Unable to read RocksDB config from {}", dbname, ex);
      }
    }
  }

  if (option == null) {
    LOG.debug("Using default options: {}", dbProfile);
    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));
    option = option.setStatistics(statistics);
  }
  return option;
}
 
Example 6
Source File: MetadataStoreBuilder.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
public MetadataStore build() throws IOException {
  if (dbFile == null) {
    throw new IllegalArgumentException("Failed to build metadata store, "
        + "dbFile is required but not found");
  }

  // Build db store based on configuration
  final ConfigurationSource conf = optionalConf.orElse(DEFAULT_CONF);

  if (dbType == null) {
    LOG.debug("dbType is null, using ");
    dbType = conf.getTrimmed(OzoneConfigKeys.OZONE_METADATA_STORE_IMPL,
            OzoneConfigKeys.OZONE_METADATA_STORE_IMPL_DEFAULT);
    LOG.debug("dbType is null, using dbType {} from ozone configuration",
        dbType);
  } else {
    LOG.debug("Using dbType {} for metastore", dbType);
  }
  if (OZONE_METADATA_STORE_IMPL_LEVELDB.equals(dbType)) {
    Options options = new Options();
    options.createIfMissing(createIfMissing);
    if (cacheSize > 0) {
      options.cacheSize(cacheSize);
    }
    return new LevelDBStore(dbFile, options);
  } else if (OZONE_METADATA_STORE_IMPL_ROCKSDB.equals(dbType)) {
    org.rocksdb.Options opts;
    // Used cached options if config object passed down is the same
    if (CACHED_OPTS.containsKey(conf)) {
      opts = CACHED_OPTS.get(conf);
    } else {
      opts = new org.rocksdb.Options();
      if (cacheSize > 0) {
        BlockBasedTableConfig tableConfig = new BlockBasedTableConfig();
        tableConfig.setBlockCacheSize(cacheSize);
        opts.setTableFormatConfig(tableConfig);
      }

      String rocksDbStat = conf.getTrimmed(
          OZONE_METADATA_STORE_ROCKSDB_STATISTICS,
          OZONE_METADATA_STORE_ROCKSDB_STATISTICS_DEFAULT);

      if (!rocksDbStat.equals(OZONE_METADATA_STORE_ROCKSDB_STATISTICS_OFF)) {
        Statistics statistics = new Statistics();
        statistics.setStatsLevel(StatsLevel.valueOf(rocksDbStat));
        opts = opts.setStatistics(statistics);
      }
    }
    opts.setCreateIfMissing(createIfMissing);
    CACHED_OPTS.put(conf, opts);
    return new RocksDBStore(dbFile, opts);
  }
  
  throw new IllegalArgumentException("Invalid argument for "
      + OzoneConfigKeys.OZONE_METADATA_STORE_IMPL
      + ". Expecting " + OZONE_METADATA_STORE_IMPL_LEVELDB
      + " or " + OZONE_METADATA_STORE_IMPL_ROCKSDB
      + ", but met " + dbType);
}