HBASE-23177 If fail to open reference because FNFE, make it plain it is a Reference

Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Sean Busbey <busbey@apache.org>
Signed-off-by: Viraj Jasani <virajjasani007@gmail.com>
This commit is contained in:
stack 2019-10-16 23:01:52 -07:00
parent 924e0f765e
commit cad7831567
3 changed files with 17 additions and 6 deletions

View File

@ -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());
}
/**

View File

@ -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.
*
* <p>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",

View File

@ -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(),