Browse Source

HADOOP-3678. Avoid spurious exceptions logged at DataNode when clients
read from DFS. (rangadi)


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.17@677779 13f79535-47bb-0310-9956-ffa450edef68

Raghu Angadi 17 years ago
parent
commit
57ade48d47
2 changed files with 22 additions and 1 deletions
  1. 3 0
      CHANGES.txt
  2. 19 1
      src/java/org/apache/hadoop/dfs/DataNode.java

+ 3 - 0
CHANGES.txt

@@ -4,6 +4,9 @@ Release 0.17.2 - Unreleased
 
 
   BUG FIXES
   BUG FIXES
 
 
+    HADOOP-3678. Avoid spurious exceptions logged at DataNode when clients
+    read from DFS. (rangadi)
+
     HADOOP-3760. Fix a bug with HDFS file close() mistakenly introduced
     HADOOP-3760. Fix a bug with HDFS file close() mistakenly introduced
     by HADOOP-3681. (Lohit Vijayarenu via rangadi)
     by HADOOP-3681. (Lohit Vijayarenu via rangadi)
 
 

+ 19 - 1
src/java/org/apache/hadoop/dfs/DataNode.java

@@ -1780,7 +1780,25 @@ public class DataNode implements FSConstants, Runnable {
         }
         }
       }
       }
 
 
-      out.write(buf, 0, dataOff + len);
+      try {
+        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
       if (throttler != null) { // rebalancing so throttle
         throttler.throttle(packetLen);
         throttler.throttle(packetLen);