/** * Deletes a file or folder. * * @param fileId The id of the file / folder. If it is not INVALID_FILE_ID, path parameter is * ignored. Otherwise, the method uses the path parameter. * @param path The path of the file / folder. It could be empty iff id is not INVALID_FILE_ID. * @param recursive If fileId or path represents a non-empty folder, delete the folder recursively * or not. * @return true if deletes successfully, false otherwise * @throws IOException if the underlying master RPC fails */ @Override public synchronized boolean delete(long fileId, TachyonURI path, boolean recursive) throws IOException { validateUri(path); fileId = getValidFileId(fileId, path.getPath()); try { return mFSMasterClient.deleteFile(fileId, recursive); } catch (TachyonException e) { throw new IOException(e); } }
/** * {@inheritDoc} * * The delete will abort on a failure, but previous deletes (if deleting more than one file) that * occurred will still be effective. The delete will only synchronously be propagated to the * master. The file metadata will not be available after this call, but the data in Tachyon or * under storage space may still reside until the delete is propagated and all current readers * have relinquished their locks. */ @Override public void delete(TachyonFile file, DeleteOptions options) throws IOException, FileDoesNotExistException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { masterClient.deleteFile(file.getFileId(), options.isRecursive()); LOG.info( "Deleted file " + file.getFileId() + " from both Tachyon Storage and under file system"); } catch (TachyonException e) { TachyonException.unwrap(e, FileDoesNotExistException.class); throw e; } finally { mContext.releaseMasterClient(masterClient); } }