@Override public TachyonFS createClient(String uri) throws IOException { if (!uri.startsWith(PREFIX)) uri = PREFIX + uri; return TachyonFS.get(uri); } }
@Override protected InputStream open(long offset) throws IOException { TachyonFS tfs = (TachyonFS) (Persist.I[Value.TACHYON].createClient(clientURI)); InputStream is = tfs.getFile(fpath).getInStream(ReadType.NO_CACHE); is.skip(offset); return is; } }
client = ((PersistTachyon) Persist.I[Value.TACHYON]).createClient(PersistTachyon.PREFIX+serverUri); String rootFolder = pathComponents[1]; List<ClientFileInfo> filesOnTFS= client.listStatus(rootFolder); // do a recursive descend Futures fs = new Futures(); for (ClientFileInfo f : filesOnTFS ) { fillEmpty("Cannot access specified file(s) on tachyon FS, because " + e.getMessage()); } finally { if (client!=null) try { client.close(); } catch (TException _ ) {};
@Override protected FileSystemMasterClient createNewResource() { return new FileSystemMasterClient(mMasterAddress, ClientContext.getConf()); } }
@Override protected BlockMasterClient createNewResource() { return new BlockMasterClient(mMasterAddress, ClientContext.getConf()); } }
/** * Returns whether this file is complete or not * * @return true if this file is complete, false otherwise * @throws IOException if the underlying file does not exist or its metadata is corrupted */ public boolean isCompleted() throws IOException { return getCachedFileStatus().isCompleted || getUnCachedFileStatus().isCompleted; }
/** * Deletes the file denoted by the file id. * * @param fid file id * @param recursive if delete the path recursively. * @return true if deletion succeed (including the case the file does not exist in the first * place), false otherwise * @throws IOException if the operation fails */ public synchronized boolean delete(long fid, boolean recursive) throws IOException { return delete(fid, TachyonURI.EMPTY_URI, recursive); }
/** * @param writeType the write type to use * @return the builder */ public Builder setWriteType(WriteType writeType) { mUnderStorageType = writeType.getUnderStorageType(); return this; }
/** * @return the {@link TachyonStorageType} which is associated with this mode */ public TachyonStorageType getTachyonStorageType() { if (isCache()) { return TachyonStorageType.STORE; } return TachyonStorageType.NO_STORE; }
/** * Renames the srcPath to the dstPath. * * @param srcPath The path of the source file / folder. * @param dstPath The path of the destination file / folder. * @return true if succeed, false otherwise * @throws IOException if the operation fails */ public synchronized boolean rename(TachyonURI srcPath, TachyonURI dstPath) throws IOException { return rename(-1, srcPath, dstPath); }
/** * Returns the id of a block in the file, specified by blockIndex. * * @param blockIndex the index of the block in this file * @return the block id * @throws IOException if the underlying file does not exist or its metadata is corrupted */ public long getBlockId(int blockIndex) throws IOException { return mTachyonFS.getBlockId(mFileId, blockIndex); }
/** * Renames this file. * * @param path the new name * @return true if succeed, false otherwise * @throws IOException if an event that prevent the operation from completing is encountered */ public boolean rename(TachyonURI path) throws IOException { return mTachyonFS.rename(mFileId, path); }
/** * Checks if this client is connected to master. * * @return true if this client is connected to master, false otherwise */ public synchronized boolean isConnected() { return mFSMasterClient.isConnected(); }
/** * @return the tachyonConf for the client process */ public static synchronized TachyonConf getConf() { checkContextInitialized(); return sTachyonConf; }
/** * Gets <code>ClientFileInfo</code> object based on fileId. * * @param fileId the file id of the file or folder. * @param useCachedMetadata if true use the local cached meta data * @return the FileInfo of the file. null if the file does not exist * @throws IOException if the underlying master RPC fails */ public synchronized FileInfo getFileStatus(long fileId, boolean useCachedMetadata) throws IOException { return getFileStatus(fileId, TachyonURI.EMPTY_URI, useCachedMetadata); }
/** * @return the address of the UnderFileSystem * @throws IOException if the underlying master RPC fails */ public synchronized String getUfsAddress() throws IOException { return mFSMasterClient.getUfsAddress(); }
/** * @return all the works' info * @throws IOException if the underlying master RPC fails */ public synchronized List<WorkerInfo> getWorkersInfo() throws IOException { return mBlockMasterClient.getWorkerInfoList(); }
/** * Updates the RawTable's meta data. * * Currently unsupported. * * @param id the raw table's id * @param metadata the new meta data * @throws IOException if the underlying master RPC fails */ public synchronized void updateRawTableMetadata(long id, ByteBuffer metadata) throws IOException { mRawTableMasterClient.updateRawTableMetadata(id, metadata); }
@Override public byte[] load(Value v) { Key k = v._key; // key for value if (k._kb[0] != Key.DVEC) throw H2O.unimpl(); // Load only from values stored in vector long skip = FileVec.chunkOffset(k); // Compute skip for this value long start_io_ms = System.currentTimeMillis(); final byte[] b = MemoryManager.malloc1(v._max); String[] keyComp = decodeKey(k); String clientUri = keyComp[0]; String fpath = keyComp[1]; TachyonFS tfs = null; InputStream is = null; try { tfs = (TachyonFS) (Persist.I[Value.TACHYON].createClient(clientUri)); long start_ns = System.nanoTime(); // Blocking i/o call timing - without counting repeats is = tfs.getFile(fpath).getInStream(ReadType.NO_CACHE); ByteStreams.skipFully(is, skip); ByteStreams.readFully(is, b); TimeLine.record_IOclose(start_ns, start_io_ms, 1/* read */, v._max, Value.TACHYON); return b; } catch (IOException e) { throw new RuntimeException(Log.err("File load failed: ", e)); } finally { if (is!=null) Utils.close(is); } }
/** * Deletes the file denoted by the path. * * @param path the file path * @param recursive if delete the path recursively. * @return true if the deletion succeed (including the case that the path does not exist in the * first place), false otherwise * @throws IOException if the operation fails */ public synchronized boolean delete(TachyonURI path, boolean recursive) throws IOException { return delete(-1, path, recursive); }