hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rang...@apache.org
Subject svn commit: r673764 - in /hadoop/core/branches/branch-0.18: CHANGES.txt src/hdfs/org/apache/hadoop/dfs/DataNode.java
Date Thu, 03 Jul 2008 19:00:26 GMT
Author: rangadi
Date: Thu Jul  3 12:00:25 2008
New Revision: 673764

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

Modified:
    hadoop/core/branches/branch-0.18/CHANGES.txt
    hadoop/core/branches/branch-0.18/src/hdfs/org/apache/hadoop/dfs/DataNode.java

Modified: hadoop/core/branches/branch-0.18/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.18/CHANGES.txt?rev=673764&r1=673763&r2=673764&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.18/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.18/CHANGES.txt Thu Jul  3 12:00:25 2008
@@ -702,6 +702,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/branches/branch-0.18/src/hdfs/org/apache/hadoop/dfs/DataNode.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.18/src/hdfs/org/apache/hadoop/dfs/DataNode.java?rev=673764&r1=673763&r2=673764&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.18/src/hdfs/org/apache/hadoop/dfs/DataNode.java (original)
+++ hadoop/core/branches/branch-0.18/src/hdfs/org/apache/hadoop/dfs/DataNode.java Thu Jul
 3 12:00:25 2008
@@ -1825,19 +1825,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);
 
@@ -1859,8 +1847,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