@Override public void cancel() throws IOException { mCanceled = true; close(); }
/** * Acquires a block master client from the block master client pool. * * @return the acquired block master client */ public FileSystemMasterClient acquireMasterClient() { return mFileSystemMasterClientPool.acquire(); }
/** * Releases a block master client into the block master client pool. * * NOTE: the client pool is already thread-safe. Synchronizing on FileSystemContext will lead to * deadlock: thread A acquired a client and awaits for FileSystemContext to release the client, * while thread B holds the lock of FileSystemContext but waits for available clients. * * @param masterClient a block master client to release */ public void releaseMasterClient(FileSystemMasterClient masterClient) { mFileSystemMasterClientPool.release(masterClient); }
public TachyonReadWorker(int id, int left, int right, ByteBuffer buf) throws IOException { super(id, left, right, buf); mTFS = TachyonFileSystem.TachyonFileSystemFactory.get(); }
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); } } }
/** * Convenience method for {@link #getOutStream(TachyonURI, OutStreamOptions)} with default * options. */ public FileOutStream getOutStream(TachyonURI path) throws IOException, TachyonException, FileAlreadyExistsException, InvalidPathException { return getOutStream(path, OutStreamOptions.defaults()); }
@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public void write(byte[] b) throws IOException { write(b, 0, b.length); }
/** * Convenience method for {@link #listStatus(TachyonFile, ListStatusOptions)} with default * options. */ public List<FileInfo> listStatus(TachyonFile file) throws IOException, TachyonException, FileDoesNotExistException { return listStatus(file, ListStatusOptions.defaults()); }
@Override public void seek(long pos) throws IOException { long offset = mPos - mInitPos; if (pos < offset) { setUnderStoreStream(pos); } else { long toSkip = pos - offset; if (skip(toSkip) != toSkip) { throw new IOException("Failed to seek forward to " + pos); } } }
/** * Alternative way to get a FileOutStream to a file that has already been created. This should not * be used. Deprecated in version v0.8 and will be removed in v0.9. * * @see #getOutStream(TachyonURI path, OutStreamOptions options) */ // TODO(calvin): We should remove this when the TachyonFS code is fully deprecated. @Deprecated public FileOutStream getOutStream(long fileId, OutStreamOptions options) throws IOException { return new FileOutStream(fileId, options); }
@Override public boolean unmount(TachyonURI tachyonPath, UnmountOptions options) throws IOException, TachyonException { FileSystemMasterClient masterClient = mContext.acquireMasterClient(); try { return masterClient.unmount(tachyonPath); } finally { mContext.releaseMasterClient(masterClient); } }
/** * Re-initializes the Block Store context. This method should only be used in * {@link ClientContext}. */ public synchronized void reset() { mFileSystemMasterClientPool.close(); mFileSystemMasterClientPool = new FileSystemMasterClientPool(ClientContext.getMasterAddress()); } }
/** * Creates a new under storage file input stream. * * @param initPos the initial position * @param length the length * @param ufsPath the under file system path * @throws IOException if an I/O error occurs */ public UnderStoreFileInStream(long initPos, long length, String ufsPath) throws IOException { mInitPos = initPos; mLength = length; mUfsPath = ufsPath; setUnderStoreStream(initPos); }
/** * Creates a new <code>TachyonFile</code>, based on file id. * * @param tfs the Tachyon file system client handler * @param fid the file id * @param tachyonConf the TachyonConf for this file */ TachyonFile(TachyonFS tfs, long fid, TachyonConf tachyonConf) { mTachyonFS = tfs; mTFS = TachyonFileSystemFactory.get(); mFileId = fid; mTachyonConf = tachyonConf; }
public TachyonWriterWorker(int id, int left, int right, ByteBuffer buf) throws IOException { super(id, left, right, buf); mTFS = TachyonFileSystem.TachyonFileSystemFactory.get(); }