HADOOP-6246. Add backward compatibility support to use deprecated decimal umask from old configuration. Contributed by Jakob Homan.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@814080 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c9cc61e853
commit
3617ed0bad
@ -190,6 +190,9 @@ Trunk (unreleased changes)
|
||||
HADOOP-4012. Provide splitting support for bzip2 compressed files. (Abdul
|
||||
Qadeer via cdouglas)
|
||||
|
||||
HADOOP-6246. Add backward compatibility support to use deprecated decimal
|
||||
umask from old configuration. (Jakob Homan via suresh)
|
||||
|
||||
IMPROVEMENTS
|
||||
|
||||
HADOOP-4565. Added CombineFileInputFormat to use data locality information
|
||||
|
@ -181,10 +181,14 @@ public FsPermission applyUMask(FsPermission umask) {
|
||||
otheraction.and(umask.otheraction.not()));
|
||||
}
|
||||
|
||||
/** umask property label */
|
||||
/** umask property label Deprecated key may be removed in version .23 */
|
||||
public static final String DEPRECATED_UMASK_LABEL = "dfs.umask";
|
||||
public static final String UMASK_LABEL = "dfs.umaskmode";
|
||||
public static final int DEFAULT_UMASK = 0022;
|
||||
{ Configuration.addDeprecation(DEPRECATED_UMASK_LABEL,
|
||||
new String [] {UMASK_LABEL}, DEPRECATED_UMASK_LABEL + " is deprecated, " +
|
||||
"use " + UMASK_LABEL + " with octal or symbolic specifications.");
|
||||
}
|
||||
|
||||
/** Get the user file creation mask (umask) */
|
||||
public static FsPermission getUMask(Configuration conf) {
|
||||
@ -195,15 +199,10 @@ public static FsPermission getUMask(Configuration conf) {
|
||||
if(conf != null) {
|
||||
String confUmask = conf.get(UMASK_LABEL);
|
||||
if(confUmask != null) { // UMASK_LABEL is set
|
||||
umask = new UmaskParser(confUmask).getUMask();
|
||||
} else { // check for deprecated key label
|
||||
int oldStyleValue = conf.getInt(DEPRECATED_UMASK_LABEL, Integer.MIN_VALUE);
|
||||
if(oldStyleValue != Integer.MIN_VALUE) { // Property was set with old key
|
||||
LOG.warn(DEPRECATED_UMASK_LABEL + " configuration key is deprecated. " +
|
||||
"Convert to " + UMASK_LABEL + ", using octal or symbolic umask " +
|
||||
"specifications.");
|
||||
umask = oldStyleValue;
|
||||
}
|
||||
if(conf.deprecatedKeyWasSet(DEPRECATED_UMASK_LABEL))
|
||||
umask = Integer.parseInt(confUmask); // Evaluate as decimal value
|
||||
else
|
||||
umask = new UmaskParser(confUmask).getUMask();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,4 +161,14 @@ public void testBadUmasks() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user