Search in sources :

Example 76 with MetricsRecordBuilder

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

the class TestMutableMetrics method testMutableRatesWithAggregationInit.

@Test
public void testMutableRatesWithAggregationInit() {
    MetricsRecordBuilder rb = mockMetricsRecordBuilder();
    MutableRatesWithAggregation rates = new MutableRatesWithAggregation();
    rates.init(TestProtocol.class);
    rates.snapshot(rb, false);
    assertCounter("FooNumOps", 0L, rb);
    assertGauge("FooAvgTime", 0.0, rb);
    assertCounter("BarNumOps", 0L, rb);
    assertGauge("BarAvgTime", 0.0, rb);
}
Also used : MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder) Test(org.junit.Test)

Example 77 with MetricsRecordBuilder

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

the class TestUserGroupInformation method verifyGroupMetrics.

private static void verifyGroupMetrics(long groups) throws InterruptedException {
    MetricsRecordBuilder rb = getMetrics("UgiMetrics");
    if (groups > 0) {
        assertCounterGt("GetGroupsNumOps", groups - 1, rb);
        double avg = getDoubleGauge("GetGroupsAvgTime", rb);
        assertTrue(avg >= 0.0);
        // Sleep for an interval+slop to let the percentiles rollover
        Thread.sleep((PERCENTILES_INTERVAL + 1) * 1000);
        // Check that the percentiles were updated
        assertQuantileGauges("GetGroups1s", rb);
    }
}
Also used : MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder)

Example 78 with MetricsRecordBuilder

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

the class TestUserGroupInformation method verifyLoginMetrics.

public static void verifyLoginMetrics(long success, int failure) throws IOException {
    // Ensure metrics related to kerberos login is updated.
    MetricsRecordBuilder rb = getMetrics("UgiMetrics");
    if (success > 0) {
        assertCounter("LoginSuccessNumOps", success, rb);
        assertGaugeGt("LoginSuccessAvgTime", 0, rb);
    }
    if (failure > 0) {
        assertCounter("LoginFailureNumPos", failure, rb);
        assertGaugeGt("LoginFailureAvgTime", 0, rb);
    }
}
Also used : MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder)

Example 79 with MetricsRecordBuilder

use of org.apache.hadoop.metrics2.MetricsRecordBuilder 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 80 with MetricsRecordBuilder

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

the class TestMutableMetrics method testMutableQuantilesEmptyRollover.

/**
   * Test that {@link MutableQuantiles} rolls over correctly even if no items
   * have been added to the window
   */
@Test(timeout = 30000)
public void testMutableQuantilesEmptyRollover() throws Exception {
    MetricsRecordBuilder mb = mockMetricsRecordBuilder();
    MetricsRegistry registry = new MetricsRegistry("test");
    // Use a 5s rollover period
    MutableQuantiles quantiles = registry.newQuantiles("foo", "stat", "Ops", "Latency", 5);
    // Check it initially
    quantiles.snapshot(mb, true);
    verify(mb).addGauge(info("FooNumOps", "Number of ops for stat with 5s interval"), (long) 0);
    Thread.sleep(6000);
    quantiles.snapshot(mb, false);
    verify(mb, times(2)).addGauge(info("FooNumOps", "Number of ops for stat with 5s interval"), (long) 0);
}
Also used : MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder) Test(org.junit.Test)

Aggregations

MetricsRecordBuilder (org.apache.hadoop.metrics2.MetricsRecordBuilder)99 Test (org.junit.Test)47 Path (org.apache.hadoop.fs.Path)20 Configuration (org.apache.hadoop.conf.Configuration)14 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)12 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)11 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)11 FileSystem (org.apache.hadoop.fs.FileSystem)8 MetricsInfo (org.apache.hadoop.metrics2.MetricsInfo)7 IOException (java.io.IOException)6 MetricsCollector (org.apache.hadoop.metrics2.MetricsCollector)6 MetricsSource (org.apache.hadoop.metrics2.MetricsSource)5 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)4 Quantile (org.apache.hadoop.metrics2.util.Quantile)4 ServiceException (com.google.protobuf.ServiceException)3 InterruptedIOException (java.io.InterruptedIOException)2 GarbageCollectorMXBean (java.lang.management.GarbageCollectorMXBean)2 Map (java.util.Map)2 CacheDirectiveInfo (org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo)2 CachePoolInfo (org.apache.hadoop.hdfs.protocol.CachePoolInfo)2