HDFS-13686. Add overall metrics for FSNamesystemLock. Contributed by Lukas Majercak.
This commit is contained in:
parent
1da3b55659
commit
d31a3ce767
@ -107,6 +107,8 @@ public Long initialValue() {
|
||||
private static final String WRITE_LOCK_METRIC_PREFIX = "FSNWriteLock";
|
||||
private static final String LOCK_METRIC_SUFFIX = "Nanos";
|
||||
|
||||
private static final String OVERALL_METRIC_NAME = "Overall";
|
||||
|
||||
FSNamesystemLock(Configuration conf,
|
||||
MutableRatesWithAggregation detailedHoldTimeMetrics) {
|
||||
this(conf, detailedHoldTimeMetrics, new Timer());
|
||||
@ -320,12 +322,17 @@ public int getQueueLength() {
|
||||
*/
|
||||
private void addMetric(String operationName, long value, boolean isWrite) {
|
||||
if (metricsEnabled) {
|
||||
String metricName =
|
||||
(isWrite ? WRITE_LOCK_METRIC_PREFIX : READ_LOCK_METRIC_PREFIX) +
|
||||
org.apache.commons.lang.StringUtils.capitalize(operationName) +
|
||||
LOCK_METRIC_SUFFIX;
|
||||
detailedHoldTimeMetrics.add(metricName, value);
|
||||
String opMetric = getMetricName(operationName, isWrite);
|
||||
detailedHoldTimeMetrics.add(opMetric, value);
|
||||
|
||||
String overallMetric = getMetricName(OVERALL_METRIC_NAME, isWrite);
|
||||
detailedHoldTimeMetrics.add(overallMetric, value);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getMetricName(String operationName, boolean isWrite) {
|
||||
return (isWrite ? WRITE_LOCK_METRIC_PREFIX : READ_LOCK_METRIC_PREFIX) +
|
||||
org.apache.commons.lang.StringUtils.capitalize(operationName) +
|
||||
LOCK_METRIC_SUFFIX;
|
||||
}
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ public void testDetailedHoldMetrics() throws Exception {
|
||||
FSNamesystemLock fsLock = new FSNamesystemLock(conf, rates, timer);
|
||||
|
||||
fsLock.readLock();
|
||||
timer.advanceNanos(1200000);
|
||||
timer.advanceNanos(1300000);
|
||||
fsLock.readUnlock("foo");
|
||||
fsLock.readLock();
|
||||
timer.advanceNanos(2400000);
|
||||
@ -353,12 +353,18 @@ public void testDetailedHoldMetrics() throws Exception {
|
||||
MetricsRecordBuilder rb = MetricsAsserts.mockMetricsRecordBuilder();
|
||||
rates.snapshot(rb, true);
|
||||
|
||||
assertGauge("FSNReadLockFooNanosAvgTime", 1800000.0, rb);
|
||||
assertGauge("FSNReadLockFooNanosAvgTime", 1850000.0, rb);
|
||||
assertCounter("FSNReadLockFooNanosNumOps", 2L, rb);
|
||||
assertGauge("FSNReadLockBarNanosAvgTime", 2000000.0, rb);
|
||||
assertCounter("FSNReadLockBarNanosNumOps", 1L, rb);
|
||||
assertGauge("FSNWriteLockBazNanosAvgTime", 1000000.0, rb);
|
||||
assertCounter("FSNWriteLockBazNanosNumOps", 1L, rb);
|
||||
|
||||
// Overall
|
||||
assertGauge("FSNReadLockOverallNanosAvgTime", 1900000.0, rb);
|
||||
assertCounter("FSNReadLockOverallNanosNumOps", 3L, rb);
|
||||
assertGauge("FSNWriteLockOverallNanosAvgTime", 1000000.0, rb);
|
||||
assertCounter("FSNWriteLockOverallNanosNumOps", 1L, rb);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user