ソースを参照

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
Jason Lowe 9 年 前
コミット
17b1a5482b

+ 0 - 3
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -1492,9 +1492,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)
 

+ 10 - 7
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;
     }
   }