hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1576187 - in /hadoop/common/trunk/hadoop-common-project/hadoop-common: CHANGES.txt src/main/java/org/apache/hadoop/metrics/util/MetricsRegistry.java
Date Tue, 11 Mar 2014 04:34:13 GMT
Author: stack
Date: Tue Mar 11 04:34:13 2014
New Revision: 1576187

URL: http://svn.apache.org/r1576187
Log:
HADOOP-10337 ConcurrentModificationException from MetricsDynamicMBeanBase.createMBeanInfo()
(Liang Xie via stack)

Modified:
    hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
    hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsRegistry.java

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1576187&r1=1576186&r2=1576187&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Tue Mar 11 04:34:13
2014
@@ -416,6 +416,9 @@ Release 2.4.0 - UNRELEASED
     HADOOP-10395. TestCallQueueManager is flaky. (Arpit Agarwal)
 
     HADOOP-10394. TestAuthenticationFilter is flaky. (Arpit Agarwal)
+    
+    HADOOP-10337 ConcurrentModificationException from
+    MetricsDynamicMBeanBase.createMBeanInfo() (Liang Xie via stack)
 
   BREAKDOWN OF HADOOP-10184 SUBTASKS AND RELATED JIRAS
 

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsRegistry.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsRegistry.java?rev=1576187&r1=1576186&r2=1576187&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsRegistry.java
(original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsRegistry.java
Tue Mar 11 04:34:13 2014
@@ -18,8 +18,7 @@
 package org.apache.hadoop.metrics.util;
 
 import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 
@@ -32,7 +31,8 @@ import org.apache.hadoop.classification.
  */
 @InterfaceAudience.LimitedPrivate({"HDFS", "MapReduce"})
 public class MetricsRegistry {
-  private Map<String, MetricsBase> metricsList = new HashMap<String, MetricsBase>();
+  private ConcurrentHashMap<String, MetricsBase> metricsList =
+      new ConcurrentHashMap<String, MetricsBase>();
 
   public MetricsRegistry() {
   }
@@ -51,11 +51,11 @@ public class MetricsRegistry {
    * @param theMetricsObj - the metrics
    * @throws IllegalArgumentException if a name is already registered
    */
-  public synchronized void add(final String metricsName, final MetricsBase theMetricsObj)
{
-    if (metricsList.containsKey(metricsName)) {
-      throw new IllegalArgumentException("Duplicate metricsName:" + metricsName);
+  public void add(final String metricsName, final MetricsBase theMetricsObj) {
+    if (metricsList.putIfAbsent(metricsName, theMetricsObj) != null) {
+      throw new IllegalArgumentException("Duplicate metricsName:" +
+          metricsName);
     }
-    metricsList.put(metricsName, theMetricsObj);
   }
 
   
@@ -65,7 +65,7 @@ public class MetricsRegistry {
    * @return the metrics if there is one registered by the supplied name.
    *         Returns null if none is registered
    */
-  public synchronized MetricsBase get(final String metricsName) {
+  public MetricsBase get(final String metricsName) {
     return metricsList.get(metricsName);
   }
   
@@ -74,7 +74,7 @@ public class MetricsRegistry {
    * 
    * @return the list of metrics names
    */
-  public synchronized Collection<String> getKeyList() {
+  public Collection<String> getKeyList() {
     return metricsList.keySet();
   }
   
@@ -82,7 +82,7 @@ public class MetricsRegistry {
    * 
    * @return the list of metrics
    */
-  public synchronized Collection<MetricsBase> getMetricsList() {
+  public Collection<MetricsBase> getMetricsList() {
     return metricsList.values();
   }
 }



Mime
View raw message