hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1588770 - 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 Sun, 20 Apr 2014 14:31:51 GMT
Author: tedyu
Date: Sun Apr 20 14:31:50 2014
New Revision: 1588770

URL: http://svn.apache.org/r1588770
Log:
HBASE-10948 Fix hbase table file 'x' mode (Jerry He)


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=1588770&r1=1588769&r2=1588770&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
Sun Apr 20 14:31:50 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 FsPermission.getFileDefault();
         // appy the umask
         FsPermission umask = new FsPermission(mask);
         return perm.applyUMask(umask);
@@ -375,10 +375,10 @@ public abstract class FSUtils {
             "Incorrect umask attempted to be created: "
                 + conf.get(permssionConfKey)
                 + ", using default file permissions.", e);
-        return FsPermission.getDefault();
+        return FsPermission.getFileDefault();
       }
     }
-    return FsPermission.getDefault();
+    return FsPermission.getFileDefault();
   }
 
   /**
@@ -1910,4 +1910,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.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=1588770&r1=1588769&r2=1588770&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
Sun Apr 20 14:31:50 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(FsPermission.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