Search in sources :

Example 21 with MetricsSource

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

the class TestQueueMetrics method checkApps.

public static void checkApps(MetricsSource source, int submitted, int pending, int running, int completed, int failed, int killed, boolean all) {
    MetricsRecordBuilder rb = getMetrics(source, all);
    assertCounter("AppsSubmitted", submitted, rb);
    assertGauge("AppsPending", pending, rb);
    assertGauge("AppsRunning", running, rb);
    assertCounter("AppsCompleted", completed, rb);
    assertCounter("AppsFailed", failed, rb);
    assertCounter("AppsKilled", killed, rb);
}
Also used : MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder)

Example 22 with MetricsSource

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

the class CleanerMetrics method create.

static CleanerMetrics create() {
    MetricsSystem ms = DefaultMetricsSystem.instance();
    CleanerMetrics metricObject = new CleanerMetrics();
    MetricsSourceBuilder sb = MetricsAnnotations.newSourceBuilder(metricObject);
    final MetricsSource s = sb.build();
    ms.register("cleaner", "The cleaner service of truly shared cache", s);
    metricObject.metricSource = s;
    return metricObject;
}
Also used : MetricsSource(org.apache.hadoop.metrics2.MetricsSource) MetricsSourceBuilder(org.apache.hadoop.metrics2.lib.MetricsSourceBuilder) MetricsSystem(org.apache.hadoop.metrics2.MetricsSystem) DefaultMetricsSystem(org.apache.hadoop.metrics2.lib.DefaultMetricsSystem)

Example 23 with MetricsSource

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

the class TestMetricsSourceAdapter method testPurgeOldMetrics.

@Test
public void testPurgeOldMetrics() throws Exception {
    // create test source with a single metric counter of value 1
    PurgableSource source = new PurgableSource();
    MetricsSourceBuilder sb = MetricsAnnotations.newSourceBuilder(source);
    final MetricsSource s = sb.build();
    List<MetricsTag> injectedTags = new ArrayList<MetricsTag>();
    MetricsSourceAdapter sa = new MetricsSourceAdapter("tst", "tst", "testdesc", s, injectedTags, null, null, 1, false);
    MBeanInfo info = sa.getMBeanInfo();
    boolean sawIt = false;
    for (MBeanAttributeInfo mBeanAttributeInfo : info.getAttributes()) {
        sawIt |= mBeanAttributeInfo.getName().equals(source.lastKeyName);
    }
    ;
    assertTrue("The last generated metric is not exported to jmx", sawIt);
    // skip JMX cache TTL
    Thread.sleep(1000);
    info = sa.getMBeanInfo();
    sawIt = false;
    for (MBeanAttributeInfo mBeanAttributeInfo : info.getAttributes()) {
        sawIt |= mBeanAttributeInfo.getName().equals(source.lastKeyName);
    }
    ;
    assertTrue("The last generated metric is not exported to jmx", sawIt);
}
Also used : MetricsSource(org.apache.hadoop.metrics2.MetricsSource) MBeanInfo(javax.management.MBeanInfo) MetricsSourceBuilder(org.apache.hadoop.metrics2.lib.MetricsSourceBuilder) ArrayList(java.util.ArrayList) MetricsTag(org.apache.hadoop.metrics2.MetricsTag) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) Test(org.junit.Test)

Example 24 with MetricsSource

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

the class TestMetricsSystemImpl method testRegisterDups.

@Test
public void testRegisterDups() {
    MetricsSystem ms = new MetricsSystemImpl();
    TestSource ts1 = new TestSource("ts1");
    TestSource ts2 = new TestSource("ts2");
    ms.register("ts1", "", ts1);
    MetricsSource s1 = ms.getSource("ts1");
    assertNotNull(s1);
    // should work when metrics system is not started
    ms.register("ts1", "", ts2);
    MetricsSource s2 = ms.getSource("ts1");
    assertNotNull(s2);
    assertNotSame(s1, s2);
    ms.shutdown();
}
Also used : MetricsSource(org.apache.hadoop.metrics2.MetricsSource) DefaultMetricsSystem(org.apache.hadoop.metrics2.lib.DefaultMetricsSystem) MetricsSystem(org.apache.hadoop.metrics2.MetricsSystem) Test(org.junit.Test)

Example 25 with MetricsSource

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

the class TestMetricsAnnotations method testMethods.

@Test
public void testMethods() {
    MyMetrics2 metrics = new MyMetrics2();
    MetricsSource source = MetricsAnnotations.makeSource(metrics);
    MetricsRecordBuilder rb = getMetrics(source);
    verify(rb).addGauge(info("G1", "G1"), 1);
    verify(rb).addGauge(info("G2", "G2"), 2L);
    verify(rb).addGauge(info("G3", "G3"), 3.0f);
    verify(rb).addGauge(info("G4", "G4"), 4.0);
    verify(rb).addCounter(info("C1", "C1"), 1);
    verify(rb).addCounter(info("C2", "C2"), 2L);
    verify(rb).tag(info("T1", "T1"), "t1");
}
Also used : MetricsSource(org.apache.hadoop.metrics2.MetricsSource) MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder) Test(org.junit.Test)

Aggregations

MetricsSource (org.apache.hadoop.metrics2.MetricsSource)21 Test (org.junit.Test)17 MetricsRecordBuilder (org.apache.hadoop.metrics2.MetricsRecordBuilder)9 MetricsSourceBuilder (org.apache.hadoop.metrics2.lib.MetricsSourceBuilder)4 MetricsSystem (org.apache.hadoop.metrics2.MetricsSystem)3 MetricsCollectorImpl (org.apache.hadoop.metrics2.impl.MetricsCollectorImpl)3 DefaultMetricsSystem (org.apache.hadoop.metrics2.lib.DefaultMetricsSystem)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 MetricsCollector (org.apache.hadoop.metrics2.MetricsCollector)2 MetricsTag (org.apache.hadoop.metrics2.MetricsTag)2 DynamicMetricsRegistry (org.apache.hadoop.metrics2.lib.DynamicMetricsRegistry)2 HashMap (java.util.HashMap)1 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)1 MBeanInfo (javax.management.MBeanInfo)1 Configuration (org.apache.hadoop.conf.Configuration)1 MetricsReplicationGlobalSourceSource (org.apache.hadoop.hbase.replication.regionserver.MetricsReplicationGlobalSourceSource)1 MetricsReplicationGlobalSourceSourceImpl (org.apache.hadoop.hbase.replication.regionserver.MetricsReplicationGlobalSourceSourceImpl)1 MetricsReplicationSourceImpl (org.apache.hadoop.hbase.replication.regionserver.MetricsReplicationSourceImpl)1 MetricsReplicationSourceSource (org.apache.hadoop.hbase.replication.regionserver.MetricsReplicationSourceSource)1