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-17710 HBase in standalone mode creates directories with 777 permission
Date Thu, 02 Mar 2017 19:33:55 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 f64a52a0c -> 88f909cf1


HBASE-17710 HBase in standalone mode creates directories with 777 permission


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

Branch: refs/heads/branch-1
Commit: 88f909cf1f9300c2e2b5d99b7300d74c0b0d7916
Parents: f64a52a
Author: tedyu <yuzhihong@gmail.com>
Authored: Thu Mar 2 11:33:36 2017 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Thu Mar 2 11:33:36 2017 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/regionserver/HRegionFileSystem.java  | 12 ++++++++++--
 .../apache/hadoop/hbase/regionserver/StoreFile.java   |  4 +++-
 .../java/org/apache/hadoop/hbase/util/FSUtils.java    | 14 ++++++++++++++
 3 files changed, 27 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/88f909cf/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
index fca237d..33c03ca 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
@@ -719,6 +719,14 @@ public class HRegionFileSystem {
     }
   }
 
+  static boolean mkdirs(FileSystem fs, Configuration conf, Path dir) throws IOException {
+    if (FSUtils.isDistributedFileSystem(fs) ||
+        !conf.getBoolean(HConstants.ENABLE_DATA_FILE_UMASK, false)) {
+      return fs.mkdirs(dir);
+    }
+    FsPermission perms = FSUtils.getFilePermissions(fs, conf, HConstants.DATA_FILE_UMASK_KEY);
+    return fs.mkdirs(dir, perms);
+  }
   /**
    * Create the region merges directory.
    * @throws IOException If merges dir already exists or we fail to create it.
@@ -734,7 +742,7 @@ public class HRegionFileSystem {
             + " before creating them again.");
       }
     }
-    if (!fs.mkdirs(mergesdir))
+    if (!mkdirs(fs, conf, mergesdir))
       throw new IOException("Failed create of " + mergesdir);
   }
 
@@ -1026,7 +1034,7 @@ public class HRegionFileSystem {
     IOException lastIOE = null;
     do {
       try {
-        return fs.mkdirs(dir);
+        return mkdirs(fs, conf, dir);
       } catch (IOException ioe) {
         lastIOE = ioe;
         if (fs.exists(dir)) return true; // directory is present

http://git-wip-us.apache.org/repos/asf/hbase/blob/88f909cf/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
index b7e1736..28c0892 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
@@ -720,7 +720,9 @@ public class StoreFile {
       }
 
       if (!fs.exists(dir)) {
-        fs.mkdirs(dir);
+        // Handle permission for non-HDFS filesystem properly
+        // See HBASE-17710
+        HRegionFileSystem.mkdirs(fs, conf, dir);
       }
 
       if (filePath == null) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/88f909cf/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
index d3df8b7..3e2d230 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
@@ -198,6 +198,20 @@ public abstract class FSUtils {
   }
 
   /**
+   * @return True is <code>fs</code> is instance of DistributedFileSystem
+   * @throws IOException
+   */
+  public static boolean isDistributedFileSystem(final FileSystem fs) throws IOException {
+    FileSystem fileSystem = fs;
+    // If passed an instance of HFileSystem, it fails instanceof DistributedFileSystem.
+    // Check its backing fs for dfs-ness.
+    if (fs instanceof HFileSystem) {
+      fileSystem = ((HFileSystem)fs).getBackingFs();
+    }
+    return fileSystem instanceof DistributedFileSystem;
+  }
+ 
+  /**
    * Compare of path component. Does not consider schema; i.e. if schemas
    * different but <code>path</code> starts with <code>rootPath</code>,
    * then the function returns true


Mime
View raw message