소스 검색

HDFS-11087. NamenodeFsck should check if the output writer is still writable. Contributed by Erik Krogen.

Erik Krogen 8 년 전
부모
커밋
98d9e9c4c8
1개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  1. 8 1
      hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java

+ 8 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java

@@ -526,7 +526,14 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
     } else {
       out.print('.');
     }
-    if (res.totalFiles % 100 == 0) { out.println(); out.flush(); }
+    if (res.totalFiles % 100 == 0) {
+      out.println();
+      // checkError here will attempt to flush the stream, or report an error
+      // if the stream has encountered an error or been closed by the client
+      if (out.checkError()) {
+        throw new IOException("fsck encountered an error in its output stream");
+      }
+    }
   }
 
   private void collectBlocksSummary(String parent, HdfsFileStatus file,