Search in sources :

Example 1 with MetricsInfo

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

the class MetricsSystemImpl method register.

@Override
public synchronized <T> T register(String name, String desc, T source) {
    MetricsSourceBuilder sb = MetricsAnnotations.newSourceBuilder(source);
    final MetricsSource s = sb.build();
    MetricsInfo si = sb.info();
    String name2 = name == null ? si.name() : name;
    final String finalDesc = desc == null ? si.description() : desc;
    final // be friendly to non-metrics tests
    String finalName = DefaultMetricsSystem.sourceName(name2, !monitoring);
    allSources.put(finalName, s);
    LOG.debug(finalName + ", " + finalDesc);
    if (monitoring) {
        registerSource(finalName, finalDesc, s);
    }
    // We want to re-register the source to pick up new config when the
    // metrics system restarts.
    register(finalName, new AbstractCallback() {

        @Override
        public void postStart() {
            registerSource(finalName, finalDesc, s);
        }
    });
    return source;
}
Also used : MetricsInfo(org.apache.hadoop.metrics2.MetricsInfo) MetricsSource(org.apache.hadoop.metrics2.MetricsSource) MetricsSourceBuilder(org.apache.hadoop.metrics2.lib.MetricsSourceBuilder)

Example 2 with MetricsInfo

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

the class StartupProgressMetrics method addCounter.

/**
   * Adds a counter with a name built by using the specified phase's name as
   * prefix and then appending the specified suffix.
   * 
   * @param builder MetricsRecordBuilder to receive counter
   * @param phase Phase to add
   * @param nameSuffix String suffix of metric name
   * @param descSuffix String suffix of metric description
   * @param value long counter value
   */
private static void addCounter(MetricsRecordBuilder builder, Phase phase, String nameSuffix, String descSuffix, long value) {
    MetricsInfo metricsInfo = info(phase.getName() + nameSuffix, phase.getDescription() + descSuffix);
    builder.addCounter(metricsInfo, value);
}
Also used : MetricsInfo(org.apache.hadoop.metrics2.MetricsInfo)

Example 3 with MetricsInfo

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

the class StartupProgressMetrics method addGauge.

/**
   * Adds a gauge with a name built by using the specified phase's name as prefix
   * and then appending the specified suffix.
   * 
   * @param builder MetricsRecordBuilder to receive counter
   * @param phase Phase to add
   * @param nameSuffix String suffix of metric name
   * @param descSuffix String suffix of metric description
   * @param value float gauge value
   */
private static void addGauge(MetricsRecordBuilder builder, Phase phase, String nameSuffix, String descSuffix, float value) {
    MetricsInfo metricsInfo = info(phase.getName() + nameSuffix, phase.getDescription() + descSuffix);
    builder.addGauge(metricsInfo, value);
}
Also used : MetricsInfo(org.apache.hadoop.metrics2.MetricsInfo)

Example 4 with MetricsInfo

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

the class TestInterns method testInfoOverflow.

@Test
public void testInfoOverflow() {
    MetricsInfo i0 = info("m0", "m desc");
    for (int i = 0; i < MAX_INFO_NAMES + 1; ++i) {
        info("m" + i, "m desc");
        if (i < MAX_INFO_NAMES) {
            assertSame("m0 is still there", i0, info("m0", "m desc"));
        }
    }
    assertNotSame("m0 is gone", i0, info("m0", "m desc"));
    MetricsInfo i1 = info("m1", "m desc");
    for (int i = 0; i < MAX_INFO_DESCS; ++i) {
        info("m1", "m desc" + i);
        if (i < MAX_INFO_DESCS - 1) {
            assertSame("i1 is still there", i1, info("m1", "m desc"));
        }
    }
    assertNotSame("i1 is gone", i1, info("m1", "m desc"));
}
Also used : MetricsInfo(org.apache.hadoop.metrics2.MetricsInfo) Test(org.junit.Test)

Example 5 with MetricsInfo

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

the class TestInterns method testInfo.

@Test
public void testInfo() {
    MetricsInfo info = info("m", "m desc");
    assertSame("same info", info, info("m", "m desc"));
}
Also used : MetricsInfo(org.apache.hadoop.metrics2.MetricsInfo) Test(org.junit.Test)

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