hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rang...@apache.org
Subject svn commit: r738697 - in /hadoop/core/trunk: CHANGES.txt src/hdfs/org/apache/hadoop/hdfs/server/datanode/BlockSender.java
Date Thu, 29 Jan 2009 01:27:12 GMT
Author: rangadi
Date: Thu Jan 29 01:27:12 2009
New Revision: 738697

URL: http://svn.apache.org/viewvc?rev=738697&view=rev
Log:
HADOOP-4862. Minor : HADOOP-3678 did not remove all the cases of
spurious IOExceptions logged by DataNode. (Raghu Angadi)

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/BlockSender.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=738697&r1=738696&r2=738697&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Thu Jan 29 01:27:12 2009
@@ -715,6 +715,9 @@
     HADOOP-4955. Make DBOutputFormat us column names from setOutput().
     (Kevin Peterson via enis) 
 
+    HADOOP-4862. Minor : HADOOP-3678 did not remove all the cases of 
+    spurious IOExceptions logged by DataNode. (Raghu Angadi) 
+
 Release 0.19.0 - 2008-11-18
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/BlockSender.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/BlockSender.java?rev=738697&r1=738696&r2=738697&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/BlockSender.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/BlockSender.java Thu
Jan 29 01:27:12 2009
@@ -201,6 +201,26 @@
   }
 
   /**
+   * Converts an IOExcpetion (not subclasses) to SocketException.
+   * This is typically done to indicate to upper layers that the error 
+   * was a socket error rather than often more serious exceptions like 
+   * disk errors.
+   */
+  private static IOException ioeToSocketException(IOException ioe) {
+    if (ioe.getClass().equals(IOException.class)) {
+      // "se" could be a new class in stead of SocketException.
+      IOException se = new SocketException("Original Exception : " + ioe);
+      se.initCause(ioe);
+      /* Change the stacktrace so that original trace is not truncated
+       * when printed.*/ 
+      se.setStackTrace(ioe.getStackTrace());
+      return se;
+    }
+    // otherwise just return the same exception.
+    return ioe;
+  }
+
+  /**
    * Sends upto maxChunks chunks of data.
    * 
    * When blockInPosition is >= 0, assumes 'out' is a 
@@ -301,20 +321,9 @@
       
     } catch (IOException e) {
       /* exception while writing to the client (well, with transferTo(),
-       * it could also be while reading from the local file). Many times 
-       * this error can be ignored. We will let the callers distinguish this 
-       * from other exceptions if this is not a subclass of IOException. 
+       * it could also be while reading from the local file).
        */
-      if (e.getClass().equals(IOException.class)) {
-        // "se" could be a new class in stead of SocketException.
-        IOException se = new SocketException("Original Exception : " + e);
-        se.initCause(e);
-        /* Cange the stacktrace so that original trace is not truncated
-         * when printed.*/ 
-        se.setStackTrace(e.getStackTrace());
-        throw se;
-      }
-      throw e;
+      throw ioeToSocketException(e);
     }
 
     if (throttler != null) { // rebalancing so throttle
@@ -349,11 +358,15 @@
     OutputStream streamForSendChunks = out;
     
     try {
-      checksum.writeHeader(out);
-      if ( chunkOffsetOK ) {
-        out.writeLong( offset );
+      try {
+        checksum.writeHeader(out);
+        if ( chunkOffsetOK ) {
+          out.writeLong( offset );
+        }
+        out.flush();
+      } catch (IOException e) { //socket error
+        throw ioeToSocketException(e);
       }
-      out.flush();
       
       int maxChunksPerPacket;
       int pktSize = DataNode.PKT_HEADER_LEN + SIZE_OF_INTEGER;
@@ -391,8 +404,12 @@
                             checksumSize);
         seqno++;
       }
-      out.writeInt(0); // mark the end of block        
-      out.flush();
+      try {
+        out.writeInt(0); // mark the end of block        
+        out.flush();
+      } catch (IOException e) { //socket error
+        throw ioeToSocketException(e);
+      }
     } finally {
       if (clientTraceFmt != null) {
         ClientTraceLog.info(String.format(clientTraceFmt, totalRead));



Mime
View raw message