HBASE-14445 ExportSnapshot does not honor -chmod option
This commit is contained in:
parent
992856c11d
commit
8ed3729105
|
@ -300,9 +300,14 @@ public class ExportSnapshot extends Configured implements Tool {
|
||||||
createOutputPath(parent);
|
createOutputPath(parent);
|
||||||
}
|
}
|
||||||
outputFs.mkdirs(path);
|
outputFs.mkdirs(path);
|
||||||
|
if (filesUser != null || filesGroup != null) {
|
||||||
// override the owner when non-null user/group is specified
|
// override the owner when non-null user/group is specified
|
||||||
outputFs.setOwner(path, filesUser, filesGroup);
|
outputFs.setOwner(path, filesUser, filesGroup);
|
||||||
}
|
}
|
||||||
|
if (filesMode > 0) {
|
||||||
|
outputFs.setPermission(path, new FsPermission(filesMode));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -825,6 +830,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.
|
* Execute the export snapshot by copying the snapshot metadata, hfiles and wals.
|
||||||
* @return 0 on success, and != 0 upon failure.
|
* @return 0 on success, and != 0 upon failure.
|
||||||
|
@ -951,6 +972,9 @@ public class ExportSnapshot extends Configured implements Tool {
|
||||||
if (filesUser != null || filesGroup != null) {
|
if (filesUser != null || filesGroup != null) {
|
||||||
setOwner(outputFs, snapshotTmpDir, filesUser, filesGroup, true);
|
setOwner(outputFs, snapshotTmpDir, filesUser, filesGroup, true);
|
||||||
}
|
}
|
||||||
|
if (filesMode > 0) {
|
||||||
|
setPermission(outputFs, snapshotTmpDir, (short)filesMode, true);
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ExportSnapshotException("Failed to copy the snapshot directory: from=" +
|
throw new ExportSnapshotException("Failed to copy the snapshot directory: from=" +
|
||||||
snapshotDir + " to=" + initialOutputSnapshotDir, e);
|
snapshotDir + " to=" + initialOutputSnapshotDir, e);
|
||||||
|
|
Loading…
Reference in New Issue