HDFS-9451. Clean up depreated umasks and related unit tests. Contributed by Wei-Chiu Chuang.

This commit is contained in:
Haohui Mai 2015-11-25 12:47:24 -08:00
parent 95d5227c75
commit b21dffb1fe
4 changed files with 8 additions and 35 deletions

View File

@ -215,9 +215,6 @@ public FsPermission applyUMask(FsPermission umask) {
otheraction.and(umask.otheraction.not()));
}
/** umask property label deprecated key and code in getUMask method
* to accommodate it may be removed in version .23 */
public static final String DEPRECATED_UMASK_LABEL = "dfs.umask";
public static final String UMASK_LABEL =
CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY;
public static final int DEFAULT_UMASK =
@ -236,8 +233,6 @@ public FsPermission applyUMask(FsPermission umask) {
* '-' sets bits in the mask.
*
* Octal umask, the specified bits are set in the file mode creation mask.
*
* {@code DEPRECATED_UMASK_LABEL} config param has umask value set to decimal.
*/
public static FsPermission getUMask(Configuration conf) {
int umask = DEFAULT_UMASK;
@ -246,7 +241,6 @@ public static FsPermission getUMask(Configuration conf) {
// If the deprecated key is not present then check for the new key
if(conf != null) {
String confUmask = conf.get(UMASK_LABEL);
int oldUmask = conf.getInt(DEPRECATED_UMASK_LABEL, Integer.MIN_VALUE);
try {
if(confUmask != null) {
umask = new UmaskParser(confUmask).getUMask();
@ -290,7 +284,6 @@ public boolean getEncryptedBit() {
/** Set the user file creation mask (umask) */
public static void setUMask(Configuration conf, FsPermission umask) {
conf.set(UMASK_LABEL, String.format("%1$03o", umask.toShort()));
conf.setInt(DEPRECATED_UMASK_LABEL, umask.toShort());
}
/**

View File

@ -695,14 +695,4 @@ private boolean isCorrectExceptionMessage(String msg, String umask) {
msg.contains(umask) &&
msg.contains("octal or symbolic");
}
// Ensure that when the deprecated decimal umask key is used, it is correctly
// parsed as such and converted correctly to an FsPermission value
public void testDeprecatedUmask() {
Configuration conf = new Configuration();
conf.set(FsPermission.DEPRECATED_UMASK_LABEL, "302"); // 302 = 0456
FsPermission umask = FsPermission.getUMask(conf);
assertEquals(0456, umask.toShort());
}
}

View File

@ -868,6 +868,9 @@ Trunk (Unreleased)
HDFS-9348. Erasure Coding: DFS GetErasureCodingPolicy API on a non-existent
file should be handled properly. (Rakesh R via umamahesh)
HDFS-9451. Clean up depreated umasks and related unit tests.
(Wei-Chiu Chuang via wheat9)
Release 2.8.0 - UNRELEASED
NEW FEATURES

View File

@ -83,31 +83,18 @@ public void testBackwardCompatibility() {
Configuration conf = new Configuration();
FsPermission.setUMask(conf, perm);
assertEquals(18, FsPermission.getUMask(conf).toShort());
// Test 2 - old configuration key set with decimal
// umask value should be handled
perm = new FsPermission((short)18);
conf = new Configuration();
conf.set(FsPermission.DEPRECATED_UMASK_LABEL, "18");
assertEquals(18, FsPermission.getUMask(conf).toShort());
// Test 3 - old configuration key overrides the new one
conf = new Configuration();
conf.set(FsPermission.DEPRECATED_UMASK_LABEL, "18");
conf.set(FsPermission.UMASK_LABEL, "000");
assertEquals(18, FsPermission.getUMask(conf).toShort());
// Test 4 - new configuration key is handled
// Test 2 - new configuration key is handled
conf = new Configuration();
conf.set(FsPermission.UMASK_LABEL, "022");
assertEquals(18, FsPermission.getUMask(conf).toShort());
// Test 5 - equivalent valid umask
// Test 3 - equivalent valid umask
conf = new Configuration();
conf.set(FsPermission.UMASK_LABEL, "0022");
assertEquals(18, FsPermission.getUMask(conf).toShort());
// Test 6 - invalid umask
// Test 4 - invalid umask
conf = new Configuration();
conf.set(FsPermission.UMASK_LABEL, "1222");
try {
@ -117,7 +104,7 @@ public void testBackwardCompatibility() {
//pass, exception successfully trigger
}
// Test 7 - invalid umask
// Test 5 - invalid umask
conf = new Configuration();
conf.set(FsPermission.UMASK_LABEL, "01222");
try {