org.rocksdb.HistogramData Java Examples

The following examples show how to use org.rocksdb.HistogramData. 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: RocksDBStoreMBean.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
/**
 * Collect all histogram metrics from RocksDB statistics.
 * @param rb Metrics Record Builder.
 */
private void getHistogramData(MetricsRecordBuilder rb) {
  for (HistogramType histogramType : HistogramType.values()) {
    HistogramData histogram =
        statistics.getHistogramData(
            HistogramType.valueOf(histogramType.name()));
    for (String histogramAttribute : histogramAttributes) {
      try {
        Method method =
            HistogramData.class.getMethod("get" + histogramAttribute);
        double metricValue =  (double) method.invoke(histogram);
        rb.addGauge(Interns.info(histogramType.name() + "_" +
                histogramAttribute.toUpperCase(), "RocksDBStat"),
            metricValue);
      } catch (Exception e) {
        LOG.error("Error reading histogram data", e);
      }
    }
  }
}
 
Example #2
Source File: RocksDBStats.java    From besu with Apache License 2.0 6 votes vote down vote up
private static Collector histogramToCollector(
    final Statistics stats, final HistogramType histogram) {
  return new Collector() {
    final String metricName =
        KVSTORE_ROCKSDB_STATS.getName() + "_" + histogram.name().toLowerCase();

    @Override
    public List<MetricFamilySamples> collect() {
      final HistogramData data = stats.getHistogramData(histogram);
      return Collections.singletonList(
          new MetricFamilySamples(
              metricName,
              Type.SUMMARY,
              "RocksDB histogram for " + metricName,
              Arrays.asList(
                  new MetricFamilySamples.Sample(metricName, LABELS, LABEL_50, data.getMedian()),
                  new MetricFamilySamples.Sample(
                      metricName, LABELS, LABEL_95, data.getPercentile95()),
                  new MetricFamilySamples.Sample(
                      metricName, LABELS, LABEL_99, data.getPercentile99()))));
    }
  };
}
 
Example #3
Source File: RocksDBStoreMBean.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@Override
public Object getAttribute(String attribute)
    throws AttributeNotFoundException, MBeanException, ReflectionException {
  for (String histogramAttribute : histogramAttributes) {
    if (attribute.endsWith("_" + histogramAttribute.toUpperCase())) {
      String keyName = attribute
          .substring(0, attribute.length() - histogramAttribute.length() - 1);
      try {
        HistogramData histogram =
            statistics.getHistogramData(HistogramType.valueOf(keyName));
        try {
          Method method =
              HistogramData.class.getMethod("get" + histogramAttribute);
          return method.invoke(histogram);
        } catch (Exception e) {
          throw new ReflectionException(e,
              "Can't read attribute " + attribute);
        }
      } catch (IllegalArgumentException exception) {
        throw new AttributeNotFoundException(
            "No such attribute in RocksDB stats: " + attribute);
      }
    }
  }
  try {
    return statistics.getTickerCount(TickerType.valueOf(attribute));
  } catch (IllegalArgumentException ex) {
    throw new AttributeNotFoundException(
        "No such attribute in RocksDB stats: " + attribute);
  }
}
 
Example #4
Source File: RocksStatistics.java    From sofa-jraft with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the histogram data for a particular histogram.
 */
public static HistogramData getHistogramData(final RocksRawKVStore rocksRawKVStore,
                                             final HistogramType histogramType) {
    final Statistics statistics = statistics(rocksRawKVStore);
    if (statistics == null) {
        return null;
    }
    return statistics.getHistogramData(histogramType);
}
 
Example #5
Source File: RocksDbStats.java    From teku with Apache License 2.0 5 votes vote down vote up
private Collector histogramToCollector(
    final MetricCategory metricCategory, final Statistics stats, final HistogramType histogram) {
  return new Collector() {
    final String metricName =
        metricCategory.getApplicationPrefix().orElse("")
            + metricCategory.getName()
            + "_"
            + histogram.name().toLowerCase();

    @Override
    public List<MetricFamilySamples> collect() {
      return ifOpen(
          () -> {
            final HistogramData data = stats.getHistogramData(histogram);
            return Collections.singletonList(
                new MetricFamilySamples(
                    metricName,
                    Type.SUMMARY,
                    "RocksDB histogram for " + metricName,
                    Arrays.asList(
                        new MetricFamilySamples.Sample(
                            metricName, LABELS, LABEL_50, data.getMedian()),
                        new MetricFamilySamples.Sample(
                            metricName, LABELS, LABEL_95, data.getPercentile95()),
                        new MetricFamilySamples.Sample(
                            metricName, LABELS, LABEL_99, data.getPercentile99()))));
          },
          Collections.emptyList());
    }
  };
}