Search in sources :

Example 6 with MetricsInfo

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

the class JvmMetrics method getGcUsage.

private void getGcUsage(MetricsRecordBuilder rb) {
    long count = 0;
    long timeMillis = 0;
    for (GarbageCollectorMXBean gcBean : gcBeans) {
        long c = gcBean.getCollectionCount();
        long t = gcBean.getCollectionTime();
        MetricsInfo[] gcInfo = getGcInfo(gcBean.getName());
        rb.addCounter(gcInfo[0], c).addCounter(gcInfo[1], t);
        count += c;
        timeMillis += t;
    }
    rb.addCounter(GcCount, count).addCounter(GcTimeMillis, timeMillis);
    if (pauseMonitor != null) {
        rb.addCounter(GcNumWarnThresholdExceeded, pauseMonitor.getNumGcWarnThreadholdExceeded());
        rb.addCounter(GcNumInfoThresholdExceeded, pauseMonitor.getNumGcInfoThresholdExceeded());
        rb.addCounter(GcTotalExtraSleepTime, pauseMonitor.getTotalGcExtraSleepTime());
    }
}
Also used : MetricsInfo(org.apache.hadoop.metrics2.MetricsInfo) JvmMetricsInfo(org.apache.hadoop.hive.common.JvmMetricsInfo) GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean)

Example 7 with MetricsInfo

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

the class JvmMetrics method getGcUsage.

private void getGcUsage(MetricsRecordBuilder rb) {
    long count = 0;
    long timeMillis = 0;
    for (GarbageCollectorMXBean gcBean : gcBeans) {
        long c = gcBean.getCollectionCount();
        long t = gcBean.getCollectionTime();
        MetricsInfo[] gcInfo = getGcInfo(gcBean.getName());
        rb.addCounter(gcInfo[0], c).addCounter(gcInfo[1], t);
        count += c;
        timeMillis += t;
    }
    rb.addCounter(GcCount, count).addCounter(GcTimeMillis, timeMillis);
    if (pauseMonitor != null) {
        rb.addCounter(GcNumWarnThresholdExceeded, pauseMonitor.getNumGcWarnThresholdExceeded());
        rb.addCounter(GcNumInfoThresholdExceeded, pauseMonitor.getNumGcInfoThresholdExceeded());
        rb.addCounter(GcTotalExtraSleepTime, pauseMonitor.getTotalGcExtraSleepTime());
    }
}
Also used : MetricsInfo(org.apache.hadoop.metrics2.MetricsInfo) JvmMetricsInfo(org.apache.hadoop.metrics2.source.JvmMetricsInfo) GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean)

Example 8 with MetricsInfo

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

the class MutableMetricsFactory method newForMethod.

MutableMetric newForMethod(Object source, Method method, Metric annotation, MetricsRegistry registry) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("method " + method + " with annotation " + annotation);
    }
    MetricsInfo info = getInfo(annotation, method);
    MutableMetric metric = newForMethod(source, method, annotation);
    metric = metric != null ? metric : new MethodMetric(source, method, info, annotation.type());
    registry.add(info.name(), metric);
    return metric;
}
Also used : MetricsInfo(org.apache.hadoop.metrics2.MetricsInfo)

Example 9 with MetricsInfo

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

the class MutableMetricsFactory method newForField.

MutableMetric newForField(Field field, Metric annotation, MetricsRegistry registry) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("field " + field + " with annotation " + annotation);
    }
    MetricsInfo info = getInfo(annotation, field);
    MutableMetric metric = newForField(field, annotation);
    if (metric != null) {
        registry.add(info.name(), metric);
        return metric;
    }
    final Class<?> cls = field.getType();
    if (cls == MutableCounterInt.class) {
        return registry.newCounter(info, 0);
    }
    if (cls == MutableCounterLong.class) {
        return registry.newCounter(info, 0L);
    }
    if (cls == MutableGaugeInt.class) {
        return registry.newGauge(info, 0);
    }
    if (cls == MutableGaugeLong.class) {
        return registry.newGauge(info, 0L);
    }
    if (cls == MutableRate.class) {
        return registry.newRate(info.name(), info.description(), annotation.always());
    }
    if (cls == MutableRates.class) {
        return new MutableRates(registry);
    }
    if (cls == MutableRatesWithAggregation.class) {
        return registry.newRatesWithAggregation(info.name());
    }
    if (cls == MutableStat.class) {
        return registry.newStat(info.name(), info.description(), annotation.sampleName(), annotation.valueName(), annotation.always());
    }
    throw new MetricsException("Unsupported metric field " + field.getName() + " of type " + field.getType().getName());
}
Also used : MetricsInfo(org.apache.hadoop.metrics2.MetricsInfo) MetricsException(org.apache.hadoop.metrics2.MetricsException)

Example 10 with MetricsInfo

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

the class RollingAverages method snapshot.

@Override
public void snapshot(MetricsRecordBuilder builder, boolean all) {
    if (all || changed()) {
        for (final Entry<String, LinkedBlockingDeque<SumAndCount>> entry : averages.entrySet()) {
            final String name = entry.getKey();
            final MetricsInfo avgInfo = info(String.format(avgInfoNameTemplate, StringUtils.capitalize(name)), String.format(avgInfoDescTemplate, StringUtils.uncapitalize(name)));
            double totalSum = 0;
            long totalCount = 0;
            for (final SumAndCount sumAndCount : entry.getValue()) {
                totalCount += sumAndCount.getCount();
                totalSum += sumAndCount.getSum();
            }
            if (totalCount != 0) {
                builder.addGauge(avgInfo, totalSum / totalCount);
            }
        }
        if (changed()) {
            clearChanged();
        }
    }
}
Also used : MetricsInfo(org.apache.hadoop.metrics2.MetricsInfo) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque)

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