From 2946621a531bd71e2408951ab72ecaf5f9fea3f0 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Tue, 24 Nov 2015 19:12:04 +0000 Subject: [PATCH] Revert "HADOOP-11361. Fix a race condition in MetricsSourceAdapter.updateJmxCache. Contributed by Brahma Reddy Battula." This reverts commit 4356e8a5ef0ac6d11a34704b80ef360a710e623a. Conflicts: hadoop-common-project/hadoop-common/CHANGES.txt hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java (cherry picked from commit 17b1a5482b32dab82225e8233648990bc77674ba) --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 --- .../metrics2/impl/MetricsSourceAdapter.java | 17 ++++++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 7065abcbaad..3ea617bc556 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -25,9 +25,6 @@ Release 2.7.3 - UNRELEASED HADOOP-12374. Updated expunge command description. (WeiWei Yang via eyang) - HADOOP-11361. Fix a race condition in MetricsSourceAdapter.updateJmxCache. - (Brahma Reddy Battula via ozawa) - HADOOP-12348. MetricsSystemImpl creates MetricsSourceAdapter with wrong time unit parameter. (zxu via rkanter) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java index 706ef7eb4f9..d56ee532201 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java @@ -158,7 +158,7 @@ class MetricsSourceAdapter implements DynamicMBean { private void updateJmxCache() { boolean getAllMetrics = false; - synchronized (this) { + synchronized(this) { if (Time.now() - jmxCacheTS >= jmxCacheTTL) { // temporarilly advance the expiry while updating the cache jmxCacheTS = Time.now() + jmxCacheTTL; @@ -169,21 +169,24 @@ class MetricsSourceAdapter implements DynamicMBean { getAllMetrics = true; lastRecsCleared = false; } - } else { + } + else { return; } + } - if (getAllMetrics) { - MetricsCollectorImpl builder = new MetricsCollectorImpl(); - getMetrics(builder, true); - } + if (getAllMetrics) { + MetricsCollectorImpl builder = new MetricsCollectorImpl(); + getMetrics(builder, true); + } + synchronized(this) { updateAttrCache(); if (getAllMetrics) { updateInfoCache(); } jmxCacheTS = Time.now(); - lastRecs = null; // in case regular interval update is not running + lastRecs = null; // in case regular interval update is not running lastRecsCleared = true; } }