You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2019/10/21 16:18:38 UTC

[hbase] branch branch-1 updated: HBASE-23177 If fail to open reference because FNFE, make it plain it is a Reference

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

stack pushed a commit to branch branch-1
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-1 by this push:
     new cad7831  HBASE-23177 If fail to open reference because FNFE, make it plain it is a Reference
cad7831 is described below

commit cad7831567304d34b425339c81d111f849eb0ba1
Author: stack <st...@apache.org>
AuthorDate: Wed Oct 16 23:01:52 2019 -0700

    HBASE-23177 If fail to open reference because FNFE, make it plain it is a Reference
    
    Signed-off-by: Duo Zhang <zh...@apache.org>
    Signed-off-by: Sean Busbey <bu...@apache.org>
    Signed-off-by: Viraj Jasani <vi...@gmail.com>
---
 .../src/main/java/org/apache/hadoop/hbase/io/FileLink.java   |  8 ++++----
 .../src/main/java/org/apache/hadoop/hbase/io/HFileLink.java  |  3 +++
 .../org/apache/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 39aecec..a5c17e1 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 c724dda..edfde5c 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.
+   *
+   * <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",
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 76551e2..3894d06 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(),