@Override public Boolean doCall(final Path p) throws IOException, UnresolvedLinkException { return dfs.delete(getPathName(p), recursive); } @Override
@Override public Boolean doCall(final Path p) throws IOException, UnresolvedLinkException { return dfs.delete(getPathName(p), recursive); } @Override
@Override public boolean removeReference(@Nullable String id) { if (id == null || !referenceExists(id)) return false; if (logger.isInfoEnabled()) logger.info("Deleting file " + id); try { // delete metadata, too client.delete(rootPath + id + ".metadata", false); return client.delete(rootPath + id, false); } catch (IOException e) { logger.error("IOException: " + e.getMessage()); return false; } }
@Override public boolean delete(Path f, boolean recursive) throws IOException, UnresolvedLinkException { return dfs.delete(getUriPath(f), recursive); }
/** * Get rid of Path f, whether a true file or dir. */ @Deprecated public boolean delete(Path f) throws IOException { return dfs.delete(getPathName(f)); }
/** * Delete file or directory. * See {@link ClientProtocol#delete(String, boolean)}. */ @Deprecated public boolean delete(String src) throws IOException { checkOpen(); return delete(src, true); }
/** * Delete file or directory. * See {@link ClientProtocol#delete(String, boolean)}. */ @Deprecated public boolean delete(String src) throws IOException { checkOpen(); return delete(src, true); }
/** * Delete file or directory. * See {@link ClientProtocol#delete(String, boolean)}. */ @Deprecated public boolean delete(String src) throws IOException { checkOpen(); return delete(src, true); }
@Override public boolean delete(Path f, boolean recursive) throws IOException, UnresolvedLinkException { return dfs.delete(getUriPath(f), recursive); }
@Override public Boolean doCall(final Path p) throws IOException { return dfs.delete(getPathName(p), recursive); } @Override
@Override void invoke() throws Exception { expectedUpdateCount++; deleted = client.delete(target, true); }
@Override public boolean delete(Path f, boolean recursive) throws IOException, UnresolvedLinkException { return dfs.delete(getUriPath(f), recursive); }
/** * requires a boolean check to delete a non * empty directory recursively. */ public boolean delete(Path f, boolean recursive) throws IOException { return dfs.delete(getPathName(f), recursive); }
/** * requires a boolean check to delete a non * empty directory recursively. */ public boolean delete(Path f, boolean recursive) throws IOException { String pathName = getPathName(f); int val = deleteUsingTrash(pathName, recursive); // allow deletion only from FsShell if (val == 0) { return true; } else if (val == 1) { return false; } return dfs.delete(pathName, recursive); }
@Override public void run() { /** * Create a file, write up to 3 blocks of data and close the file. * Do this in a loop until we are told to stop. */ while (keepRunning) { OutputStream os = null; try { String filename = "/file-" + rand.nextLong(); os = localClient.create(filename, false); os.write(data, 0, rand.nextInt(data.length)); IOUtils.closeQuietly(os); os = null; localClient.delete(filename, false); Thread.sleep(50); // Sleep for a bit to avoid killing the system. ++filesCreated; } catch (IOException ioe) { // Just ignore the exception and keep going. ++numFailures; } catch (InterruptedException ie) { return; } finally { if (os != null) { IOUtils.closeQuietly(os); } } } }
@Test public void testDFSCloseOrdering() throws Exception { DistributedFileSystem fs = new MyDistributedFileSystem(); Path path = new Path("/a"); fs.deleteOnExit(path); fs.close(); InOrder inOrder = inOrder(fs.dfs); inOrder.verify(fs.dfs).closeOutputStreams(eq(false)); inOrder.verify(fs.dfs).delete(eq(path.toString()), eq(true)); inOrder.verify(fs.dfs).close(); }
dfs.delete(file.getPath().toString(), true); } catch (Exception e) { e.printStackTrace();
/** * RAM_DISK used/free space * @throws IOException * @throws InterruptedException */ @Test public void testDfsUsageCreateDelete() throws IOException, InterruptedException { startUpCluster(true, 4); final String METHOD_NAME = GenericTestUtils.getMethodName(); Path path = new Path("/" + METHOD_NAME + ".dat"); // Get the usage before write BLOCK_SIZE long usedBeforeCreate = fs.getUsed(); makeTestFile(path, BLOCK_SIZE, true); long usedAfterCreate = fs.getUsed(); assertThat(usedAfterCreate, is((long) BLOCK_SIZE)); // Sleep for a short time to allow the lazy writer thread to do its job Thread.sleep(3 * LAZY_WRITER_INTERVAL_SEC * 1000); long usedAfterPersist = fs.getUsed(); assertThat(usedAfterPersist, is((long) BLOCK_SIZE)); // Delete after persist client.delete(path.toString(), false); long usedAfterDelete = fs.getUsed(); assertThat(usedBeforeCreate, is(usedAfterDelete)); }
/** * Delete lazy-persist file that has not been persisted to disk. * Memory is freed up and file is gone. * @throws IOException */ @Test public void testDeleteBeforePersist() throws Exception { startUpCluster(true, -1); final String METHOD_NAME = GenericTestUtils.getMethodName(); FsDatasetTestUtil.stopLazyWriter(cluster.getDataNodes().get(0)); Path path = new Path("/" + METHOD_NAME + ".dat"); makeTestFile(path, BLOCK_SIZE, true); LocatedBlocks locatedBlocks = ensureFileReplicasOnStorageType(path, RAM_DISK); // Delete before persist client.delete(path.toString(), false); Assert.assertFalse(fs.exists(path)); assertThat(verifyDeletedBlocks(locatedBlocks), is(true)); verifyRamDiskJMXMetric("RamDiskBlocksDeletedBeforeLazyPersisted", 1); }
/** * Delete lazy-persist file that has been persisted to disk * Both memory blocks and disk blocks are deleted. * @throws IOException * @throws InterruptedException */ @Test public void testDeleteAfterPersist() throws Exception { startUpCluster(true, -1); final String METHOD_NAME = GenericTestUtils.getMethodName(); Path path = new Path("/" + METHOD_NAME + ".dat"); makeTestFile(path, BLOCK_SIZE, true); LocatedBlocks locatedBlocks = ensureFileReplicasOnStorageType(path, RAM_DISK); // Sleep for a short time to allow the lazy writer thread to do its job Thread.sleep(6 * LAZY_WRITER_INTERVAL_SEC * 1000); // Delete after persist client.delete(path.toString(), false); Assert.assertFalse(fs.exists(path)); assertThat(verifyDeletedBlocks(locatedBlocks), is(true)); verifyRamDiskJMXMetric("RamDiskBlocksLazyPersisted", 1); verifyRamDiskJMXMetric("RamDiskBytesLazyPersisted", BLOCK_SIZE); }