/** * @return the under file system address * @throws IOException if an I/O error occurs */ public synchronized String getUfsAddress() throws IOException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.getUfsAddress(); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * @param path the path * @return the file id for the given path, or -1 if the path does not point to a file * @throws IOException if an I/O error occurs */ public synchronized long getFileId(String path) throws IOException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.getFileId(path); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * @param fileId the file id * @return a new block id for the given file id * @throws IOException if an I/O error occurs * @throws TachyonException if a Tachyon error occurs */ public synchronized long getNewBlockIdForFile(long fileId) throws IOException, TachyonException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.getNewBlockIdForFile(fileId); } catch (TachyonTException e) { throw new TachyonException(e); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Unmounts the given Tachyon path. * * @param tachyonPath the Tachyon path * @throws IOException an I/O error occurs */ public synchronized boolean unmount(TachyonURI tachyonPath) throws IOException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.unmount(tachyonPath.toString()); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); } }
/** * @param fileId the file id * @return the file info for the given file id * @throws IOException if an I/O error occurs * @throws TachyonException if a Tachyon error occurs */ public synchronized FileInfo getFileInfo(long fileId) throws IOException, TachyonException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.getFileInfo(fileId); } catch (TachyonTException e) { throw new TachyonException(e); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Reports a lost file. * * @param fileId the file id * @throws IOException if an I/O error occurs * @throws TachyonException if a Tachyon error occurs */ public synchronized void reportLostFile(long fileId) throws IOException, TachyonException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { mClient.reportLostFile(fileId); } catch (TachyonTException e) { throw new TachyonException(e); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Deletes a file. * * @param fileId the file id * @param recursive whether to delete the file recursively (when it is a directory) * @return whether operation succeeded or not * @throws IOException if an I/O error occurs * @throws TachyonException if a Tachyon error occurs */ public synchronized boolean deleteFile(long fileId, boolean recursive) throws IOException, TachyonException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.deleteFile(fileId, recursive); } catch (TachyonTException e) { throw new TachyonException(e); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Sets the "pinned" status for a file. * * @param fileId the file id * @param pinned the pinned status to use * @throws IOException if an I/O error occurs * @throws TachyonException if a Tachyon error occurs */ public synchronized void setPinned(long fileId, boolean pinned) throws IOException, TachyonException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { mClient.setPinned(fileId, pinned); return; } catch (TachyonTException e) { throw new TachyonException(e); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * @param fileId the file id * @return the list of file information for the given file id * @throws IOException if an I/O error occurs * @throws TachyonException if a Tachyon error occurs */ public synchronized List<FileInfo> getFileInfoList(long fileId) throws IOException, TachyonException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.getFileInfoList(fileId); } catch (TachyonTException e) { throw new TachyonException(e); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * @param fileId the file id * @return the list of file block information for the given file id * @throws IOException if an I/O error occurs * @throws TachyonException if a Tachyon error occurs */ // TODO(calvin): Not sure if this is necessary. public synchronized List<FileBlockInfo> getFileBlockInfoList(long fileId) throws IOException, TachyonException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.getFileBlockInfoList(fileId); } catch (TachyonTException e) { throw new TachyonException(e); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Marks a file as completed. * * @param fileId the file id * @throws IOException if an I/O error occurs * @throws TachyonException if a Tachyon error occurs */ public synchronized void completeFile(long fileId) throws IOException, TachyonException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { mClient.completeFile(fileId); return; } catch (TachyonTException e) { throw new TachyonException(e); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Renames a file. * * @param fileId the file id * @param dstPath new file path * @return whether operation succeeded or not * @throws IOException if an I/O error occurs * @throws TachyonException if a Tachyon error occurs */ public synchronized boolean renameFile(long fileId, String dstPath) throws IOException, TachyonException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.renameFile(fileId, dstPath); } catch (TachyonTException e) { throw new TachyonException(e); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Loads a file from the under file system. * * @param path the Tachyon path of the file * @param recursive whether parent directories should be loaded if not present yet * @return the file id * @throws TachyonException if a tachyon error occurs * @throws IOException if an I/O error occurs */ public synchronized long loadMetadata(String path, boolean recursive) throws IOException, TachyonException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.loadMetadata(path, recursive); } catch (TachyonTException e) { throw new TachyonException(e); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * @param fileId the file id * @param fileBlockIndex the file block index * @return the file block information * @throws IOException if an I/O error occurs * @throws TachyonException if a Tachyon error occurs */ // TODO(calvin): Not sure if this is necessary. public synchronized FileBlockInfo getFileBlockInfo(long fileId, int fileBlockIndex) throws IOException, TachyonException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.getFileBlockInfo(fileId, fileBlockIndex); } catch (TachyonTException e) { throw new TachyonException(e); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Frees a file. * * @param fileId the file id * @param recursive whether free the file recursively (when it is a directory) * @return whether operation succeeded or not * @throws IOException if an I/O error occurs * @throws TachyonException if a Tachyon error occurs */ public synchronized boolean free(long fileId, boolean recursive) throws IOException, TachyonException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.free(fileId, recursive); } catch (TachyonTException e) { throw new TachyonException(e); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Mounts the given UFS path under the given Tachyon path. * * @param tachyonPath the Tachyon path * @param ufsPath the UFS path * @throws IOException an I/O error occurs */ public synchronized boolean mount(TachyonURI tachyonPath, TachyonURI ufsPath) throws IOException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.mount(tachyonPath.toString(), ufsPath.toString()); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Creates a new file. * * @param path the file path * @param options method options * @return the file id * @throws IOException if an I/O error occurs * @throws TachyonException if a Tachyon error occurs */ public synchronized long create(String path, CreateOptions options) throws IOException, TachyonException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.create(path, options.toThrift()); } catch (TachyonTException e) { throw new TachyonException(e); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Creates a new directory. * * @param path the directory path * @param options method options * @return whether operation succeeded or not * @throws IOException if an I/O error occurs * @throws TachyonException if a Tachyon error occurs */ public synchronized boolean mkdir(String path, MkdirOptions options) throws IOException, TachyonException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.mkdir(path, options.toThrift()); } catch (TachyonTException e) { throw new TachyonException(e); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }