HADOOP-14892. MetricsSystemImpl should use Time.monotonicNow for measuring durations. Contributed by Chetna Chaudhari.

(cherry picked from commit 3a10367a17)
(cherry picked from commit 6004fb4676)
This commit is contained in:
Akira Ajisaka 2017-09-26 01:47:02 +09:00
parent 44b51b0047
commit ea7e655897
No known key found for this signature in database
GPG Key ID: C1EDBB9CA400FD50
1 changed files with 4 additions and 4 deletions

View File

@ -415,10 +415,10 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
private void snapshotMetrics(MetricsSourceAdapter sa,
MetricsBufferBuilder bufferBuilder) {
long startTime = Time.now();
long startTime = Time.monotonicNow();
bufferBuilder.add(sa.name(), sa.getMetrics(collector, true));
collector.clear();
snapshotStat.add(Time.now() - startTime);
snapshotStat.add(Time.monotonicNow() - startTime);
LOG.debug("Snapshotted source "+ sa.name());
}
@ -431,7 +431,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
synchronized void publishMetrics(MetricsBuffer buffer, boolean immediate) {
int dropped = 0;
for (MetricsSinkAdapter sa : sinks.values()) {
long startTime = Time.now();
long startTime = Time.monotonicNow();
boolean result;
if (immediate) {
result = sa.putMetricsImmediate(buffer);
@ -439,7 +439,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
result = sa.putMetrics(buffer, logicalTime);
}
dropped += result ? 0 : 1;
publishStat.add(Time.now() - startTime);
publishStat.add(Time.monotonicNow() - startTime);
}
droppedPubAll.incr(dropped);
}