Repository: hbase
Updated Branches:
  refs/heads/branch-1.3 731293894 -> 65eed7c54


HBASE-15281 Allow the FileSystem inside HFileSystem to be wrapped (Rajesh 
Nishtala)


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

Branch: refs/heads/branch-1.3
Commit: 65eed7c54dad56b8269f27dcb9942731e9d7d85d
Parents: 7312938
Author: Mikhail Antonov <anto...@apache.org>
Authored: Mon May 2 13:23:51 2016 -0700
Committer: Mikhail Antonov <anto...@apache.org>
Committed: Mon May 2 13:54:31 2016 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/fs/HFileSystem.java | 27 ++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/65eed7c5/hbase-server/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java
index fb58360..521bc57 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/fs/HFileSystem.java
@@ -101,11 +101,13 @@ public class HFileSystem extends FilterFileSystem {
     if (useHBaseChecksum && !(fs instanceof LocalFileSystem)) {
       conf = new Configuration(conf);
       conf.setBoolean("dfs.client.read.shortcircuit.skip.checksum", true);
-      this.noChecksumFs = newInstanceFileSystem(conf);
+      this.noChecksumFs = maybeWrapFileSystem(newInstanceFileSystem(conf), 
conf);
       this.noChecksumFs.setVerifyChecksum(false);
     } else {
-      this.noChecksumFs = fs;
+      this.noChecksumFs = maybeWrapFileSystem(fs, conf);
     }
+
+    this.fs = maybeWrapFileSystem(this.fs, conf);
   }
 
   /**
@@ -191,6 +193,27 @@ public class HFileSystem extends FilterFileSystem {
     return fs;
   }
 
+  /**
+   * Returns an instance of Filesystem wrapped into the class specified in
+   * hbase.fs.wrapper property, if one is set in the configuration, returns
+   * unmodified FS instance passed in as an argument otherwise.
+   * @param base Filesystem instance to wrap
+   * @param conf Configuration
+   * @return wrapped instance of FS, or the same instance if no wrapping 
configured.
+   */
+  private FileSystem maybeWrapFileSystem(FileSystem base, Configuration conf) {
+    try {
+      Class<?> clazz = conf.getClass("hbase.fs.wrapper", null);
+      if (clazz != null) {
+        return (FileSystem) clazz.getConstructor(FileSystem.class, 
Configuration.class)
+          .newInstance(base, conf);
+      }
+    } catch (Exception e) {
+      LOG.error("Failed to wrap filesystem: " + e);
+    }
+    return base;
+  }
+
   public static boolean addLocationsOrderInterceptor(Configuration conf) 
throws IOException {
     return addLocationsOrderInterceptor(conf, new ReorderWALBlocks());
   }

Reply via email to