/** * Creates a file in the system with a pre-defined underfsPath. It also creates necessary folders * along the path. * * TODO(hy): It should not create necessary path. * * @param path the path of the file in Tachyon * @param ufsPath the path of the file in the underfs * @return The unique file id. It returns -1 if the creation failed * @throws IOException if the operation fails */ public synchronized long createFile(TachyonURI path, TachyonURI ufsPath) throws IOException { return createFile(path, ufsPath, -1, true); }
/** * Deletes the file denoted by the path. * * @param path the file path * @param recursive if delete the path recursively. * @return true if the deletion succeed (including the case that the path does not exist in the * first place), false otherwise * @throws IOException if the operation fails */ public synchronized boolean delete(TachyonURI path, boolean recursive) throws IOException { return delete(-1, path, recursive); }
/** * Frees the in-memory blocks of file/folder denoted by the path. * * @param path the file/folder path * @param recursive if free the path recursively * @return true if the memory free succeed (including the case that the path does not exist in the * first place), false otherwise * @throws IOException if the operation fails */ public synchronized boolean freepath(TachyonURI path, boolean recursive) throws IOException { return freepath(-1, path, recursive); } }
/** * Renames the srcPath to the dstPath. * * @param srcPath The path of the source file / folder. * @param dstPath The path of the destination file / folder. * @return true if succeed, false otherwise * @throws IOException if the operation fails */ public synchronized boolean rename(TachyonURI srcPath, TachyonURI dstPath) throws IOException { return rename(-1, srcPath, dstPath); }
/** * Create a directory if it does not exist. The method also creates necessary non-existing parent * folders. * * @param path Directory path. * @return true if the folder is created successfully or already existing. false otherwise * @throws IOException if the operation fails */ public synchronized boolean mkdir(TachyonURI path) throws IOException { return mkdirs(path, true); }
/** * Renames the file. * * @param fileId the file id * @param dstPath the new path of the file in the file system. * @return true if succeed, false otherwise * @throws IOException if the operation fails */ public synchronized boolean rename(long fileId, TachyonURI dstPath) throws IOException { return rename(fileId, TachyonURI.EMPTY_URI, dstPath); }
/** * Creates a file in the system. It also creates necessary folders along the path. * * TODO(hy): It should not create necessary path. * * @param path the path of the file * @param blockSizeByte the block size of the file * @return The unique file id. It returns -1 if the creation failed * @throws IOException if the operation fails */ public synchronized long createFile(TachyonURI path, long blockSizeByte) throws IOException { if (blockSizeByte > (long) Constants.GB * 2) { throw new IOException("Block size must be less than 2GB: " + blockSizeByte); } return createFile(path, TachyonURI.EMPTY_URI, blockSizeByte, true); }
/** * Deletes the file denoted by the file id. * * @param fid file id * @param recursive if delete the path recursively. * @return true if deletion succeed (including the case the file does not exist in the first * place), false otherwise * @throws IOException if the operation fails */ public synchronized boolean delete(long fid, boolean recursive) throws IOException { return delete(fid, TachyonURI.EMPTY_URI, recursive); }
/** * Creates a file with the default block size (1GB) in the system. It also creates necessary * folders along the path. * * TODO(hy): It should not create necessary path. * * @param path the path of the file * @return The unique file id. It returns -1 if the creation failed * @throws IOException if the operation fails */ public synchronized long createFile(TachyonURI path) throws IOException { long defaultBlockSize = mTachyonConf.getBytes(Constants.USER_BLOCK_SIZE_BYTES_DEFAULT); return createFile(path, defaultBlockSize); }