Set permissions on staging and output directories for
SegmentCreationJob.
Follow up to
1. Set permissions for staging as well as output directories for
SegmentCreationJob, if default umask is specified.
2. Set the permissions after mkdir.
@@ -140,11 +140,6 @@ public class SegmentCreationJob extends Configured {
}
fs.mkdirs(stagingDir);
- if (_defaultPermissionsMask != null) {
- FsPermission umask = new FsPermission(_defaultPermissionsMask);
- FsPermission permission = FsPermission.getDirDefault().applyUMask(umask);
- FileSystem.get(getConf()).setPermission(stagingDir, permission);
- }
Path stagingDirInputPath = new Path(_stagingDir + "/input/");
fs.mkdirs(stagingDirInputPath);
LOGGER.info("Staging dir input path is {}", stagingDirInputPath);
@@ -155,6 +150,15 @@ public class SegmentCreationJob extends Configured {
}
fs.mkdirs(outputDir);
+ if (_defaultPermissionsMask != null) {
+ FsPermission umask = new FsPermission(_defaultPermissionsMask);
+ FsPermission permission = FsPermission.getDirDefault().applyUMask(umask);
+
+ setDirPermission(stagingDir, permission);
+ setDirPermission(stagingDirInputPath, permission);
+ setDirPermission(outputDir, permission);
+ }
+
List<FileStatus> inputDataFiles = new ArrayList<FileStatus>();
FileStatus[] fileStatusArr = fs.globStatus(inputPathPattern);
for (FileStatus fileStatus : fileStatusArr) {
@@ -228,6 +232,11 @@ public class SegmentCreationJob extends Configured {
fs.delete(new Path(_stagingDir), true);
}
+ private void setDirPermission(Path directory, FsPermission permission) throws IOException {
+ FileSystem.get(getConf()).setPermission(directory, permission);
+ LOGGER.info("Setting permissions '{}' for directory: '{}'", permission, directory);
+ }
+
protected void setAdditionalJobProperties(Job job) throws Exception {
// Check host and port information before set table config dependent properties
if (_hosts == null || _port == 0) {
