/** * Gets <code>TachyonFile</code> based on the path. Does not utilize the file metadata cache. * * @param path file path. * @return TachyonFile of the path, or null if the file does not exist * @throws IOException if the underlying master RPC fails */ public synchronized TachyonFile getFile(TachyonURI path) throws IOException { validateUri(path); return getFile(path, false); }
/** * Get the <code>RawTable</code> by path. * * Currently unsupported. * * @param path the path of the raw table * @return the RawTable * @throws IOException if the underlying master RPC fails */ public synchronized RawTable getRawTable(TachyonURI path) throws IOException { validateUri(path); RawTableInfo rawTableInfo = mRawTableMasterClient.getClientRawTableInfo(path); return new RawTable(this, rawTableInfo); }
/** * Creates a <code>RawTable</code> and returns its id. * * Currently unsupported. * * @param path the RawTable's path * @param columns number of columns it has * @param metadata the meta data of the RawTable * @return the id if succeed, {@link tachyon.util.IdUtils#INVALID_FILE_ID} otherwise * @throws IOException if the number of columns is invalid or the underlying master RPC fails */ public synchronized long createRawTable(TachyonURI path, int columns, ByteBuffer metadata) throws IOException { validateUri(path); int maxColumns = mTachyonConf.getInt(Constants.MAX_COLUMNS); if (columns < 1 || columns > maxColumns) { throw new IOException("Column count " + columns + " is smaller than 1 or " + "bigger than " + maxColumns); } return mRawTableMasterClient.createRawTable(path, columns, metadata); }
/** * Renames a file or folder to the indicated new path. * * @param fileId The id of the source file / folder. If it is not INVALID_FILE_ID, path parameter * is ignored. Otherwise, the method uses the srcPath parameter. * @param srcPath The path of the source file / folder. It could be empty iff id is not * INVALID_FILE_ID. * @param dstPath The path of the destination file / folder. It could be empty iff id is not * INVALID_FILE_ID. * @return true if renames successfully, false otherwise * @throws IOException if the underlying master RPC fails */ @Override public synchronized boolean rename(long fileId, TachyonURI srcPath, TachyonURI dstPath) throws IOException { validateUri(srcPath); validateUri(dstPath); fileId = getValidFileId(fileId, srcPath.getPath()); try { return mFSMasterClient.renameFile(fileId, dstPath.getPath()); } catch (TachyonException e) { throw new IOException(e); } }
/** * If the <code>path</code> is a directory, returns all the direct entries in it. If the * <code>path</code> is a file, returns its ClientFileInfo. * * @param path the target directory/file path * @return A list of FileInfo, null if the file or folder does not exist * @throws IOException when the underlying master RPC fails */ @Override public synchronized List<FileInfo> listStatus(TachyonURI path) throws IOException { validateUri(path); try { return mFSMasterClient.getFileInfoList( getFileStatus(IdUtils.INVALID_FILE_ID, path).getFileId()); } catch (TachyonException e) { throw new IOException(e); } }
/** * 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); } }
/** * Frees an in-memory 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, free the folder recursively * or not * @return true if in-memory free successfully, false otherwise * @throws IOException if the underlying master RPC fails */ @Override public synchronized boolean freepath(long fileId, TachyonURI path, boolean recursive) throws IOException { validateUri(path); fileId = getValidFileId(fileId, path.getPath()); try { return mFSMasterClient.free(fileId, recursive); } catch (TachyonException e) { throw new IOException(e); } }
/** * Gets <code>TachyonFile</code> based on the path. If useCachedMetadata is true, this will not * see changes to the file's pin setting, or other dynamic properties. * * @param path file path. * @param useCachedMetadata whether to use the file metadata cache * @return TachyonFile of the path, or null if the file does not exist * @throws IOException if the underlying master RPC fails */ public synchronized TachyonFile getFile(TachyonURI path, boolean useCachedMetadata) throws IOException { validateUri(path); FileInfo fileInfo = getFileStatus(IdUtils.INVALID_FILE_ID, path, useCachedMetadata); if (fileInfo == null) { return null; } return new TachyonFile(this, fileInfo.getFileId(), mTachyonConf); }
/** * Creates a folder. * * @param path the path of the folder to be created * @param recursive Creates necessary parent folders if true, not otherwise. * @return true if the folder is created successfully or already existing. false otherwise * @throws IOException if the underlying master RPC fails */ @Override public synchronized boolean mkdirs(TachyonURI path, boolean recursive) throws IOException { validateUri(path); try { MkdirOptions options = new MkdirOptions.Builder(ClientContext.getConf()).setRecursive(recursive).build(); return mFSMasterClient.mkdir(path.getPath(), options); } catch (TachyonException e) { throw new IOException(e); } }
/** * Creates a new file in the file system. * * @param path The path of the file * @param ufsPath The path of the file in the under file system. If this is empty, the file does * not exist in the under file system yet. * @param blockSizeBytes The size of the block in bytes. It is -1 iff ufsPath is non-empty. * @param recursive Creates necessary parent folders if true, not otherwise. * @return The file id, which is globally unique * @throws IOException if the underlying master RPC fails */ @Override public synchronized long createFile(TachyonURI path, TachyonURI ufsPath, long blockSizeBytes, boolean recursive) throws IOException { validateUri(path); try { if (blockSizeBytes > 0) { CreateOptions options = new CreateOptions.Builder(ClientContext.getConf()).setBlockSizeBytes(blockSizeBytes) .setRecursive(recursive).build(); return mFSMasterClient.create(path.getPath(), options); } else { return mFSMasterClient.loadMetadata(path.getPath(), recursive); } } catch (TachyonException e) { throw new IOException(e); } }