Search in sources :

Example 11 with MetricsInfo

use of org.apache.hadoop.metrics2.MetricsInfo in project hbase by apache.

the class DynamicMetricsRegistry method tag.

/**
 * Add a tag to the metrics
 * @param info  metadata of the tag
 * @param value of the tag
 * @param override existing tag if true
 * @return the registry (for keep adding tags etc.)
 */
public DynamicMetricsRegistry tag(MetricsInfo info, String value, boolean override) {
    MetricsTag tag = Interns.tag(info, value);
    if (!override) {
        MetricsTag existing = tagsMap.putIfAbsent(info.name(), tag);
        if (existing != null) {
            throw new MetricsException("Tag " + info.name() + " already exists!");
        }
        return this;
    }
    tagsMap.put(info.name(), tag);
    return this;
}
Also used : MetricsException(org.apache.hadoop.metrics2.MetricsException) MetricsTag(org.apache.hadoop.metrics2.MetricsTag)

Example 12 with MetricsInfo

use of org.apache.hadoop.metrics2.MetricsInfo in project hbase by apache.

the class HBaseMetrics2HadoopMetricsAdapter method addGauge.

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());
    }
}
Also used : MetricsInfo(org.apache.hadoop.metrics2.MetricsInfo)

Example 13 with MetricsInfo

use of org.apache.hadoop.metrics2.MetricsInfo in project hbase by apache.

the class HBaseMetrics2HadoopMetricsAdapter method addCounter.

private void addCounter(String name, Counter counter, MetricsRecordBuilder builder) {
    MetricsInfo info = Interns.info(name, EMPTY_STRING);
    builder.addCounter(info, counter.getCount());
}
Also used : MetricsInfo(org.apache.hadoop.metrics2.MetricsInfo)

Example 14 with MetricsInfo

use of org.apache.hadoop.metrics2.MetricsInfo in project hbase by apache.

the class Interns method info.

/**
 * Get a metric info object
 *
 * @return an interned metric info object
 */
public static MetricsInfo info(String name, String description) {
    Map<String, MetricsInfo> map = infoCache.getUnchecked(name);
    MetricsInfo info = map.get(description);
    if (info == null) {
        info = new MetricsInfoImpl(name, description);
        map.put(description, info);
    }
    return info;
}
Also used : MetricsInfo(org.apache.hadoop.metrics2.MetricsInfo)

Example 15 with MetricsInfo

use of org.apache.hadoop.metrics2.MetricsInfo in project hbase by apache.

the class Interns method tag.

/**
 * Get a metrics tag
 *
 * @param info  of the tag
 * @param value of the tag
 * @return an interned metrics tag
 */
public static MetricsTag tag(MetricsInfo info, String value) {
    Map<String, MetricsTag> map = tagCache.getUnchecked(info);
    MetricsTag tag = map.get(value);
    if (tag == null) {
        tag = new MetricsTag(info, value);
        map.put(value, tag);
    }
    return tag;
}
Also used : MetricsTag(org.apache.hadoop.metrics2.MetricsTag)

Aggregations

MetricsInfo (org.apache.hadoop.metrics2.MetricsInfo)13 GarbageCollectorMXBean (java.lang.management.GarbageCollectorMXBean)2 MetricsException (org.apache.hadoop.metrics2.MetricsException)2 MetricsTag (org.apache.hadoop.metrics2.MetricsTag)2 Test (org.junit.Test)2 LinkedBlockingDeque (java.util.concurrent.LinkedBlockingDeque)1 JvmMetricsInfo (org.apache.hadoop.hive.common.JvmMetricsInfo)1 MetricsSource (org.apache.hadoop.metrics2.MetricsSource)1 MetricsSourceBuilder (org.apache.hadoop.metrics2.lib.MetricsSourceBuilder)1 JvmMetricsInfo (org.apache.hadoop.metrics2.source.JvmMetricsInfo)1