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..b9facfc 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,13 @@ public class HRegionFileSystem { } } + static boolean mkdirs(FileSystem fs, Configuration conf, Path dir) throws IOException { + if (FSUtils.isDistributedFileSystem(fs)) { + 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 +741,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 +1033,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 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..b8ca3da 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,7 @@ public class StoreFile { } if (!fs.exists(dir)) { - fs.mkdirs(dir); + HRegionFileSystem.mkdirs(fs, conf, dir); } if (filePath == null) { 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 fs 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 path starts with rootPath, * then the function returns true