You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2014/04/28 22:06:23 UTC

svn commit: r1590770 - in /hbase/branches/0.96/hbase-server/src: main/java/org/apache/hadoop/hbase/util/FSUtils.java test/java/org/apache/hadoop/hbase/util/TestFSUtils.java

Author: stack
Date: Mon Apr 28 20:06:22 2014
New Revision: 1590770

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

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

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java?rev=1590770&r1=1590769&r2=1590770&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java Mon Apr 28 20:06:22 2014
@@ -89,7 +89,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;
 
@@ -292,7 +292,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),
@@ -365,7 +365,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);
@@ -374,10 +374,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);
   }
 
   /**
@@ -1911,4 +1924,4 @@ public abstract class FSUtils {
     int hbaseSize = conf.getInt("hbase." + dfsKey, defaultSize);
     conf.setIfUnset(dfsKey, Integer.toString(hbaseSize));
   }
-}
\ No newline at end of file
+}

Modified: hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSUtils.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSUtils.java?rev=1590770&r1=1590769&r2=1590770&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSUtils.java (original)
+++ hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSUtils.java Mon Apr 28 20:06:22 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