From cad7831567304d34b425339c81d111f849eb0ba1 Mon Sep 17 00:00:00 2001 From: stack Date: Wed, 16 Oct 2019 23:01:52 -0700 Subject: [PATCH] HBASE-23177 If fail to open reference because FNFE, make it plain it is a Reference Signed-off-by: Duo Zhang Signed-off-by: Sean Busbey Signed-off-by: Viraj Jasani --- .../java/org/apache/hadoop/hbase/io/FileLink.java | 8 ++++---- .../java/org/apache/hadoop/hbase/io/HFileLink.java | 3 +++ .../hadoop/hbase/regionserver/StoreFileInfo.java | 12 ++++++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java index 39aecec27a3..a5c17e14b48 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java @@ -317,7 +317,7 @@ public class FileLink { if (!(ioe instanceof FileNotFoundException)) throw re; } } - throw new FileNotFoundException("Unable to open link: " + fileLink); + throw new FileNotFoundException(this.fileLink.toString()); } } @@ -351,7 +351,7 @@ public class FileLink { @Override public String toString() { - StringBuilder str = new StringBuilder(getClass().getName()); + StringBuilder str = new StringBuilder(getClass().getSimpleName()); str.append(" locations=["); for (int i = 0; i < locations.length; ++i) { if (i > 0) str.append(", "); @@ -382,7 +382,7 @@ public class FileLink { return locations[i]; } } - throw new FileNotFoundException("Unable to open link: " + this); + throw new FileNotFoundException(toString()); } /** @@ -400,7 +400,7 @@ public class FileLink { // Try another file location } } - throw new FileNotFoundException("Unable to open link: " + this); + throw new FileNotFoundException(toString()); } /** diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java index c724ddada7f..edfde5c7748 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java @@ -66,6 +66,9 @@ public class HFileLink extends FileLink { * Region name is ([a-f0-9]+), so '-' is an invalid character for the region name. * HFile is ([0-9a-f]+(?:_SeqId_[0-9]+_)?) covering the plain hfiles (uuid) * and the bulk loaded (_SeqId_[0-9]+_) hfiles. + * + *

Here is an example name: /hbase/test/0123/cf/testtb=4567-abcd where 'testtb' is table name + * and '4567' is region name and 'abcd' is filename. */ public static final String LINK_NAME_REGEX = String.format("(?:(?:%s=)?)%s=%s-%s", diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java index 76551e2eee3..3894d06155b 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java @@ -250,8 +250,16 @@ public class StoreFileInfo { } else if (this.reference != null) { // HFile Reference Path referencePath = getReferredToFile(this.getPath()); - in = new FSDataInputStreamWrapper(fs, referencePath, - doDropBehind); + try { + in = new FSDataInputStreamWrapper(fs, referencePath, doDropBehind); + } catch (FileNotFoundException fnfe) { + // Intercept the exception so can insert more info about the Reference; otherwise + // exception just complains about some random file -- operator doesn't realize it + // other end of a Reference + FileNotFoundException newFnfe = new FileNotFoundException(toString()); + newFnfe.initCause(fnfe); + throw newFnfe; + } status = fs.getFileStatus(referencePath); } else { in = new FSDataInputStreamWrapper(fs, this.getPath(),