HBASE-10948 Fix hbase table file 'x' mode (Jerry He)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1588718 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2014-04-20 05:31:19 +00:00
parent a262b2424e
commit 3511399ca7
2 changed files with 20 additions and 9 deletions

View File

@ -90,7 +90,7 @@ public abstract class FSUtils {
private static final Log LOG = LogFactory.getLog(FSUtils.class);
/** Full access permissions (starting point for a umask) */
private static final String FULL_RWX_PERMISSIONS = "777";
public static final String FULL_RWX_PERMISSIONS = "777";
private static final String THREAD_POOLSIZE = "hbase.client.localityCheck.threadPoolSize";
private static final int DEFAULT_THREAD_POOLSIZE = 2;
@ -293,7 +293,7 @@ public abstract class FSUtils {
.getDeclaredMethod("create", Path.class, FsPermission.class,
boolean.class, int.class, short.class, long.class,
Progressable.class, InetSocketAddress[].class)
.invoke(backingFs, path, FsPermission.getDefault(), true,
.invoke(backingFs, path, perm, true,
getDefaultBufferSize(backingFs),
getDefaultReplication(backingFs, path),
getDefaultBlockSize(backingFs, path),
@ -366,7 +366,7 @@ public abstract class FSUtils {
// make sure that we have a mask, if not, go default.
String mask = conf.get(permssionConfKey);
if (mask == null)
return FsPermission.getDefault();
return FsPermission.getFileDefault();
// appy the umask
FsPermission umask = new FsPermission(mask);
return perm.applyUMask(umask);
@ -375,10 +375,10 @@ public abstract class FSUtils {
"Incorrect umask attempted to be created: "
+ conf.get(permssionConfKey)
+ ", using default file permissions.", e);
return FsPermission.getDefault();
return FsPermission.getFileDefault();
}
}
return FsPermission.getDefault();
return FsPermission.getFileDefault();
}
/**

View File

@ -232,12 +232,23 @@ public class TestFSUtils {
public void testPermMask() throws Exception {
Configuration conf = HBaseConfiguration.create();
conf.setBoolean(HConstants.ENABLE_DATA_FILE_UMASK, true);
FileSystem fs = FileSystem.get(conf);
// first check that we don't crash if we don't have perms set
FsPermission defaultPerms = FSUtils.getFilePermissions(fs, conf,
// default fs permission
FsPermission defaultFsPerm = FSUtils.getFilePermissions(fs, conf,
HConstants.DATA_FILE_UMASK_KEY);
assertEquals(FsPermission.getDefault(), defaultPerms);
// 'hbase.data.umask.enable' is false. We will get default fs permission.
assertEquals(FsPermission.getFileDefault(), defaultFsPerm);
conf.setBoolean(HConstants.ENABLE_DATA_FILE_UMASK, true);
// first check that we don't crash if we don't have perms set
FsPermission defaultStartPerm = FSUtils.getFilePermissions(fs, conf,
HConstants.DATA_FILE_UMASK_KEY);
// default 'hbase.data.umask'is 000, and this umask will be used when
// 'hbase.data.umask.enable' is true.
// Therefore we will not get the real fs default in this case.
// Instead we will get the starting point FULL_RWX_PERMISSIONS
assertEquals(new FsPermission(FSUtils.FULL_RWX_PERMISSIONS), defaultStartPerm);
conf.setStrings(HConstants.DATA_FILE_UMASK_KEY, "077");
// now check that we get the right perms