/** * 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."); }
/** * 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."); }
/** * 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."); }
/** * 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."); }
/** * @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."); }
/** * @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."); }
/** * @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."); }
/** * @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 file info for the given file id * @throws IOException if an I/O error occurs */ // TODO(jiri): Factor this method out to a common client. public synchronized FileInfo getFileInfo(long fileId) throws IOException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.getFileInfo(fileId); } catch (TachyonTException e) { throw new IOException(e); } 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."); }
@Override protected void afterConnect() { mClient = new FileSystemMasterService.Client(mProtocol); }
@Override protected void afterConnect() { mClient = new FileSystemMasterService.Client(mProtocol); }