HBASE-17710 HBase in standalone mode creates directories with 777 permission
This commit is contained in:
parent
697a55a878
commit
0b3ecc5ee7
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue