/** * Delete all the paths that were marked as delete-on-exit. */ static void processDeleteOnExit() { synchronized (DELETE_ON_EXIT) { Set<Entry<FileContext, Set<Path>>> set = DELETE_ON_EXIT.entrySet(); for (Entry<FileContext, Set<Path>> entry : set) { FileContext fc = entry.getKey(); Set<Path> paths = entry.getValue(); for (Path path : paths) { try { fc.delete(path, true); } catch (IOException e) { LOG.warn("Ignoring failure to deleteOnExit for path " + path); } } } DELETE_ON_EXIT.clear(); } }
File targetWorkDir = new File("target", clusterNameTrimmed); try { FileContext.getLocalFSFileContext().delete( new Path(targetWorkDir.getAbsolutePath()), true); } catch (Exception e) {
return delete(qSrc, true); } else { return true;
@Override public void close() throws IOException { yarnCluster.close(); FileContext.getLocalFSFileContext().delete(new Path(workDir.getAbsolutePath()), true); }
@Override public Void run() throws Exception { if (fileContext.util().exists(deletePath)) { fileContext.delete(deletePath, false); } return null; } }.runWithRetries();
@Override public Object run() throws Exception { if (fileContext.util().exists(fileToDelete)) { fileContext.delete(fileToDelete, false); } return null; } });
@Before public void setup() throws Exception { localFS = FileContext.getLocalFSFileContext(); localActiveDir = new File("target", this.getClass().getSimpleName() + "-activeDir") .getAbsoluteFile(); localFS.delete(new Path(localActiveDir.getAbsolutePath()), true); localActiveDir.mkdir(); LOG.info("Created activeDir in " + localActiveDir.getAbsolutePath()); authUgi = UserGroupInformation.getCurrentUser(); }
private String setupTestWorkDir() { File testWorkDir = new File("target", this.getClass().getCanonicalName()); try { FileContext.getLocalFSFileContext().delete( new Path(testWorkDir.getAbsolutePath()), true); return testWorkDir.getAbsolutePath(); } catch (Exception e) { LOG.warn("Could not cleanup", e); throw new YarnRuntimeException("could not cleanup test dir", e); } }
@BeforeClass public static void setup() throws AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException { localFS = FileContext.getLocalFSFileContext(); localFS.delete(new Path(localFSDirBase.getAbsolutePath()), true); localFSDirBase.mkdirs(); // Do not start cluster here }
@After public void tearDown() throws Exception { if (client != null) { client.stop(); } localFS.delete(new Path(localActiveDir.getAbsolutePath()), true); }
@AfterClass public static void deleteTestDir() throws IOException { FileContext fs = FileContext.getLocalFSFileContext(); fs.delete(new Path("target", TestFSDownload.class.getSimpleName()), true); }
@After public void tearDown() throws Exception { if (client != null) { client.stop(); } localFS.delete(new Path(localActiveDir.getAbsolutePath()), true); }
@After public void tearDown() throws Exception { if (store != null) { store.stop(); } if (fsContext != null) { fsContext.delete(new Path(fsPath.getAbsolutePath()), true); } }
@BeforeClass public static void setup() throws AccessControlException, FileNotFoundException, IllegalArgumentException, IOException { //Do not error out if metrics are inited multiple times DefaultMetricsSystem.setMiniClusterMode(true); File dir = new File(stagingDir); stagingDir = dir.getAbsolutePath(); localFS = FileContext.getLocalFSFileContext(); localFS.delete(testDir, true); new File(testDir.toString()).mkdir(); }
/** * * delete the test directory in the target local fs */ static public void tearDownForViewFsLocalFs(FileContextTestHelper helper) throws Exception { FileContext fclocal = FileContext.getLocalFSFileContext(); Path targetOfTests = helper.getTestRootPath(fclocal); fclocal.delete(targetOfTests, true); }
@Before public void setup() throws IOException { assumeTrue(Shell.LINUX); FileContext.getLocalFSFileContext().delete( new Path(TEST_ROOT_DIR.getAbsolutePath()), true); }
/** * 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 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)); }