hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rang...@apache.org
Subject svn commit: r673509 - in /hadoop/core/trunk: CHANGES.txt src/hdfs/org/apache/hadoop/dfs/DataNode.java
Date Wed, 02 Jul 2008 21:32:28 GMT
Author: rangadi
Date: Wed Jul  2 14:32:28 2008
New Revision: 673509

URL: http://svn.apache.org/viewvc?rev=673509&view=rev
Log:
HADOOP-3678. Avoid spurious exceptions logged at DataNode when clients
read from DFS. (rangadi)

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/dfs/DataNode.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=673509&r1=673508&r2=673509&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed Jul  2 14:32:28 2008
@@ -732,6 +732,9 @@
     retrieving the address of direct buffers from compression code by obtaining
     a lock during this call. (Arun C Murthy via cdouglas)
 
+    HADOOP-3678. Avoid spurious exceptions logged at DataNode when clients
+    read from DFS. (rangadi)
+
 Release 0.17.1 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/dfs/DataNode.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/dfs/DataNode.java?rev=673509&r1=673508&r2=673509&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/dfs/DataNode.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/dfs/DataNode.java Wed Jul  2 14:32:28 2008
@@ -1830,19 +1830,7 @@
       
       int dataOff = checksumOff + checksumLen;
       
-      if (blockInPosition >= 0) {
-        //use transferTo(). Checks on out and blockIn are already done. 
-        
-        SocketOutputStream sockOut = (SocketOutputStream)out;
-        //first write the packet
-        sockOut.write(buf, 0, dataOff);
-        // no need to flush. since we know out is not a buffered stream. 
-
-        sockOut.transferToFully(((FileInputStream)blockIn).getChannel(), 
-                                blockInPosition, len);
-        
-        blockInPosition += len;
-      } else {
+      if (blockInPosition < 0) {
         //normal transfer
         IOUtils.readFully(blockIn, buf, dataOff, len);
 
@@ -1864,8 +1852,43 @@
             cOff += checksumSize;
           }
         }
+        //writing is done below (mainly to handle IOException)
+      }
+      
+      try {
+        if (blockInPosition >= 0) {
+          //use transferTo(). Checks on out and blockIn are already done. 
+
+          SocketOutputStream sockOut = (SocketOutputStream)out;
+          //first write the packet
+          sockOut.write(buf, 0, dataOff);
+          // no need to flush. since we know out is not a buffered stream. 
 
-        out.write(buf, 0, dataOff + len);
+          sockOut.transferToFully(((FileInputStream)blockIn).getChannel(), 
+                                  blockInPosition, len);
+
+          blockInPosition += len;
+        } else {
+          // normal transfer
+          out.write(buf, 0, dataOff + len);
+        }
+        
+      } 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. 
+         */
+        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;
       }
 
       if (throttler != null) { // rebalancing so throttle



Mime
View raw message