Java Code Examples for org.apache.hadoop.metrics2.lib.Interns#info()

The following examples show how to use org.apache.hadoop.metrics2.lib.Interns#info() . 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: HadoopMetrics2Reporter.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
private HadoopMetrics2Reporter(MetricRegistry registry, TimeUnit rateUnit, TimeUnit durationUnit,
        MetricFilter filter, MetricsSystem metrics2System, String jmxContext, String description, String recordName,
        String context) {
    super(registry, "hadoop-metrics2-reporter", filter, rateUnit, durationUnit);
    this.metrics2Registry = new MetricsRegistry(Interns.info(jmxContext, description));
    this.metrics2System = metrics2System;
    this.recordName = recordName;
    this.context = context;

    // These could really be Collection.emptyMap(), but this makes testing a bit easier.
    this.dropwizardGauges = EMPTY_GAUGE_MAP;
    this.dropwizardCounters = EMPTY_COUNTER_MAP;
    this.dropwizardHistograms = EMPTY_HISTOGRAM_MAP;
    this.dropwizardMeters = EMPTY_METER_MAP;
    this.dropwizardTimers = EMPTY_TIMER_MAP;

    // Register this source with the Metrics2 system.
    // Make sure this is the last thing done as getMetrics() can be called at any time after.
    this.metrics2System.register(Objects.requireNonNull(jmxContext), Objects.requireNonNull(description), this);
}
 
Example 2
Source File: HadoopMetrics2Reporter.java    From kylin with Apache License 2.0 6 votes vote down vote up
private HadoopMetrics2Reporter(MetricRegistry registry, TimeUnit rateUnit, TimeUnit durationUnit,
        MetricFilter filter, MetricsSystem metrics2System, String jmxContext, String description, String recordName,
        String context) {
    super(registry, "hadoop-metrics2-reporter", filter, rateUnit, durationUnit);
    this.metrics2Registry = new MetricsRegistry(Interns.info(jmxContext, description));
    this.metrics2System = metrics2System;
    this.recordName = recordName;
    this.context = context;

    // These could really be Collection.emptyMap(), but this makes testing a bit easier.
    this.dropwizardGauges = EMPTY_GAUGE_MAP;
    this.dropwizardCounters = EMPTY_COUNTER_MAP;
    this.dropwizardHistograms = EMPTY_HISTOGRAM_MAP;
    this.dropwizardMeters = EMPTY_METER_MAP;
    this.dropwizardTimers = EMPTY_TIMER_MAP;

    // Register this source with the Metrics2 system.
    // Make sure this is the last thing done as getMetrics() can be called at any time after.
    this.metrics2System.register(Objects.requireNonNull(jmxContext), Objects.requireNonNull(description), this);
}
 
Example 3
Source File: HBaseMetrics2HadoopMetricsAdapter.java    From hbase with Apache License 2.0 6 votes vote down vote up
private void addGauge(String name, Gauge<?> gauge, MetricsRecordBuilder builder) {
  final MetricsInfo info = Interns.info(name, EMPTY_STRING);
  final Object o = gauge.getValue();

  // Figure out which gauge types metrics2 supports and call the right method
  if (o instanceof Integer) {
    builder.addGauge(info, (int) o);
  } else if (o instanceof Long) {
    builder.addGauge(info, (long) o);
  } else if (o instanceof Float) {
    builder.addGauge(info, (float) o);
  } else if (o instanceof Double) {
    builder.addGauge(info, (double) o);
  } else {
    LOG.warn("Ignoring Gauge (" + name + ") with unhandled type: " + o.getClass());
  }
}
 
Example 4
Source File: GlobalMetricRegistriesAdapter.java    From phoenix with Apache License 2.0 6 votes vote down vote up
private void addGauge(String name, Gauge<?> gauge, MetricsRecordBuilder builder) {
    MetricsInfo info = Interns.info(name, "");
    Object o = gauge.getValue();
    if (o instanceof Integer) {
        builder.addGauge(info, (Integer)o);
    } else if (o instanceof Long) {
        builder.addGauge(info, (Long)o);
    } else if (o instanceof Float) {
        builder.addGauge(info, (Float)o);
    } else if (o instanceof Double) {
        builder.addGauge(info, (Double)o);
    } else {
        LOGGER.warn("Ignoring Gauge (" + name + ") with unhandled type: " + o.getClass());
    }

}
 
Example 5
Source File: JvmMetrics.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private MetricsInfo[] getGcInfo(String gcName) {
  MetricsInfo[] gcInfo = gcInfoCache.get(gcName);
  if (gcInfo == null) {
    gcInfo = new MetricsInfo[2];
    gcInfo[0] = Interns.info("GcCount" + gcName, "GC Count for " + gcName);
    gcInfo[1] = Interns
        .info("GcTimeMillis" + gcName, "GC Time for " + gcName);
    MetricsInfo[] previousGcInfo = gcInfoCache.putIfAbsent(gcName, gcInfo);
    if (previousGcInfo != null) {
      return previousGcInfo;
    }
  }
  return gcInfo;
}
 
Example 6
Source File: JvmMetrics.java    From big-c with Apache License 2.0 5 votes vote down vote up
private MetricsInfo[] getGcInfo(String gcName) {
  MetricsInfo[] gcInfo = gcInfoCache.get(gcName);
  if (gcInfo == null) {
    gcInfo = new MetricsInfo[2];
    gcInfo[0] = Interns.info("GcCount" + gcName, "GC Count for " + gcName);
    gcInfo[1] = Interns
        .info("GcTimeMillis" + gcName, "GC Time for " + gcName);
    MetricsInfo[] previousGcInfo = gcInfoCache.putIfAbsent(gcName, gcInfo);
    if (previousGcInfo != null) {
      return previousGcInfo;
    }
  }
  return gcInfo;
}
 
Example 7
Source File: GlobalMetricRegistriesAdapter.java    From phoenix with Apache License 2.0 5 votes vote down vote up
private void snapshotAllMetrics(MetricRegistry metricRegistry, MetricsCollector collector) {
    MetricRegistryInfo hbaseMetricRegistryInfo = metricRegistry.getMetricRegistryInfo();
    MetricsInfo hadoopMetricsInfo = Interns.info(hbaseMetricRegistryInfo.getMetricsName(), hbaseMetricRegistryInfo.getMetricsDescription());
    MetricsRecordBuilder builder = collector.addRecord(hadoopMetricsInfo);
    builder.setContext(hbaseMetricRegistryInfo.getMetricsContext());
    builder.tag(hadoopMetricsInfo, metricTag);
    this.snapshotAllMetrics(metricRegistry, builder);
}
 
Example 8
Source File: HBaseMetrics2HadoopMetricsAdapter.java    From hbase with Apache License 2.0 4 votes vote down vote up
private void addCounter(String name, Counter counter, MetricsRecordBuilder builder) {
  MetricsInfo info = Interns.info(name, EMPTY_STRING);
  builder.addCounter(info, counter.getCount());
}
 
Example 9
Source File: GlobalMetricRegistriesAdapter.java    From phoenix with Apache License 2.0 4 votes vote down vote up
private void addCounter(String name, Counter counter, MetricsRecordBuilder builder) {
    MetricsInfo info = Interns.info(name, "");
    builder.addCounter(info, counter.getCount());
}