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);
}
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);
}
}
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);
}
}
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());
}
}
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);
}
Aggregations