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); } }
/** * Returns an output stream for the journal checkpoint. The returned output stream is a singleton * for this writer. * * @param latestSequenceNumber the sequence number of the latest journal entry. This sequence * number will be used to determine the next sequence numbers for the subsequent journal * entries. * @return the output stream for the journal checkpoint * @throws IOException */ public synchronized JournalOutputStream getCheckpointOutputStream(long latestSequenceNumber) throws IOException { if (mCheckpointOutputStream == null) { LOG.info("Creating tmp checkpoint file: " + mTempCheckpointPath); if (!mUfs.exists(mJournalDirectory)) { LOG.info("Creating journal folder: " + mJournalDirectory); mUfs.mkdirs(mJournalDirectory, true); } mNextEntrySequenceNumber = latestSequenceNumber + 1; LOG.info("Latest journal sequence number: " + latestSequenceNumber + " Next journal sequence number: " + mNextEntrySequenceNumber); mCheckpointOutputStream = new CheckpointOutputStream(new DataOutputStream(mUfs.create(mTempCheckpointPath))); } return mCheckpointOutputStream; }
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; }
/** * Moves the current log file to the completed folder, marking it as complete. If successful, the * current log file will no longer exist. The current log must already be closed before this call. * * @throws IOException */ private void completeCurrentLog() throws IOException { String currentLog = mJournal.getCurrentLogFilePath(); if (!mUfs.exists(currentLog)) { // All logs are already complete, so nothing to do. return; } if (!mUfs.exists(mCompletedDirectory)) { mUfs.mkdirs(mCompletedDirectory, true); } String completedLog = mJournal.getCompletedLogFilePath(mNextCompleteLogNumber); mUfs.rename(currentLog, completedLog); LOG.info("Completed current log: " + currentLog + " to completed log: " + completedLog); mNextCompleteLogNumber ++; }
LOG.info("persist file " + fileId + " at " + dstPath); String parentPath = PathUtils.concatPath(ufsRoot, uri.getParent().getPath()); if (!mUfs.exists(parentPath) && !mUfs.mkdirs(parentPath, true)) { throw new IOException("Failed to create " + parentPath);
String ufsPath = mMountTable.resolve(getPath(next)).toString(); UnderFileSystem ufs = UnderFileSystem.get(ufsPath, MasterContext.getConf()); ufs.mkdirs(ufsPath, false);
UnderFileSystem ufs = UnderFileSystem.get(ufsSrcPath, MasterContext.getConf()); String parentPath = new TachyonURI(ufsDstPath).getParent().toString(); if (!ufs.exists(parentPath) && !ufs.mkdirs(parentPath, true)) { LOG.error("Failed to create " + parentPath); return false;
String ufsPath = mMountTable.resolve(getPath(dir)).toString(); UnderFileSystem ufs = UnderFileSystem.get(ufsPath, MasterContext.getConf()); ufs.mkdirs(ufsPath, false); String ufsPath = mMountTable.resolve(getPath(lastInode)).toString(); UnderFileSystem ufs = UnderFileSystem.get(ufsPath, MasterContext.getConf()); ufs.mkdirs(ufsPath, false); String ufsPath = mMountTable.resolve(getPath(lastInode)).toString(); UnderFileSystem ufs = UnderFileSystem.get(ufsPath, MasterContext.getConf()); ufs.mkdirs(ufsPath, false);