Search in sources :

Example 6 with MutableQuantiles

use of org.apache.hadoop.metrics2.lib.MutableQuantiles in project hive by apache.

the class LlapDaemonIOMetrics method addDecodeBatchTime.

public void addDecodeBatchTime(long latency) {
    rateOfDecoding.add(latency);
    if (latency > maxTime) {
        maxTime = latency;
        maxDecodingTime.set(maxTime);
    }
    for (MutableQuantiles q : decodingTimes) {
        q.add(latency);
    }
}
Also used : MutableQuantiles(org.apache.hadoop.metrics2.lib.MutableQuantiles)

Example 7 with MutableQuantiles

use of org.apache.hadoop.metrics2.lib.MutableQuantiles in project hive by apache.

the class LlapDaemonIOMetrics method getIoStats.

private void getIoStats(MetricsRecordBuilder rb) {
    rb.addGauge(MaxDecodingTime, maxDecodingTime.value());
    rateOfDecoding.snapshot(rb, true);
    for (MutableQuantiles q : decodingTimes) {
        q.snapshot(rb, true);
    }
}
Also used : MutableQuantiles(org.apache.hadoop.metrics2.lib.MutableQuantiles)

Example 8 with MutableQuantiles

use of org.apache.hadoop.metrics2.lib.MutableQuantiles in project hive by apache.

the class LlapDaemonExecutorMetrics method addMetricsPreemptionTimeToKill.

public void addMetricsPreemptionTimeToKill(long value) {
    totalPreemptionTimeToKill.incr(value);
    if (value > maxTimeToKill) {
        maxTimeToKill = value;
        maxPreemptionTimeToKill.set(maxTimeToKill);
    }
    for (MutableQuantiles q : percentileTimeToKill) {
        q.add(value);
    }
}
Also used : MutableQuantiles(org.apache.hadoop.metrics2.lib.MutableQuantiles)

Example 9 with MutableQuantiles

use of org.apache.hadoop.metrics2.lib.MutableQuantiles 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)

Example 10 with MutableQuantiles

use of org.apache.hadoop.metrics2.lib.MutableQuantiles in project hadoop by apache.

the class TestMutableMetrics method testMutableQuantilesError.

/**
   * Ensure that quantile estimates from {@link MutableQuantiles} are within
   * specified error bounds.
   */
@Test(timeout = 30000)
public void testMutableQuantilesError() throws Exception {
    MetricsRecordBuilder mb = mockMetricsRecordBuilder();
    MetricsRegistry registry = new MetricsRegistry("test");
    // Use a 5s rollover period
    MutableQuantiles quantiles = registry.newQuantiles("foo", "stat", "Ops", "Latency", 5);
    // Push some values in and wait for it to publish
    long start = System.nanoTime() / 1000000;
    for (long i = 1; i <= 1000; i++) {
        quantiles.add(i);
        quantiles.add(1001 - i);
    }
    long end = System.nanoTime() / 1000000;
    Thread.sleep(6000 - (end - start));
    registry.snapshot(mb, false);
    // Print out the snapshot
    Map<Quantile, Long> previousSnapshot = quantiles.previousSnapshot;
    for (Entry<Quantile, Long> item : previousSnapshot.entrySet()) {
        System.out.println(String.format("Quantile %.2f has value %d", item.getKey().quantile, item.getValue()));
    }
    // Verify the results are within our requirements
    verify(mb).addGauge(info("FooNumOps", "Number of ops for stat with 5s interval"), (long) 2000);
    Quantile[] quants = MutableQuantiles.quantiles;
    String name = "Foo%dthPercentileLatency";
    String desc = "%d percentile latency with 5 second interval for stat";
    for (Quantile q : quants) {
        int percentile = (int) (100 * q.quantile);
        int error = (int) (1000 * q.error);
        String n = String.format(name, percentile);
        String d = String.format(desc, percentile);
        long expected = (long) (q.quantile * 1000);
        verify(mb).addGauge(eq(info(n, d)), leq(expected + error));
        verify(mb).addGauge(eq(info(n, d)), geq(expected - error));
    }
}
Also used : Matchers.anyLong(org.mockito.Matchers.anyLong) Quantile(org.apache.hadoop.metrics2.util.Quantile) MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder) Test(org.junit.Test)

Aggregations

MutableQuantiles (org.apache.hadoop.metrics2.lib.MutableQuantiles)7 Test (org.junit.Test)4 MetricsRecordBuilder (org.apache.hadoop.metrics2.MetricsRecordBuilder)3 Quantile (org.apache.hadoop.metrics2.util.Quantile)2 File (java.io.File)1 MetricsSource (org.apache.hadoop.metrics2.MetricsSource)1 MetricsCollectorImpl (org.apache.hadoop.metrics2.impl.MetricsCollectorImpl)1 Matchers.anyLong (org.mockito.Matchers.anyLong)1