HDFS-15050. Optimize log information when DFSInputStream meet CannotObtainBlockLengthException. Contributed by Xiaoqiao He.

Signed-off-by: Wei-Chiu Chuang <weichiu@apache.org>
This commit is contained in:
He Xiaoqiao 2019-12-11 16:33:26 -08:00 committed by Wei-Chiu Chuang
parent 93bb368094
commit 0e28cd8f63
2 changed files with 13 additions and 1 deletions

View File

@ -52,4 +52,16 @@ public CannotObtainBlockLengthException(LocatedBlock locatedBlock) {
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);
}
}

View File

@ -383,7 +383,7 @@ private long readBlockLength(LocatedBlock locatedblock) throws IOException {
return 0;
}
throw new CannotObtainBlockLengthException(locatedblock);
throw new CannotObtainBlockLengthException(locatedblock, src);
}
public long getFileLength() {