HBASE-17710 HBase in standalone mode creates directories with 777 permission
This commit is contained in:
parent
f64a52a0c2
commit
88f909cf1f
|
@ -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.
|
* Create the region merges directory.
|
||||||
* @throws IOException If merges dir already exists or we fail to create it.
|
* @throws IOException If merges dir already exists or we fail to create it.
|
||||||
|
@ -734,7 +742,7 @@ public class HRegionFileSystem {
|
||||||
+ " before creating them again.");
|
+ " before creating them again.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fs.mkdirs(mergesdir))
|
if (!mkdirs(fs, conf, mergesdir))
|
||||||
throw new IOException("Failed create of " + mergesdir);
|
throw new IOException("Failed create of " + mergesdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1026,7 +1034,7 @@ public class HRegionFileSystem {
|
||||||
IOException lastIOE = null;
|
IOException lastIOE = null;
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
return fs.mkdirs(dir);
|
return mkdirs(fs, conf, dir);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
lastIOE = ioe;
|
lastIOE = ioe;
|
||||||
if (fs.exists(dir)) return true; // directory is present
|
if (fs.exists(dir)) return true; // directory is present
|
||||||
|
|
|
@ -720,7 +720,9 @@ public class StoreFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fs.exists(dir)) {
|
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) {
|
if (filePath == null) {
|
||||||
|
|
|
@ -197,6 +197,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
|
* Compare of path component. Does not consider schema; i.e. if schemas
|
||||||
* different but <code>path</code> starts with <code>rootPath</code>,
|
* different but <code>path</code> starts with <code>rootPath</code>,
|
||||||
|
|
Loading…
Reference in New Issue