private void deleteDir(String path) throws IOException { UnderFileSystem ufs = UnderFileSystem.get(path, mMasterConf); if (ufs.exists(path) && !ufs.delete(path, true)) { throw new IOException("Folder " + path + " already exists but can not be deleted."); } }
private void mkdir(String path) throws IOException { UnderFileSystem ufs = UnderFileSystem.get(path, mMasterConf); if (ufs.exists(path)) { ufs.delete(path, true); } if (!ufs.mkdirs(path, true)) { throw new IOException("Failed to make folder: " + path); } }
/** * Deletes all of the logs in the completed folder. * * @throws IOException */ private void deleteCompletedLogs() throws IOException { LOG.info("Deleting all completed log files..."); // Loop over all complete logs starting from the beginning. // TODO(gpang): should the deletes start from the end? long logNumber = Journal.FIRST_COMPLETED_LOG_NUMBER; String logFilename = mJournal.getCompletedLogFilePath(logNumber); while (mUfs.exists(logFilename)) { LOG.info("Deleting completed log: " + logFilename); mUfs.delete(logFilename, true); logNumber ++; // generate the next completed log filename in the sequence. logFilename = mJournal.getCompletedLogFilePath(logNumber); } LOG.info("Finished deleting all completed log files."); // All complete logs are deleted. Reset the log number counter. mNextCompleteLogNumber = Journal.FIRST_COMPLETED_LOG_NUMBER; }
private static boolean formatFolder(String name, String folder, TachyonConf tachyonConf) throws IOException { UnderFileSystem ufs = UnderFileSystem.get(folder, tachyonConf); LOG.info("Formatting {}:{}", name, folder); if (ufs.exists(folder)) { for (String file : ufs.list(folder)) { if (!ufs.delete(PathUtils.concatPath(folder, file), true)) { LOG.info("Failed to remove {}:{}", name, file); return false; } } } else if (!ufs.mkdirs(folder, true)) { LOG.info("Failed to create {}:{}", name, folder); return false; } return true; }
/** * To clean up the test environment over underfs cluster system, so that we can re-use the running * system for the next test round instead of turning on/off it from time to time. This function is * expected to be called either before or after each test case which avoids certain overhead from * the bootstrap. * * @throws IOException when the operation fails */ public void cleanup() throws IOException { if (isStarted()) { String path = getUnderFilesystemAddress() + TachyonURI.SEPARATOR; UnderFileSystem ufs = UnderFileSystem.get(path, mTachyonConf); for (String p : ufs.list(path)) { ufs.delete(PathUtils.concatPath(path, p), true); } } }
if (!ufs.exists(ufsPath)) { LOG.warn("File does not exist the underfs: " + ufsPath); } else if (!ufs.delete(ufsPath, true)) { LOG.error("Failed to delete " + ufsPath); return false;
tmpPath = PathUtils.temporaryFileName(mFileId, mNonce, mUfsPath); ufs.delete(tmpPath, false); } else { mUnderStorageOutputStream.flush();