Browse Source

HADOOP-1135, HADOOP-1145, HADOOP-1140, HADOOP-1150: Merge -r 519461:521864 from trunk, preparing for 0.12.2 release.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/branches/branch-0.12@521866 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 years ago
parent
commit
79768d05e4

+ 14 - 0
CHANGES.txt

@@ -1,6 +1,20 @@
 Hadoop Change Log
 
 
+Release 0.12.2 - 2007-23-17
+
+ 1. HADOOP-1135.  Fix bug in block report processing which may cause
+    the namenode to delete blocks.  (Dhruba Borthakur via tomwhite)
+
+ 2. HADOOP-1145.  Make XML serializer and deserializer classes public
+    in record package.  (Milind Bhandarkar via cutting)
+
+ 3. HADOOP-1140.  Fix a deadlock in metrics. (David Bowen via cutting)
+
+ 4. HADOOP-1150.  Fix streaming -reducer and -mapper to give them
+    defaults. (Owen O'Malley via tomwhite)
+
+
 Release 0.12.1 - 2007-03-17
 
  1. HADOOP-1035.  Fix a StackOverflowError in FSDataSet.

+ 1 - 1
build.xml

@@ -9,7 +9,7 @@
  
   <property name="Name" value="Hadoop"/>
   <property name="name" value="hadoop"/>
-  <property name="version" value="0.12.2-dev"/>
+  <property name="version" value="0.12.3-dev"/>
   <property name="final.name" value="${name}-${version}"/>
   <property name="year" value="2006"/>
   <property name="libhdfs.version" value="1"/>

+ 38 - 29
docs/index.html

@@ -131,6 +131,9 @@ document.write("<text>Last Published:</text> " + document.lastModified);
 <a href="#News">News</a>
 <ul class="minitoc">
 <li>
+<a href="#23+March%2C+2007%3A+release+0.12.2+available">23 March, 2007: release 0.12.2 available</a>
+</li>
+<li>
 <a href="#17+March%2C+2007%3A+release+0.12.1+available">17 March, 2007: release 0.12.1 available</a>
 </li>
 <li>
@@ -226,151 +229,157 @@ document.write("<text>Last Published:</text> " + document.lastModified);
 <a name="N1000C"></a><a name="News"></a>
 <h2 class="h3">News</h2>
 <div class="section">
-<a name="N10012"></a><a name="17+March%2C+2007%3A+release+0.12.1+available"></a>
+<a name="N10012"></a><a name="23+March%2C+2007%3A+release+0.12.2+available"></a>
+<h3 class="h4">23 March, 2007: release 0.12.2 available</h3>
+<p>For details see the <a href="http://tinyurl.com/2r7kcw">release notes</a>. The release can
+      be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
+      nearby mirror</a>.
+      </p>
+<a name="N10024"></a><a name="17+March%2C+2007%3A+release+0.12.1+available"></a>
 <h3 class="h4">17 March, 2007: release 0.12.1 available</h3>
 <p>For details see the <a href="http://tinyurl.com/2kynuc">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N10024"></a><a name="2+March%2C+2007%3A+release+0.12.0+available"></a>
+<a name="N10036"></a><a name="2+March%2C+2007%3A+release+0.12.0+available"></a>
 <h3 class="h4">2 March, 2007: release 0.12.0 available</h3>
 <p>For details see the <a href="http://tinyurl.com/2vp248">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N10036"></a><a name="16+February%2C+2007%3A+release+0.11.2+available"></a>
+<a name="N10048"></a><a name="16+February%2C+2007%3A+release+0.11.2+available"></a>
 <h3 class="h4">16 February, 2007: release 0.11.2 available</h3>
 <p>This fixes critical bugs in 0.11.1. For details see the <a href="http://tinyurl.com/2ukkt3">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N10048"></a><a name="9+February%2C+2007%3A+release+0.11.1+available"></a>
+<a name="N1005A"></a><a name="9+February%2C+2007%3A+release+0.11.1+available"></a>
 <h3 class="h4">9 February, 2007: release 0.11.1 available</h3>
 <p>This fixes bugs in 0.11.0. For details see the <a href="http://tinyurl.com/37c5a3">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N1005A"></a><a name="2+February%2C+2007%3A+release+0.11.0+available"></a>
+<a name="N1006C"></a><a name="2+February%2C+2007%3A+release+0.11.0+available"></a>
 <h3 class="h4">2 February, 2007: release 0.11.0 available</h3>
 <p>For details see the <a href="http://tinyurl.com/2yn8zs">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N1006C"></a><a name="10+January%2C+2007%3A+release+0.10.1+available"></a>
+<a name="N1007E"></a><a name="10+January%2C+2007%3A+release+0.10.1+available"></a>
 <h3 class="h4">10 January, 2007: release 0.10.1 available</h3>
 <p>This fixes critical bugs in 0.10.0.  For details see the <a href="http://tinyurl.com/ycpsms">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N1007E"></a><a name="5+January%2C+2007%3A+release+0.10.0+available"></a>
+<a name="N10090"></a><a name="5+January%2C+2007%3A+release+0.10.0+available"></a>
 <h3 class="h4">5 January, 2007: release 0.10.0 available</h3>
 <p>For details see the <a href="http://tinyurl.com/yapkxs">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N10090"></a><a name="15+December%2C+2006%3A+release+0.9.2+available"></a>
+<a name="N100A2"></a><a name="15+December%2C+2006%3A+release+0.9.2+available"></a>
 <h3 class="h4">15 December, 2006: release 0.9.2 available</h3>
 <p>This fixes critical bugs in 0.9.1.  For details see the <a href="http://tinyurl.com/ya8lfd">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N100A2"></a><a name="6+December%2C+2006%3A+release+0.9.1+available"></a>
+<a name="N100B4"></a><a name="6+December%2C+2006%3A+release+0.9.1+available"></a>
 <h3 class="h4">6 December, 2006: release 0.9.1 available</h3>
 <p>This fixes critical bugs in 0.9.0.  For details see the <a href="http://tinyurl.com/y55d7p">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N100B4"></a><a name="1+December%2C+2006%3A+release+0.9.0+available"></a>
+<a name="N100C6"></a><a name="1+December%2C+2006%3A+release+0.9.0+available"></a>
 <h3 class="h4">1 December, 2006: release 0.9.0 available</h3>
 <p>For details see the <a href="http://tinyurl.com/sdjhb">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N100C6"></a><a name="3+November%2C+2006%3A+release+0.8.0+available"></a>
+<a name="N100D8"></a><a name="3+November%2C+2006%3A+release+0.8.0+available"></a>
 <h3 class="h4">3 November, 2006: release 0.8.0 available</h3>
 <p>For details see the <a href="http://tinyurl.com/ykqv6s">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N100D8"></a><a name="18+October%2C+2006%3A+release+0.7.2+available"></a>
+<a name="N100EA"></a><a name="18+October%2C+2006%3A+release+0.7.2+available"></a>
 <h3 class="h4">18 October, 2006: release 0.7.2 available</h3>
 <p>This fixes critical bugs in 0.7.1.  For details see the <a href="http://tinyurl.com/ygy6y7">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N100EA"></a><a name="11+October%2C+2006%3A+release+0.7.1+available"></a>
+<a name="N100FC"></a><a name="11+October%2C+2006%3A+release+0.7.1+available"></a>
 <h3 class="h4">11 October, 2006: release 0.7.1 available</h3>
 <p>This fixes critical bugs in 0.7.0.  For details see the <a href="http://tinyurl.com/p7qod">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N100FC"></a><a name="6+October%2C+2006%3A+release+0.7.0+available"></a>
+<a name="N1010E"></a><a name="6+October%2C+2006%3A+release+0.7.0+available"></a>
 <h3 class="h4">6 October, 2006: release 0.7.0 available</h3>
 <p>For details see the <a href="http://tinyurl.com/kvd9m">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N1010E"></a><a name="18+September%2C+2006%3A+release+0.6.2+available"></a>
+<a name="N10120"></a><a name="18+September%2C+2006%3A+release+0.6.2+available"></a>
 <h3 class="h4">18 September, 2006: release 0.6.2 available</h3>
 <p>This fixes critical bugs in 0.6.1.  For details see the <a href="http://tinyurl.com/gyb56">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N10120"></a><a name="13+September%2C+2006%3A+release+0.6.1+available"></a>
+<a name="N10132"></a><a name="13+September%2C+2006%3A+release+0.6.1+available"></a>
 <h3 class="h4">13 September, 2006: release 0.6.1 available</h3>
 <p>This fixes critical bugs in 0.6.0.  For details see the <a href="http://tinyurl.com/lykp4">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N10132"></a><a name="8+September%2C+2006%3A+release+0.6.0+available"></a>
+<a name="N10144"></a><a name="8+September%2C+2006%3A+release+0.6.0+available"></a>
 <h3 class="h4">8 September, 2006: release 0.6.0 available</h3>
 <p>For details see the <a href="http://tinyurl.com/r3zoj">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N10144"></a><a name="4+August%2C+2006%3A+release+0.5.0+available"></a>
+<a name="N10156"></a><a name="4+August%2C+2006%3A+release+0.5.0+available"></a>
 <h3 class="h4">4 August, 2006: release 0.5.0 available</h3>
 <p>For details see the <a href="http://tinyurl.com/pnml2">release notes</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N10156"></a><a name="28+June%2C+2006%3A+release+0.4.0+available"></a>
+<a name="N10168"></a><a name="28+June%2C+2006%3A+release+0.4.0+available"></a>
 <h3 class="h4">28 June, 2006: release 0.4.0 available</h3>
 <p>For details see the <a href="http://tinyurl.com/o35b6">change log</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N10168"></a><a name="9+June%2C+2006%3A+release+0.3.2+available"></a>
+<a name="N1017A"></a><a name="9+June%2C+2006%3A+release+0.3.2+available"></a>
 <h3 class="h4">9 June, 2006: release 0.3.2 available</h3>
 <p>This is a bugfix release.  For details see the <a href="http://tinyurl.com/k9g5c">change log</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N1017A"></a><a name="8+June%2C+2006%3A+FAQ+added+to+Wiki"></a>
+<a name="N1018C"></a><a name="8+June%2C+2006%3A+FAQ+added+to+Wiki"></a>
 <h3 class="h4">8 June, 2006: FAQ added to Wiki</h3>
 <p>Hadoop now has a <a href="http://wiki.apache.org/lucene-hadoop/FAQ">FAQ</a>.  Please
       help make this more complete!
       </p>
-<a name="N10188"></a><a name="5+June%2C+2006%3A+release+0.3.1+available"></a>
+<a name="N1019A"></a><a name="5+June%2C+2006%3A+release+0.3.1+available"></a>
 <h3 class="h4">5 June, 2006: release 0.3.1 available</h3>
 <p>This is a bugfix release.  For details see the <a href="http://tinyurl.com/l6on4">change log</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N1019A"></a><a name="2+June%2C+2006%3A+release+0.3.0+available"></a>
+<a name="N101AC"></a><a name="2+June%2C+2006%3A+release+0.3.0+available"></a>
 <h3 class="h4">2 June, 2006: release 0.3.0 available</h3>
 <p>This includes many fixes, improving performance, scalability
       and reliability and adding new features.  For details see the <a href="http://tinyurl.com/rq3f7">change log</a>. The release can
       be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N101AC"></a><a name="12+May%2C+2006%3A+release+0.2.1+available"></a>
+<a name="N101BE"></a><a name="12+May%2C+2006%3A+release+0.2.1+available"></a>
 <h3 class="h4">12 May, 2006: release 0.2.1 available</h3>
 <p>This fixes a few bugs in release 0.2.0, listed in the <a href="http://tinyurl.com/rnnvz">change log</a>. The
       release can be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N101BE"></a><a name="5+May%2C+2006%3A+release+0.2.0+available"></a>
+<a name="N101D0"></a><a name="5+May%2C+2006%3A+release+0.2.0+available"></a>
 <h3 class="h4">5 May, 2006: release 0.2.0 available</h3>
 <p>We are now aiming for monthly releases.  There have been many
       bug fixes and improvements in the past month.  MapReduce and DFS
@@ -379,24 +388,24 @@ document.write("<text>Last Published:</text> " + document.lastModified);
       details. The release can be obtained from <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
       nearby mirror</a>.
       </p>
-<a name="N101D0"></a><a name="2+April%2C+2006%3A+release+0.1.0+available"></a>
+<a name="N101E2"></a><a name="2+April%2C+2006%3A+release+0.1.0+available"></a>
 <h3 class="h4">2 April, 2006: release 0.1.0 available</h3>
 <p>This is the first Hadoop release.  The release is available
       <a href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/">
       here</a>.</p>
-<a name="N101DE"></a><a name="6+February%2C+2006%3A+nightly+builds"></a>
+<a name="N101F0"></a><a name="6+February%2C+2006%3A+nightly+builds"></a>
 <h3 class="h4">6 February, 2006: nightly builds</h3>
 <p>Hadoop now has nightly builds.  This automatically creates a
       <a href="http://lucene.zones.apache.org:8080/hudson/job/Hadoop-Nightly/">downloadable version of Hadoop every
       night</a>.  All unit tests must pass, or a message is sent to
       the developers mailing list and no new version is created.  This
       also updates the <a href="api/index.html">javadoc</a>.</p>
-<a name="N101F0"></a><a name="3+February%2C+2006%3A+Hadoop+code+moved+out+of+Nutch"></a>
+<a name="N10202"></a><a name="3+February%2C+2006%3A+Hadoop+code+moved+out+of+Nutch"></a>
 <h3 class="h4">3 February, 2006: Hadoop code moved out of Nutch</h3>
 <p>The Hadoop code has now been moved into its own Subversion
       tree, renamed into packages under <span class="codefrag">org.apache.hadoop</span>.
       All unit tests pass, but little else has yet been tested.</p>
-<a name="N101FD"></a><a name="30+March%2C+2006%3A+Hadoop+project+approved"></a>
+<a name="N1020F"></a><a name="30+March%2C+2006%3A+Hadoop+project+approved"></a>
 <h3 class="h4">30 March, 2006: Hadoop project approved</h3>
 <p>The Lucene PMC has elected to split the Nutch MapReduce and
       distributed filesytem code into a new project named Hadoop.</p>

File diff suppressed because it is too large
+ 37 - 26
docs/index.pdf


+ 12 - 8
src/contrib/streaming/src/java/org/apache/hadoop/streaming/StreamJob.java

@@ -368,12 +368,12 @@ public class StreamJob {
         "DFS output directory for the Reduce step", 
         "path", 1, true); 
     Option mapper  = createOption("mapper", 
-        "The streaming command to run", "cmd", 1, true);
+        "The streaming command to run", "cmd", 1, false);
     Option combiner = createOption("combiner", 
         "The streaming command to run", "cmd",1, false);
     // reducer could be NONE 
     Option reducer = createOption("reducer", 
-        "The streaming command to run", "cmd", 1, true); 
+        "The streaming command to run", "cmd", 1, false); 
     Option file = createOption("file", 
         "File/dir to be shipped in the Job jar file", 
         "file", Integer.MAX_VALUE, false, execValidator); 
@@ -692,12 +692,16 @@ public class StreamJob {
 
     String defaultPackage = this.getClass().getPackage().getName();
 
-    Class c = StreamUtil.goodClassOrNull(mapCmd_, defaultPackage);
-    if (c != null) {
-      jobConf_.setMapperClass(c);
-    } else {
-      jobConf_.setMapperClass(PipeMapper.class);
-      jobConf_.set("stream.map.streamprocessor", URLEncoder.encode(mapCmd_, "UTF-8"));
+    Class c;
+    if (mapCmd_ != null) {
+      c = StreamUtil.goodClassOrNull(mapCmd_, defaultPackage);
+      if (c != null) {
+        jobConf_.setMapperClass(c);
+      } else {
+        jobConf_.setMapperClass(PipeMapper.class);
+        jobConf_.set("stream.map.streamprocessor", 
+                     URLEncoder.encode(mapCmd_, "UTF-8"));
+      }
     }
 
     if (comCmd_ != null) {

+ 9 - 0
src/docs/src/documentation/content/xdocs/index.xml

@@ -14,6 +14,15 @@
     <section>
       <title>News</title>
 
+      <section>
+      <title>23 March, 2007: release 0.12.2 available</title>
+      <p>For details see the <a
+      href="http://tinyurl.com/2r7kcw">release notes</a>. The release can
+      be obtained from <a
+      href="http://www.apache.org/dyn/closer.cgi/lucene/hadoop/"> a
+      nearby mirror</a>.
+      </p> </section>
+
       <section>
       <title>17 March, 2007: release 0.12.1 available</title>
       <p>For details see the <a

+ 6 - 6
src/java/org/apache/hadoop/dfs/FSNamesystem.java

@@ -2051,14 +2051,14 @@ class FSNamesystem implements FSConstants {
             // they are added to recentInvalidateSets and will be sent out
             // thorugh succeeding heartbeat responses.
             //
-            if (obsolete.size() > FSConstants.BLOCK_INVALIDATE_CHUNK) {
+            if (! dir.isValidBlock(b) && ! pendingCreateBlocks.contains(b)) {
+              if (obsolete.size() > FSConstants.BLOCK_INVALIDATE_CHUNK) {
                 addToInvalidates(b, node);
-            } else {
-                if (! dir.isValidBlock(b) && ! pendingCreateBlocks.contains(b)) {
-                  obsolete.add(b);
-                  NameNode.stateChangeLog.debug("BLOCK* NameSystem.processReport: "
+              } else {
+                obsolete.add(b);
+              }
+              NameNode.stateChangeLog.debug("BLOCK* NameSystem.processReport: "
                         +"ask "+nodeID.getName()+" to delete "+b.getBlockName() );
-                }
             }
         }
         return (Block[]) obsolete.toArray(new Block[obsolete.size()]);

+ 53 - 64
src/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java

@@ -21,6 +21,8 @@
 package org.apache.hadoop.metrics.spi;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -50,35 +52,30 @@ public abstract class AbstractMetricsContext implements MetricsContext {
     private int period = MetricsContext.DEFAULT_PERIOD;
     private Timer timer = null;
     
-    //private Set<Updater> updaters = new HashSet<Updater>(1);
-    private Set updaters = new HashSet(1);
-    private boolean isMonitoring = false;
+    private Set<Updater> updaters = new HashSet<Updater>(1);
+    private volatile boolean isMonitoring = false;
     
     private ContextFactory factory = null;
     private String contextName = null;
     
-    //static class TagMap extends TreeMap<String,Object> {
-    static class TagMap extends TreeMap {
-		private static final long serialVersionUID = 3546309335061952993L;
-		TagMap() {
+    static class TagMap extends TreeMap<String,Object> {
+        private static final long serialVersionUID = 3546309335061952993L;
+        TagMap() {
             super();
         }
         TagMap(TagMap orig) {
             super(orig);
         }
     }
-    //static class MetricMap extends TreeMap<String,Number> {}
-    static class MetricMap extends TreeMap {
-		private static final long serialVersionUID = -7495051861141631609L;
+    static class MetricMap extends TreeMap<String,Number> {
+        private static final long serialVersionUID = -7495051861141631609L;
     }
             
-    //static class RecordMap extends HashMap<TagMap,MetricMap> {}
-    static class RecordMap extends HashMap {
-		private static final long serialVersionUID = 259835619700264611L;
+    static class RecordMap extends HashMap<TagMap,MetricMap> {
+        private static final long serialVersionUID = 259835619700264611L;
     }
     
-    //private Map<String,RecordMap> bufferedData = new HashMap<String,RecordMap>();
-    private Map bufferedData = new HashMap();
+    private Map<String,RecordMap> bufferedData = new HashMap<String,RecordMap>();
     
 
     /**
@@ -110,15 +107,10 @@ public abstract class AbstractMetricsContext implements MetricsContext {
      * <i>contextName</i>.<i>tableName</i>.  The returned map consists of
      * those attributes with the contextName and tableName stripped off.
      */
-    //protected Map<String,String> getAttributeTable(String tableName) {
-    protected Map getAttributeTable(String tableName) {
+    protected Map<String,String> getAttributeTable(String tableName) {
         String prefix = contextName + "." + tableName + ".";
-        //Map<String,String> result = new HashMap<String,String>();
-        //for (String attributeName : factory.getAttributeNames()) {
-        Map result = new HashMap();
-        String[] attributeNames = factory.getAttributeNames();
-        for (int i = 0; i < attributeNames.length; i++) {
-            String attributeName = attributeNames[i];
+        Map<String,String> result = new HashMap<String,String>();
+        for (String attributeName : factory.getAttributeNames()) {
             if (attributeName.startsWith(prefix)) {
                 String name = attributeName.substring(prefix.length());
                 String value = (String) factory.getAttribute(attributeName);
@@ -201,7 +193,7 @@ public abstract class AbstractMetricsContext implements MetricsContext {
      * @return newly created instance of MetricsRecordImpl or subclass
      */
     protected MetricsRecordImpl newRecord(String recordName) {
-    	return new MetricsRecordImpl(recordName, this);
+        return new MetricsRecordImpl(recordName, this);
     }
     
     /**
@@ -238,12 +230,12 @@ public abstract class AbstractMetricsContext implements MetricsContext {
             timer = new Timer();
             TimerTask task = new TimerTask() {
                 public void run() {
-                	try {
-                		timerEvent();
-                	}
-                	catch (IOException ioe) {
-                		ioe.printStackTrace();
-                	}
+                    try {
+                        timerEvent();
+                    }
+                    catch (IOException ioe) {
+                        ioe.printStackTrace();
+                    }
                 }
             };
             long millis = period * 1000;
@@ -264,13 +256,15 @@ public abstract class AbstractMetricsContext implements MetricsContext {
     /**
      * Timer callback.
      */
-    private synchronized void timerEvent() throws IOException {
+    private void timerEvent() throws IOException {
         if (isMonitoring) {
-            // Run all the registered updates
-            // for (Updater updater : updaters) {
-            Iterator it = updaters.iterator();
-            while (it.hasNext()) {
-                Updater updater = (Updater) it.next();
+            Collection<Updater> myUpdaters;
+            synchronized (this) {
+                myUpdaters = new ArrayList<Updater>(updaters);
+            }     
+            // Run all the registered updates without holding a lock
+            // on this context
+            for (Updater updater : myUpdaters) {
                 try {
                     updater.doUpdates(this);
                 }
@@ -278,28 +272,27 @@ public abstract class AbstractMetricsContext implements MetricsContext {
                     throwable.printStackTrace();
                 }
             }
-            
-            // Emit the records
-            //for (String recordName : bufferedData.keySet()) {
-            Iterator recordIt = bufferedData.keySet().iterator();
-            while (recordIt.hasNext()) {
-                String recordName = (String) recordIt.next();
-                RecordMap recordMap = (RecordMap) bufferedData.get(recordName);
-                synchronized (recordMap) {
-                    //for (TagMap tagMap : recordMap.keySet()) {
-                    Iterator tagIt = recordMap.keySet().iterator();
-                    while (tagIt.hasNext()) {
-                        TagMap tagMap = (TagMap) tagIt.next();
-                        MetricMap metricMap = (MetricMap) recordMap.get(tagMap);
-                        OutputRecord outRec = new OutputRecord(tagMap, metricMap);
-                        emitRecord(contextName, recordName, outRec);
-                    }
+            emitRecords();
+        }
+    }
+    
+    /**
+     *  Emits the records.
+     */
+    private synchronized void emitRecords() throws IOException {
+        for (String recordName : bufferedData.keySet()) {
+            RecordMap recordMap = bufferedData.get(recordName);
+            synchronized (recordMap) {
+                for (TagMap tagMap : recordMap.keySet()) {
+                    MetricMap metricMap = recordMap.get(tagMap);
+                    OutputRecord outRec = new OutputRecord(tagMap, metricMap);
+                    emitRecord(contextName, recordName, outRec);
                 }
             }
-            flush();
         }
+        flush();
     }
-    
+
     /**
      * Sends a record to the metrics system.
      */
@@ -320,24 +313,20 @@ public abstract class AbstractMetricsContext implements MetricsContext {
     protected void update(MetricsRecordImpl record) {
         String recordName = record.getRecordName();
         TagMap tagTable = record.getTagTable();
-        //Map<String,MetricValue> metricUpdates = record.getMetricTable();
-        Map metricUpdates = record.getMetricTable();
+        Map<String,MetricValue> metricUpdates = record.getMetricTable();
         
         RecordMap recordMap = getRecordMap(recordName);
         synchronized (recordMap) {
-            MetricMap metricMap = (MetricMap) recordMap.get(tagTable);
+            MetricMap metricMap = recordMap.get(tagTable);
             if (metricMap == null) {
                 metricMap = new MetricMap();
                 TagMap tagMap = new TagMap(tagTable); // clone tags
                 recordMap.put(tagMap, metricMap);
             }
-            //for (String metricName : metricUpdates.keySet()) {
-            Iterator metricIt = metricUpdates.keySet().iterator();
-            while (metricIt.hasNext()) {
-                String metricName = (String) metricIt.next();
-                MetricValue updateValue = (MetricValue) metricUpdates.get(metricName);
+            for (String metricName : metricUpdates.keySet()) {
+                MetricValue updateValue = metricUpdates.get(metricName);
                 Number updateNumber = updateValue.getNumber();
-                Number currentNumber = (Number) metricMap.get(metricName);
+                Number currentNumber = metricMap.get(metricName);
                 if (currentNumber == null || updateValue.isAbsolute()) {
                     metricMap.put(metricName, updateNumber);
                 }
@@ -350,7 +339,7 @@ public abstract class AbstractMetricsContext implements MetricsContext {
     }
     
     private synchronized RecordMap getRecordMap(String recordName) {
-        return (RecordMap) bufferedData.get(recordName);
+        return bufferedData.get(recordName);
     }
     
     /**

+ 2 - 2
src/java/org/apache/hadoop/record/XmlRecordInput.java

@@ -29,10 +29,10 @@ import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
 
 /**
- *
+ * XML Deserializer.
  * @author Milind Bhandarkar
  */
-class XmlRecordInput implements RecordInput {
+public class XmlRecordInput implements RecordInput {
     
     static private class Value {
         private String type;

+ 2 - 2
src/java/org/apache/hadoop/record/XmlRecordOutput.java

@@ -27,10 +27,10 @@ import java.io.UnsupportedEncodingException;
 import java.util.Stack;
 
 /**
- *
+ * XML Serializer.
  * @author Milind Bhandarkar
  */
-class XmlRecordOutput implements RecordOutput {
+public class XmlRecordOutput implements RecordOutput {
 
     private PrintStream stream;
     

Some files were not shown because too many files changed in this diff