if (fs.isDirectory()) { checkDependencies(qSrc, qDst); mkdir(qDst, FsPermission.getDirDefault(), true); FileStatus[] contents = listStatus(qSrc); for (FileStatus content : contents) {
private void initializeLogDir(FileContext lfs, String logDir) { try { lfs.mkdir(new Path(logDir), null, true); } catch (FileAlreadyExistsException fe) { // do nothing } catch (IOException e) { String msg = "Could not initialize log dir " + logDir; LOG.warn(msg, e); throw new YarnRuntimeException(msg, e); } }
@BeforeClass public static void clusterSetupAtBegining() throws IOException, LoginException, URISyntaxException { Configuration conf = new HdfsConfiguration(); cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build(); fc = FileContext.getFileContext(cluster.getURI(), conf); defaultWorkingDirectory = fc.makeQualified( new Path("/user/" + UserGroupInformation.getCurrentUser().getShortUserName())); fc.mkdir(defaultWorkingDirectory, FileContext.DEFAULT_PERM, true); }
private void createDir(Path path, FsPermission perm) throws IOException { files.mkdir(path, perm, false); if (!perm.equals(files.getUMask().applyUMask(perm))) { files.setPermission(path, perm); } }
/** * We would have liked renames across file system to fail but * Unfortunately there is not way to distinguish the two file systems * @throws IOException */ @Test public void testRenameAcrossFs() throws IOException { fc.mkdir(new Path("/newDir/dirFoo"), FileContext.DEFAULT_PERM, true); // the root will get interpreted to the root of the chrooted fs. fc.rename(new Path("/newDir/dirFoo"), new Path("file:///dirFooBar")); FileContextTestHelper.isDir(fc, new Path("/dirFooBar")); }
@Test(expected=AccessControlException.class) public void testInternalMkdirNew() throws IOException { fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/dirNew"), FileContext.DEFAULT_PERM, false); } @Test(expected=AccessControlException.class)
/** * Run a glob test on FileSystem. */ private void testOnFileSystem(FSTestWrapperGlobTest test) throws Exception { try { fc.mkdir(new Path(USER_DIR), FsPermission.getDefault(), true); test.run(); } finally { fc.delete(new Path(USER_DIR), true); } }
@Test(expected=AccessControlException.class) public void testInternalMkdirExisting1() throws IOException { fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/internalDir"), FileContext.DEFAULT_PERM, false); } @Test(expected=AccessControlException.class)
@Test(expected=AccessControlException.class) public void testInternalMkdirNew() throws IOException { fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/dirNew"), FileContext.DEFAULT_PERM, false); } @Test(expected=AccessControlException.class)
void initializeTargetTestRoot() throws IOException { targetTestRoot = fileContextTestHelper.getAbsoluteTestRootPath(fcTarget); // In case previous test was killed before cleanup fcTarget.delete(targetTestRoot, true); fcTarget.mkdir(targetTestRoot, FileContext.DEFAULT_PERM, true); }
@Test(expected=AccessControlException.class) public void testInternalMkdirExisting1() throws IOException { fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/internalDir"), FileContext.DEFAULT_PERM, false); } @Test(expected=AccessControlException.class)
@Test(expected=FileNotFoundException.class) public void testResolvePathMissingThroughMountPoints2() throws IOException { fcView.mkdir( fileContextTestHelper.getTestRootPath(fcView, "/user/dirX"), FileContext.DEFAULT_PERM, false); fcView.resolvePath(new Path("/user/dirX/nonExisting")); }
@Test public void testMkdirNonRecursiveWithNonExistingDir() { try { fc.mkdir(getTestRootPath(fc,"NonExistant/aDir"), FileContext.DEFAULT_PERM, false); Assert.fail("Mkdir with non existing parent dir should have failed"); } catch (IOException e) { // failed As expected } }
@BeforeClass public static void clusterSetupAtBegining() throws IOException, LoginException, URISyntaxException { Configuration conf = new HdfsConfiguration(); cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build(); fc = FileContext.getFileContext(cluster.getURI(0), conf); defaultWorkingDirectory = fc.makeQualified( new Path("/user/" + UserGroupInformation.getCurrentUser().getShortUserName())); fc.mkdir(defaultWorkingDirectory, FileContext.DEFAULT_PERM, true); }
@BeforeClass public static void clusterSetupAtBegining() throws IOException, LoginException, URISyntaxException { Configuration conf = new HdfsConfiguration(); cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build(); fc = FileContext.getFileContext(cluster.getURI(0), conf); defaultWorkingDirectory = fc.makeQualified( new Path("/user/" + UserGroupInformation.getCurrentUser().getShortUserName())); fc.mkdir(defaultWorkingDirectory, FileContext.DEFAULT_PERM, true); }
@Test public void testMkdirRecursiveWithExistingDir() throws IOException { Path f = getTestRootPath(fc, "aDir"); fc.mkdir(f, FileContext.DEFAULT_PERM, true); Assert.assertTrue(isDir(fc, f)); }
@Test public void testDeleteEmptyDirectory() throws IOException { Path dir = getTestRootPath(fc, "test/hadoop"); fc.mkdir(dir, FsPermission.getDefault(), true); Assert.assertTrue("Dir exists", exists(fc, dir)); Assert.assertTrue("Deleted", fc.delete(dir, false)); Assert.assertFalse("Dir doesn't exist", exists(fc, dir)); }
@Test public void testMkdirRecursiveWithNonExistingDir() throws IOException { Path f = getTestRootPath(fc, "NonExistant2/aDir"); fc.mkdir(f, FileContext.DEFAULT_PERM, true); Assert.assertTrue(isDir(fc, f)); }
@Before public void setUp() throws Exception { fileContextTestHelper = getFileContextHelper(); fc = getFileContext(); fc.mkdir(fileContextTestHelper.getTestRootPath(fc), FileContext.DEFAULT_PERM, true); }