private long getNextBlockId() throws IOException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { return masterClient.getNewBlockIdForFile(mFileId); } catch (TachyonException e) { throw new IOException(e); } finally { mContext.releaseMasterClient(masterClient); } }
@Override public boolean mount(TachyonURI tachyonPath, TachyonURI ufsPath, MountOptions options) throws IOException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { return masterClient.mount(tachyonPath, ufsPath); } finally { mContext.releaseMasterClient(masterClient); } }
@Override public boolean unmount(TachyonURI tachyonPath, UnmountOptions options) throws IOException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { return masterClient.unmount(tachyonPath); } finally { mContext.releaseMasterClient(masterClient); } }
private FileInfo getFileInfo() throws IOException { FileSystemMasterClient client = mContext.acquireMasterClient(); try { return client.getFileInfo(mFileId); } catch (TachyonException e) { throw new IOException(e.getMessage()); } finally { mContext.releaseMasterClient(client); } } }
private TachyonFS(TachyonConf tachyonConf) { super(tachyonConf); mMasterAddress = NetworkAddressUtils.getConnectAddress(ServiceType.MASTER_RPC, tachyonConf); mZookeeperMode = mTachyonConf.getBoolean(Constants.ZOOKEEPER_ENABLED); mFSMasterClient = mCloser.register(FileSystemContext.INSTANCE.acquireMasterClient()); mBlockMasterClient = mCloser.register(BlockStoreContext.INSTANCE.acquireMasterClient()); mRawTableMasterClient = mCloser.register(new RawTableMasterClient(mMasterAddress, mTachyonConf)); mWorkerClient = mCloser.register(BlockStoreContext.INSTANCE.acquireWorkerClient()); mUserFailedSpaceRequestLimits = mTachyonConf.getInt(Constants.USER_FAILED_SPACE_REQUEST_LIMITS); String scheme = mZookeeperMode ? Constants.SCHEME_FT : Constants.SCHEME; String authority = mMasterAddress.getHostName() + ":" + mMasterAddress.getPort(); mRootUri = new TachyonURI(scheme, authority, TachyonURI.SEPARATOR); }
public void reportLostFile(TachyonFile file) throws IOException, FileDoesNotExistException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { masterClient.reportLostFile(file.getFileId()); } catch (TachyonException e) { TachyonException.unwrap(e, FileDoesNotExistException.class); throw e; } finally { mContext.releaseMasterClient(masterClient); } } }
@Override public TachyonFile openIfExists(TachyonURI path, OpenOptions openOptions) throws IOException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { long fileId = masterClient.getFileId(path.getPath()); if (fileId == -1) { return null; } return new TachyonFile(fileId); } finally { mContext.releaseMasterClient(masterClient); } }
@Override public boolean mkdir(TachyonURI path, MkdirOptions options) throws IOException, FileAlreadyExistsException, InvalidPathException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { boolean result = masterClient.mkdir(path.getPath(), options); if (result) { LOG.info("Created directory " + path.getPath()); } return result; } catch (TachyonException e) { TachyonException.unwrap(e, FileAlreadyExistsException.class); TachyonException.unwrap(e, InvalidPathException.class); throw e; } finally { mContext.releaseMasterClient(masterClient); } }
/** * {@inheritDoc} * * The file infos are snapshots of the file metadata, and the locations, last modified time, and * path are possibly inconsistent. */ @Override public List<FileInfo> listStatus(TachyonFile file, ListStatusOptions options) throws IOException, FileDoesNotExistException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { return masterClient.getFileInfoList(file.getFileId()); } catch (TachyonException e) { TachyonException.unwrap(e, FileDoesNotExistException.class); throw e; } finally { mContext.releaseMasterClient(masterClient); } }
@Override public void setState(TachyonFile file, SetStateOptions options) throws IOException, FileDoesNotExistException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); Boolean pinned = options.getPinned(); try { if (pinned != null) { masterClient.setPinned(file.getFileId(), pinned); LOG.info(pinned ? "Pinned" : "Unpinned" + " file " + file.getFileId()); } } catch (TachyonException e) { TachyonException.unwrap(e, FileDoesNotExistException.class); throw e; } finally { mContext.releaseMasterClient(masterClient); } }
/** * {@inheritDoc} * * The file info is a snapshot of the file metadata, and the locations, last modified time, and * path are possibly inconsistent. */ @Override public FileInfo getInfo(TachyonFile file, GetInfoOptions options) throws IOException, FileDoesNotExistException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { return masterClient.getFileInfo(file.getFileId()); } catch (TachyonException e) { TachyonException.unwrap(e, FileDoesNotExistException.class); throw e; } finally { mContext.releaseMasterClient(masterClient); } }
@Override public boolean rename(TachyonFile src, TachyonURI dst, RenameOptions options) throws IOException, FileDoesNotExistException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { boolean result = masterClient.renameFile(src.getFileId(), dst.getPath()); if (result) { LOG.info("Renamed file " + src.getFileId() + " to " + dst.getPath()); } return result; } catch (TachyonException e) { TachyonException.unwrap(e, FileDoesNotExistException.class); throw e; } finally { mContext.releaseMasterClient(masterClient); } }
/** * {@inheritDoc} * * This method is asynchronous and will be propagated to the workers through their heartbeats. */ @Override public void free(TachyonFile file, FreeOptions options) throws IOException, FileDoesNotExistException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { masterClient.free(file.getFileId(), options.isRecursive()); LOG.info("Removed file " + file.getFileId() + " from Tachyon Storage"); } catch (TachyonException e) { TachyonException.unwrap(e, FileDoesNotExistException.class); throw e; } finally { mContext.releaseMasterClient(masterClient); } }
/** * {@inheritDoc} * * The delete will abort on a failure, but previous deletes (if deleting more than one file) that * occurred will still be effective. The delete will only synchronously be propagated to the * master. The file metadata will not be available after this call, but the data in Tachyon or * under storage space may still reside until the delete is propagated and all current readers * have relinquished their locks. */ @Override public void delete(TachyonFile file, DeleteOptions options) throws IOException, FileDoesNotExistException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { masterClient.deleteFile(file.getFileId(), options.isRecursive()); LOG.info( "Deleted file " + file.getFileId() + " from both Tachyon Storage and under file system"); } catch (TachyonException e) { TachyonException.unwrap(e, FileDoesNotExistException.class); throw e; } finally { mContext.releaseMasterClient(masterClient); } }
@Override public TachyonFile loadMetadata(TachyonURI path, LoadMetadataOptions options) throws IOException, FileDoesNotExistException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { final long fileId = masterClient.loadMetadata(path.getPath(), options.isRecursive()); LOG.info("Loaded file " + path.getPath() + (options.isRecursive() ? " recursively" : "")); return new TachyonFile(fileId); } catch (TachyonException e) { TachyonException.unwrap(e, FileDoesNotExistException.class); throw e; } finally { mContext.releaseMasterClient(masterClient); } }
FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { masterClient.completeFile(mFileId);
@Override public TachyonFile create(TachyonURI path, CreateOptions options) throws FileAlreadyExistsException, IOException, InvalidPathException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { final long fileId = masterClient.create(path.getPath(), options); return new TachyonFile(fileId); } catch (TachyonException e) { if (e.getType() == TachyonExceptionType.BLOCK_INFO) { throw new FileAlreadyExistsException(e.getMessage(), e); } else { TachyonException.unwrap(e, FileAlreadyExistsException.class); TachyonException.unwrap(e, InvalidPathException.class); throw e; } } finally { mContext.releaseMasterClient(masterClient); } }