hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1590771 - in /hbase/branches/0.98/hbase-server/src: main/java/org/apache/hadoop/hbase/util/FSUtils.java test/java/org/apache/hadoop/hbase/util/TestFSUtils.java
Date Mon, 28 Apr 2014 20:07:16 GMT
Author: stack
Date: Mon Apr 28 20:07:16 2014
New Revision: 1590771

URL: http://svn.apache.org/r1590771
Log:
HBASE-11061 Port HBASE-10948 Fix hbase table file 'x' mode to 0.96 / 0.98

Modified:
    hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
    hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSUtils.java

Modified: hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java?rev=1590771&r1=1590770&r2=1590771&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
(original)
+++ hbase/branches/0.98/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
Mon Apr 28 20:07:16 2014
@@ -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 getFileDefault();
         // appy the umask
         FsPermission umask = new FsPermission(mask);
         return perm.applyUMask(umask);
@@ -375,10 +375,23 @@ public abstract class FSUtils {
             "Incorrect umask attempted to be created: "
                 + conf.get(permssionConfKey)
                 + ", using default file permissions.", e);
-        return FsPermission.getDefault();
+        return getFileDefault();
       }
     }
-    return FsPermission.getDefault();
+    return getFileDefault();
+  }
+
+  /**
+   * Get the default permission for file.
+   * This is the same method as FsPermission.getFileDefault() in Hadoop 2.
+   * We provide the method here to support compatibility with Hadoop 1.
+   * See HBASE-11061.  Would be better to do this as Interface in hadoop-compat
+   * w/ hadoop1 and hadoop2 implementations but punting on this since small
+   * risk this will change in 0.96/0.98 timeframe (only committed to these
+   * branches).
+   */
+  public static FsPermission getFileDefault() {
+    return new FsPermission((short)00666);
   }
 
   /**

Modified: hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSUtils.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSUtils.java?rev=1590771&r1=1590770&r2=1590771&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSUtils.java
(original)
+++ hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSUtils.java
Mon Apr 28 20:07:16 2014
@@ -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);
+
+    // default fs permission
+    FsPermission defaultFsPerm = FSUtils.getFilePermissions(fs, conf,
+        HConstants.DATA_FILE_UMASK_KEY);
+    // 'hbase.data.umask.enable' is false. We will get default fs permission.
+    assertEquals(FSUtils.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 defaultPerms = FSUtils.getFilePermissions(fs, conf,
+    FsPermission defaultStartPerm = FSUtils.getFilePermissions(fs, conf,
         HConstants.DATA_FILE_UMASK_KEY);
-    assertEquals(FsPermission.getDefault(), defaultPerms);
+    // 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



Mime
View raw message