hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oz...@apache.org
Subject hadoop git commit: HADOOP-11361. Fix a race condition in MetricsSourceAdapter.updateJmxCache. Contributed by Brahma Reddy Battula.
Date Thu, 14 May 2015 01:21:22 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 3a11baa15 -> 9f89c6656


HADOOP-11361. Fix a race condition in MetricsSourceAdapter.updateJmxCache. Contributed by
Brahma Reddy Battula.

(cherry picked from commit 4356e8a5ef0ac6d11a34704b80ef360a710e623a)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/9f89c665
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/9f89c665
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/9f89c665

Branch: refs/heads/branch-2
Commit: 9f89c6656efd335edce556a2115c0fc4a3e5c020
Parents: 3a11baa
Author: Tsuyoshi Ozawa <ozawa@apache.org>
Authored: Thu May 14 10:20:45 2015 +0900
Committer: Tsuyoshi Ozawa <ozawa@apache.org>
Committed: Thu May 14 10:20:57 2015 +0900

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt    |  3 +++
 .../hadoop/metrics2/impl/MetricsSourceAdapter.java | 17 +++++++----------
 2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/9f89c665/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 25dbcf9..583db4c 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -212,6 +212,9 @@ Release 2.8.0 - UNRELEASED
     HADOOP-11962. Sasl message with MD5 challenge text shouldn't be LOG out
     even in debug level. (Junping Du via wheat9)
 
+    HADOOP-11361. Fix a race condition in MetricsSourceAdapter.updateJmxCache.
+    (Brahma Reddy Battula via ozawa)
+
 Release 2.7.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/9f89c665/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java
----------------------------------------------------------------------
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 b0b758c..63a5782 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
@@ -154,31 +154,28 @@ 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;
         if (lastRecs == null) {
           getAllMetrics = true;
         }
-      }
-      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
     }
   }
 


Mime
View raw message