Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2D7CB2009D9 for ; Mon, 2 May 2016 22:50:54 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 2BDDB1609B0; Mon, 2 May 2016 22:50:54 +0200 (CEST) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 734C91602C5 for ; Mon, 2 May 2016 22:50:53 +0200 (CEST) Received: (qmail 72817 invoked by uid 500); 2 May 2016 20:50:52 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 72808 invoked by uid 99); 2 May 2016 20:50:52 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 May 2016 20:50:52 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6056ADFCE0; Mon, 2 May 2016 20:50:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: antonov@apache.org To: commits@hbase.apache.org Message-Id: <039a6dd5b34741538816059d683ce285@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: hbase git commit: HBASE-15281 Allow the FileSystem inside HFileSystem to be wrapped (Rajesh Nishtala) Date: Mon, 2 May 2016 20:50:52 +0000 (UTC) archived-at: Mon, 02 May 2016 20:50:54 -0000 Repository: hbase Updated Branches: refs/heads/branch-1 57ca428c5 -> 36d634d35 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/36d634d3 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/36d634d3 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/36d634d3 Branch: refs/heads/branch-1 Commit: 36d634d353c2193d87d60f6525647360d8a27379 Parents: 57ca428 Author: Mikhail Antonov Authored: Mon May 2 13:23:51 2016 -0700 Committer: Mikhail Antonov Committed: Mon May 2 13:26:37 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/36d634d3/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()); }