hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-14445 ExportSnapshot does not honor -chmod option
Date Tue, 22 Sep 2015 20:01:16 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.1 e0ff8a39b -> 3a4440eea


HBASE-14445 ExportSnapshot does not honor -chmod option


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3a4440ee
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3a4440ee
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3a4440ee

Branch: refs/heads/branch-1.1
Commit: 3a4440eea5c5fe7488d60e925f5c04df450a47dc
Parents: e0ff8a3
Author: tedyu <yuzhihong@gmail.com>
Authored: Tue Sep 22 13:01:08 2015 -0700
Committer: tedyu <yuzhihong@gmail.com>
Committed: Tue Sep 22 13:01:08 2015 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/snapshot/ExportSnapshot.java   | 28 ++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/3a4440ee/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java
index e1c0b52..9d0f760 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java
@@ -300,8 +300,13 @@ public class ExportSnapshot extends Configured implements Tool {
           createOutputPath(parent);
         }
         outputFs.mkdirs(path);
-        // override the owner when non-null user/group is specified
-        outputFs.setOwner(path, filesUser, filesGroup);
+        if (filesUser != null || filesGroup != null) {
+          // override the owner when non-null user/group is specified
+          outputFs.setOwner(path, filesUser, filesGroup);
+        }
+        if (filesMode > 0) {
+          outputFs.setPermission(path, new FsPermission(filesMode));
+        }
       }
     }
 
@@ -826,6 +831,22 @@ public class ExportSnapshot extends Configured implements Tool {
   }
 
   /**
+   * Set path permission.
+   */
+  private void setPermission(final FileSystem fs, final Path path, final short filesMode,
+      final boolean recursive) throws IOException {
+    if (filesMode > 0) {
+      FsPermission perm = new FsPermission(filesMode);
+      if (recursive && fs.isDirectory(path)) {
+        for (FileStatus child : fs.listStatus(path)) {
+          setPermission(fs, child.getPath(), filesMode, recursive);
+        }
+      }
+      fs.setPermission(path, perm);
+    }
+  }
+
+  /**
    * Execute the export snapshot by copying the snapshot metadata, hfiles and wals.
    * @return 0 on success, and != 0 upon failure.
    */
@@ -951,6 +972,9 @@ public class ExportSnapshot extends Configured implements Tool {
       if (filesUser != null || filesGroup != null) {
         setOwner(outputFs, snapshotTmpDir, filesUser, filesGroup, true);
       }
+      if (filesMode > 0) {
+        setPermission(outputFs, snapshotTmpDir, (short)filesMode, true);
+      }
     } catch (IOException e) {
       throw new ExportSnapshotException("Failed to copy the snapshot directory: from=" +
         snapshotDir + " to=" + initialOutputSnapshotDir, e);


Mime
View raw message