hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sur...@apache.org
Subject svn commit: r814080 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/fs/permission/FsPermission.java src/test/core/org/apache/hadoop/fs/permission/TestFsPermission.java
Date Fri, 11 Sep 2009 23:28:08 GMT
Author: suresh
Date: Fri Sep 11 23:28:08 2009
New Revision: 814080

URL: http://svn.apache.org/viewvc?rev=814080&view=rev
Log:
HADOOP-6246. Add backward compatibility support to use deprecated decimal umask from old configuration.
Contributed by Jakob Homan.

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/java/org/apache/hadoop/fs/permission/FsPermission.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/permission/TestFsPermission.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=814080&r1=814079&r2=814080&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Fri Sep 11 23:28:08 2009
@@ -190,6 +190,9 @@
     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

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/fs/permission/FsPermission.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/fs/permission/FsPermission.java?rev=814080&r1=814079&r2=814080&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/fs/permission/FsPermission.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/fs/permission/FsPermission.java Fri Sep
11 23:28:08 2009
@@ -181,10 +181,14 @@
         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,16 +199,11 @@
     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();
+      } 
     }
     
     return new FsPermission((short)umask);

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/permission/TestFsPermission.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/permission/TestFsPermission.java?rev=814080&r1=814079&r2=814080&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/permission/TestFsPermission.java
(original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/permission/TestFsPermission.java
Fri Sep 11 23:28:08 2009
@@ -161,4 +161,14 @@
       }
     }
   }
+  
+  // 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());
+  }
 }



Mime
View raw message