hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdoug...@apache.org
Subject svn commit: r653638 - in /hadoop/core/trunk: CHANGES.txt src/java/org/apache/hadoop/metrics/util/MetricsIntValue.java src/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingInt.java src/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingRate.java
Date Mon, 05 May 2008 23:51:08 GMT
Author: cdouglas
Date: Mon May  5 16:51:08 2008
New Revision: 653638

URL: http://svn.apache.org/viewvc?rev=653638&view=rev
Log:
HADOOP-3085. Catch Exception in metrics util classes to ensure that
misconfigured metrics don't prevent others from updating. (cdouglas)


Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsIntValue.java
    hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingInt.java
    hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingRate.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=653638&r1=653637&r2=653638&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Mon May  5 16:51:08 2008
@@ -165,6 +165,9 @@
     HADOOP-2930. Make {start,stop}-balancer.sh work even if hadoop-daemon.sh
     is not in the PATH. (Spiros Papadimitriou via hairong)
 
+    HADOOP-3085. Catch Exception in metrics util classes to ensure that
+    misconfigured metrics don't prevent others from updating. (cdouglas)
+
 Release 0.17.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsIntValue.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsIntValue.java?rev=653638&r1=653637&r2=653638&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsIntValue.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsIntValue.java Mon May
 5 16:51:08 2008
@@ -18,7 +18,10 @@
 package org.apache.hadoop.metrics.util;
 
 import org.apache.hadoop.metrics.MetricsRecord;
+import org.apache.hadoop.util.StringUtils;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * The MetricsIntValue class is for a metric that is not time varied
@@ -28,6 +31,10 @@
  *
  */
 public class MetricsIntValue {  
+
+  protected static final Log LOG =
+    LogFactory.getLog("org.apache.hadoop.metrics.util");
+
   private String name;
   private int value;
   private boolean changed;
@@ -69,8 +76,14 @@
    * @param mr
    */
   public synchronized void pushMetric(final MetricsRecord mr) {
-    if (changed) 
-      mr.incrMetric(name, value);
+    if (changed) {
+      try {
+        mr.incrMetric(name, value);
+      } catch (Exception e) {
+        LOG.info("pushMetric failed for " + name + "\n" +
+            StringUtils.stringifyException(e));
+      }
+    }
     changed = false;
   }
 }

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingInt.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingInt.java?rev=653638&r1=653637&r2=653638&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingInt.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingInt.java Mon
May  5 16:51:08 2008
@@ -18,6 +18,10 @@
 package org.apache.hadoop.metrics.util;
 
 import org.apache.hadoop.metrics.MetricsRecord;
+import org.apache.hadoop.util.StringUtils;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * The MetricsTimeVaryingInt class is for a metric that naturally
@@ -30,6 +34,8 @@
  */
 public class MetricsTimeVaryingInt {
 
+  protected static final Log LOG =
+    LogFactory.getLog("org.apache.hadoop.metrics.util");
   
   private String name;
   private int currentValue;
@@ -76,7 +82,12 @@
    */
   public synchronized void pushMetric(final MetricsRecord mr) {
     intervalHeartBeat();
-    mr.incrMetric(name, getPreviousIntervalValue());
+    try {
+      mr.incrMetric(name, getPreviousIntervalValue());
+    } catch (Exception e) {
+      LOG.info("pushMetric failed for " + name + "\n" +
+          StringUtils.stringifyException(e));
+    }
   }
   
   

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingRate.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingRate.java?rev=653638&r1=653637&r2=653638&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingRate.java
(original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingRate.java
Mon May  5 16:51:08 2008
@@ -18,6 +18,10 @@
 package org.apache.hadoop.metrics.util;
 
 import org.apache.hadoop.metrics.MetricsRecord;
+import org.apache.hadoop.util.StringUtils;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * The MetricsTimeVaryingRate class is for a rate based metric that
@@ -30,6 +34,9 @@
  */
 public class MetricsTimeVaryingRate {
 
+  protected static final Log LOG =
+    LogFactory.getLog("org.apache.hadoop.metrics.util");
+
   static class Metrics {
     int numOperations = 0;
     long time = 0;  // total time or average time
@@ -125,8 +132,13 @@
    */
   public synchronized void pushMetric(final MetricsRecord mr) {
     intervalHeartBeat();
-    mr.incrMetric(name + "_num_ops", getPreviousIntervalNumOps());
-    mr.incrMetric(name + "_avg_time", (int)getPreviousIntervalAverageTime());
+    try {
+      mr.incrMetric(name + "_num_ops", getPreviousIntervalNumOps());
+      mr.incrMetric(name + "_avg_time", getPreviousIntervalNumOps());
+    } catch (Exception e) {
+      LOG.info("pushMetric failed for " + name + "\n" +
+          StringUtils.stringifyException(e));
+    }
   }
   
   /**



Mime
View raw message