From 4bcf0eb51a845239d0b6735033ab2f529ea09511 Mon Sep 17 00:00:00 2001 From: Tsz-wo Sze Date: Wed, 3 Jul 2013 11:16:15 +0000 Subject: [PATCH] HDFS-4954. In nfs, OpenFileCtx.getFlushedOffset() should handle IOException. Contributed by Brandon Li git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1499321 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/hadoop/hdfs/nfs/nfs3/OpenFileCtx.java | 10 ++++++++-- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/OpenFileCtx.java b/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/OpenFileCtx.java index fa395e70578..63eca50a4a5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/OpenFileCtx.java +++ b/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/OpenFileCtx.java @@ -178,7 +178,7 @@ class OpenFileCtx { } // Get flushed offset. Note that flushed data may not be persisted. - private long getFlushedOffset() { + private long getFlushedOffset() throws IOException { return fos.getPos(); } @@ -515,7 +515,13 @@ class OpenFileCtx { commitOffset = getNextOffsetUnprotected(); } - long flushed = getFlushedOffset(); + long flushed = 0; + try { + flushed = getFlushedOffset(); + } catch (IOException e) { + LOG.error("Can't get flushed offset, error:" + e); + return COMMIT_ERROR; + } LOG.info("getFlushedOffset=" + flushed + " commitOffset=" + commitOffset); if (flushed < commitOffset) { // Keep stream active diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 6b775711c61..17656789e95 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -444,6 +444,9 @@ Release 2.1.0-beta - 2013-07-02 HDFS-4943. WebHdfsFileSystem does not work when original file path has encoded chars. (Jerry He via szetszwo) + HDFS-4954. In nfs, OpenFileCtx.getFlushedOffset() should handle IOException. + (Brandon Li via szetszwo) + BREAKDOWN OF HDFS-347 SUBTASKS AND RELATED JIRAS HDFS-4353. Encapsulate connections to peers in Peer and PeerServer classes.