/** * Opens an FSDataOutputStream at the indicated Path with write-progress reporting. Same as * create(), except fails if parent directory doesn't already exist. * * TODO(hy): We need to refactor this method after having a new internal API support (TACHYON-46). * * @param cPath the file name to open * @param overwrite if a file with this name already exists, then if true, the file will be * overwritten, and if false an error will be thrown. * @param bufferSize the size of the buffer to be used. * @param replication required block replication for the file. * @param blockSize the size in bytes of the buffer to be used. * @param progress queryable progress * @throws IOException if 1) overwrite is not specified and the path already exists, 2) if the * path is a folder, or 3) the parent directory does not exist * @see #setPermission(Path, FsPermission) * @deprecated API only for 0.20-append */ @Override @Deprecated public FSDataOutputStream createNonRecursive(Path cPath, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException { TachyonURI path = new TachyonURI(Utils.getPathWithoutScheme(cPath.getParent())); if (!mTFS.exist(path)) { throw new FileNotFoundException("Parent directory does not exist!"); } return this.create(cPath, permission, overwrite, bufferSize, replication, blockSize, progress); }
/** * Attempts to delete the file or directory with the specified path. * * @param cPath path to delete * @param recursive if true, will attempt to delete all children of the path * @return true if one or more files/directories were deleted; false otherwise * @throws IOException if the path failed to be deleted due to some constraint (ie. non empty * directory with recursive flag disabled) */ @Override public boolean delete(Path cPath, boolean recursive) throws IOException { LOG.info("delete(" + cPath + ", " + recursive + ")"); if (mStatistics != null) { mStatistics.incrementWriteOps(1); } TachyonURI path = new TachyonURI(Utils.getPathWithoutScheme(cPath)); if (!mTFS.exist(path)) { return false; } boolean rtn = mTFS.delete(path, recursive); if (mTFS.exist(path)) { throw new IOException("Failed to delete path " + path.toString()); } return rtn; }
@Override public FileStatus[] listStatus(Path path) throws IOException { TachyonURI tPath = new TachyonURI(Utils.getPathWithoutScheme(path)); Path hdfsPath = Utils.getHDFSPath(tPath, mUnderFSAddress); LOG.info("listStatus(" + path + "): HDFS Path: " + hdfsPath); if (mStatistics != null) { mStatistics.incrementReadOps(1); } if (!mTFS.exist(tPath)) { throw new FileNotFoundException("File does not exist: " + path); } List<FileInfo> files = mTFS.listStatus(tPath); FileStatus[] ret = new FileStatus[files.size()]; for (int k = 0; k < files.size(); k ++) { FileInfo info = files.get(k); // TODO(hy): Replicate 3 with the number of disk replications. ret[k] = new FileStatus(info.getLength(), info.isFolder, 3, info.getBlockSizeBytes(), info.getCreationTimeMs(), info.getCreationTimeMs(), null, null, null, new Path( mTachyonHeader + info.getPath())); } return ret; }
if (!tfs.exist(directoryName)) { LOG.debug("Loading ufs. Make dir if needed for '" + directoryName + "'."); tfs.mkdir(directoryName); TachyonURI tfsPath = buildTFSPath(directoryName, ufsAddrRootPath, ufsPath); LOG.debug("Loading ufs. tfs path = " + tfsPath + "."); if (tfs.exist(tfsPath)) { LOG.debug("File " + tfsPath + " already exists in Tachyon."); continue; tachyonPath, ufsPath.getPath().substring(ufsAddrRootPath.getPath().length()))); LOG.debug("Loading ufs. ufs path is a directory. tfsPath = " + tfsPath + "."); if (!tfs.exist(tfsPath)) { LOG.debug("Loading ufs. ufs path is a directory. make dir = " + tfsPath + ".");
if (mTFS.exist(path)) { if (overwrite && !mTFS.getFileStatus(-1, path).isFolder) { if (!mTFS.delete(path, false)) {