hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-18312 Ineffective handling of FileNotFoundException in FileLink.tryOpen()
Date Wed, 05 Jul 2017 17:37:57 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-2 8a1ec2a93 -> 3ac029b82


HBASE-18312 Ineffective handling of FileNotFoundException in FileLink.tryOpen()


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3ac029b8
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3ac029b8
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3ac029b8

Branch: refs/heads/branch-2
Commit: 3ac029b822cfc1fe2348c5956479ead8668a6d66
Parents: 8a1ec2a
Author: tedyu <yuzhihong@gmail.com>
Authored: Wed Jul 5 10:38:05 2017 -0700
Committer: tedyu <yuzhihong@gmail.com>
Committed: Wed Jul 5 10:38:05 2017 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/io/FileLink.java    |  4 +++
 .../apache/hadoop/hbase/io/TestFileLink.java    | 31 ++++++++++++++++++++
 2 files changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/3ac029b8/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java
----------------------------------------------------------------------
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 8a79efb..5694034 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
@@ -38,6 +38,7 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.PositionedReadable;
 import org.apache.hadoop.fs.Seekable;
 import org.apache.hadoop.hbase.util.FSUtils;
+import org.apache.hadoop.ipc.RemoteException;
 
 /**
  * The FileLink is a sort of hardlink, that allows access to a file given a set of locations.
@@ -304,6 +305,9 @@ public class FileLink {
           return(in);
         } catch (FileNotFoundException e) {
           // Try another file location
+        } catch (RemoteException re) {
+          IOException ioe = re.unwrapRemoteException(FileNotFoundException.class);
+          if (!(ioe instanceof FileNotFoundException)) throw re;
         }
       }
       throw new FileNotFoundException("Unable to open link: " + fileLink);

http://git-wip-us.apache.org/repos/asf/hbase/blob/3ac029b8/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestFileLink.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestFileLink.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestFileLink.java
index 8ee7d3d..eed19a0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestFileLink.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestFileLink.java
@@ -37,7 +37,9 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.testclassification.IOTests;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.util.FSUtils;
+import org.apache.hadoop.hdfs.DistributedFileSystem;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.apache.hadoop.ipc.RemoteException;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -105,6 +107,35 @@ public class TestFileLink {
     }
   }
 
+  private static class MyDistributedFileSystem extends DistributedFileSystem {
+    MyDistributedFileSystem() {
+    }
+    @Override
+    public FSDataInputStream open(Path f, final int bufferSize)
+        throws IOException {
+      throw new RemoteException(FileNotFoundException.class.getName(), "");
+    }
+    @Override
+    public Configuration getConf() {
+      return new Configuration();
+    }
+  }
+  @Test(expected = FileNotFoundException.class)
+  public void testLinkReadWithMissingFile() throws Exception {
+    HBaseTestingUtility testUtil = new HBaseTestingUtility();
+    FileSystem fs = new MyDistributedFileSystem();
+
+    Path originalPath = new Path(testUtil.getDefaultRootDirPath(), "test.file");
+    Path archivedPath = new Path(testUtil.getDefaultRootDirPath(), "archived.file");
+
+    List<Path> files = new ArrayList<Path>();
+    files.add(originalPath);
+    files.add(archivedPath);
+
+    FileLink link = new FileLink(files);
+    link.open(fs);
+  }
+
   /**
    * Test, on a local filesystem, that the FileLink is still readable
    * even when the current file gets renamed.


Mime
View raw message