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 WRITE_LOCK_METRIC_PREFIX = "FSNWriteLock";
|
||||||
private static final String LOCK_METRIC_SUFFIX = "Nanos";
|
private static final String LOCK_METRIC_SUFFIX = "Nanos";
|
||||||
|
|
||||||
|
private static final String OVERALL_METRIC_NAME = "Overall";
|
||||||
|
|
||||||
FSNamesystemLock(Configuration conf,
|
FSNamesystemLock(Configuration conf,
|
||||||
MutableRatesWithAggregation detailedHoldTimeMetrics) {
|
MutableRatesWithAggregation detailedHoldTimeMetrics) {
|
||||||
this(conf, detailedHoldTimeMetrics, new Timer());
|
this(conf, detailedHoldTimeMetrics, new Timer());
|
||||||
@ -320,12 +322,17 @@ public int getQueueLength() {
|
|||||||
*/
|
*/
|
||||||
private void addMetric(String operationName, long value, boolean isWrite) {
|
private void addMetric(String operationName, long value, boolean isWrite) {
|
||||||
if (metricsEnabled) {
|
if (metricsEnabled) {
|
||||||
String metricName =
|
String opMetric = getMetricName(operationName, isWrite);
|
||||||
(isWrite ? WRITE_LOCK_METRIC_PREFIX : READ_LOCK_METRIC_PREFIX) +
|
detailedHoldTimeMetrics.add(opMetric, value);
|
||||||
org.apache.commons.lang.StringUtils.capitalize(operationName) +
|
|
||||||
LOCK_METRIC_SUFFIX;
|
String overallMetric = getMetricName(OVERALL_METRIC_NAME, isWrite);
|
||||||
detailedHoldTimeMetrics.add(metricName, value);
|
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);
|
FSNamesystemLock fsLock = new FSNamesystemLock(conf, rates, timer);
|
||||||
|
|
||||||
fsLock.readLock();
|
fsLock.readLock();
|
||||||
timer.advanceNanos(1200000);
|
timer.advanceNanos(1300000);
|
||||||
fsLock.readUnlock("foo");
|
fsLock.readUnlock("foo");
|
||||||
fsLock.readLock();
|
fsLock.readLock();
|
||||||
timer.advanceNanos(2400000);
|
timer.advanceNanos(2400000);
|
||||||
@ -353,12 +353,18 @@ public void testDetailedHoldMetrics() throws Exception {
|
|||||||
MetricsRecordBuilder rb = MetricsAsserts.mockMetricsRecordBuilder();
|
MetricsRecordBuilder rb = MetricsAsserts.mockMetricsRecordBuilder();
|
||||||
rates.snapshot(rb, true);
|
rates.snapshot(rb, true);
|
||||||
|
|
||||||
assertGauge("FSNReadLockFooNanosAvgTime", 1800000.0, rb);
|
assertGauge("FSNReadLockFooNanosAvgTime", 1850000.0, rb);
|
||||||
assertCounter("FSNReadLockFooNanosNumOps", 2L, rb);
|
assertCounter("FSNReadLockFooNanosNumOps", 2L, rb);
|
||||||
assertGauge("FSNReadLockBarNanosAvgTime", 2000000.0, rb);
|
assertGauge("FSNReadLockBarNanosAvgTime", 2000000.0, rb);
|
||||||
assertCounter("FSNReadLockBarNanosNumOps", 1L, rb);
|
assertCounter("FSNReadLockBarNanosNumOps", 1L, rb);
|
||||||
assertGauge("FSNWriteLockBazNanosAvgTime", 1000000.0, rb);
|
assertGauge("FSNWriteLockBazNanosAvgTime", 1000000.0, rb);
|
||||||
assertCounter("FSNWriteLockBazNanosNumOps", 1L, 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