You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by we...@apache.org on 2019/12/12 10:23:53 UTC

[hadoop] branch trunk updated: HDFS-15050. Optimize log information when DFSInputStream meet CannotObtainBlockLengthException. Contributed by Xiaoqiao He.

This is an automated email from the ASF dual-hosted git repository.

weichiu pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 0e28cd8  HDFS-15050. Optimize log information when DFSInputStream meet CannotObtainBlockLengthException. Contributed by Xiaoqiao He.
0e28cd8 is described below

commit 0e28cd8f63615dddded2f1183f27efb5c2aaf6aa
Author: He Xiaoqiao <he...@apache.org>
AuthorDate: Wed Dec 11 16:33:26 2019 -0800

    HDFS-15050. Optimize log information when DFSInputStream meet CannotObtainBlockLengthException. Contributed by Xiaoqiao He.
    
    Signed-off-by: Wei-Chiu Chuang <we...@apache.org>
---
 .../apache/hadoop/hdfs/CannotObtainBlockLengthException.java | 12 ++++++++++++
 .../src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/CannotObtainBlockLengthException.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/CannotObtainBlockLengthException.java
index 6da1d67..d6b2856 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/CannotObtainBlockLengthException.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/CannotObtainBlockLengthException.java
@@ -52,4 +52,16 @@ public class CannotObtainBlockLengthException extends IOException {
     super("Cannot obtain block length for " + locatedBlock);
   }
 
+  /**
+   * Constructs an {@code CannotObtainBlockLengthException} with the
+   * specified LocatedBlock and file that failed to obtain block length.
+   *
+   * @param locatedBlock
+   *        The LocatedBlock instance which block length can not be obtained
+   * @param src The file which include this block
+   */
+  public CannotObtainBlockLengthException(LocatedBlock locatedBlock,
+      String src) {
+    super("Cannot obtain block length for " + locatedBlock + " of " + src);
+  }
 }
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java
index 7323797..9827534 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java
@@ -383,7 +383,7 @@ public class DFSInputStream extends FSInputStream
       return 0;
     }
 
-    throw new CannotObtainBlockLengthException(locatedblock);
+    throw new CannotObtainBlockLengthException(locatedblock, src);
   }
 
   public long getFileLength() {


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org