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 16:11:59 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 697a55a87 -> 0b3ecc5ee


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/0b3ecc5e
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/0b3ecc5e
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/0b3ecc5e

Branch: refs/heads/master
Commit: 0b3ecc5ee7b990ef2149b388ed4f2eef4c5b139a
Parents: 697a55a
Author: tedyu <yuzhihong@gmail.com>
Authored: Thu Mar 2 08:11:53 2017 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Thu Mar 2 08:11:53 2017 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/regionserver/HRegionFileSystem.java   | 13 +++++++++++--
 .../hadoop/hbase/regionserver/StoreFileWriter.java     |  4 +++-
 .../java/org/apache/hadoop/hbase/util/FSUtils.java     |  2 +-
 3 files changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/0b3ecc5e/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 8876491..97cc126 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
@@ -753,6 +753,15 @@ 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.
@@ -768,7 +777,7 @@ public class HRegionFileSystem {
             + " before creating them again.");
       }
     }
-    if (!fs.mkdirs(mergesdir))
+    if (!mkdirs(fs, conf, mergesdir))
       throw new IOException("Failed create of " + mergesdir);
   }
 
@@ -1060,7 +1069,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/0b3ecc5e/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileWriter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileWriter.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileWriter.java
index 0705f4c..ccfd735 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileWriter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileWriter.java
@@ -474,7 +474,9 @@ public class StoreFileWriter implements CellSink, ShipperListener {
       }
 
       if (!fs.exists(dir)) {
-        fs.mkdirs(dir);
+        // Handle permission for non-HDFS filesystem properly
+        // See HBASE-17710
+        HRegionFileSystem.mkdirs(fs, conf, dir);
       }
 
       // set block storage policy for temp path

http://git-wip-us.apache.org/repos/asf/hbase/blob/0b3ecc5e/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 3c84f57..84b3436 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
@@ -252,7 +252,7 @@ public abstract class FSUtils {
    * @return True is <code>fs</code> is instance of DistributedFileSystem
    * @throws IOException
    */
-  private static boolean isDistributedFileSystem(final FileSystem fs) 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.


Mime
View raw message