Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,14 @@ public static Path getSummaryRecoveryPath(Path attemptRecoverPath) {
* @throws IOException
*/
public static void mkDirForAM(FileSystem fs, Path dir) throws IOException {
fs.mkdirs(dir, new FsPermission(TEZ_AM_DIR_PERMISSION));
FsPermission perm = new FsPermission(TEZ_AM_DIR_PERMISSION);
fs.mkdirs(dir, perm);
if (!fs.getFileStatus(dir).getPermission().equals(perm)) {
LOG.warn("Directory " + dir.toString() + " created with unexpected permissions : "
+ fs.getFileStatus(dir).getPermission() + ". Fixing permissions to correct value : "
+ perm.toString());
fs.setPermission(dir, perm);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.MiniDFSCluster;
Expand Down Expand Up @@ -413,4 +414,17 @@ public void testGetDAGSessionTimeout() {
}


@Test
public void testMkDirForAM() throws IOException {
Configuration remoteConf = new Configuration();
remoteConf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, TEST_ROOT_DIR);
remoteConf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "777");
MiniDFSCluster miniDFS = new MiniDFSCluster.Builder(remoteConf).numDataNodes(3).format(true).racks(null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit test works as expected, this patch is so close, 1 more thing, could you please shutdown miniDFS cluster?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @abstractdog .Thanks for your suggestion, In this patch, I closed miniDFS after I ran out of it. Thank you for reviewing my code, it has taught me a lot.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merged to master, thanks @skysiders for this patch, your tireless work, and quick responses!

.build();
FileSystem remoteFileSystem = miniDFS.getFileSystem();
Path path = new Path(TEST_ROOT_DIR + "/testMkDirForAM");
TezCommonUtils.mkDirForAM(remoteFileSystem, path);
Assert.assertEquals(TezCommonUtils.TEZ_AM_DIR_PERMISSION, remoteFileSystem.getFileStatus(path).getPermission());
miniDFS.shutdown();
}
}