/** * Get file id by the path. It will check if the path exists. * * @param path the path in Tachyon file system * @return the file id if exists, INVALID_FILE_ID otherwise */ public synchronized long getFileId(TachyonURI path) { try { FileInfo fileInfo = getFileStatus(IdUtils.INVALID_FILE_ID, path, false); return fileInfo == null ? -IdUtils.INVALID_FILE_ID : fileInfo.getFileId(); } catch (IOException e) { return IdUtils.INVALID_FILE_ID; } }
/** * If the <code>path</code> is a directory, returns all the direct entries in it. If the * <code>path</code> is a file, returns its ClientFileInfo. * * @param path the target directory/file path * @return A list of FileInfo, null if the file or folder does not exist * @throws IOException when the underlying master RPC fails */ @Override public synchronized List<FileInfo> listStatus(TachyonURI path) throws IOException { validateUri(path); try { return mFSMasterClient.getFileInfoList( getFileStatus(IdUtils.INVALID_FILE_ID, path).getFileId()); } catch (TachyonException e) { throw new IOException(e); } }
/** * Gets <code>TachyonFile</code> based on the path. If useCachedMetadata is true, this will not * see changes to the file's pin setting, or other dynamic properties. * * @param path file path. * @param useCachedMetadata whether to use the file metadata cache * @return TachyonFile of the path, or null if the file does not exist * @throws IOException if the underlying master RPC fails */ public synchronized TachyonFile getFile(TachyonURI path, boolean useCachedMetadata) throws IOException { validateUri(path); FileInfo fileInfo = getFileStatus(IdUtils.INVALID_FILE_ID, path, useCachedMetadata); if (fileInfo == null) { return null; } return new TachyonFile(this, fileInfo.getFileId(), mTachyonConf); }
public UiFileInfo(FileInfo fileInfo) { mId = fileInfo.getFileId(); mName = fileInfo.getName(); mAbsolutePath = fileInfo.getPath(); mBlockSizeBytes = fileInfo.getBlockSizeBytes(); mSize = fileInfo.getLength(); mCreationTimeMs = fileInfo.getCreationTimeMs(); mLastModificationTimeMs = fileInfo.getLastModificationTimeMs(); mInMemory = (100 == fileInfo.inMemoryPercentage); mInMemoryPercent = fileInfo.getInMemoryPercentage(); mIsDirectory = fileInfo.isFolder; mIsPinned = fileInfo.isPinned; mFileLocations = new ArrayList<String>(); for (int i = 0; i < StorageLevelAlias.SIZE; i ++) { mBlocksOnTier.add(new ArrayList<UiBlockInfo>()); } }
ret.id = fileInfo.getFileId(); ret.name = fileInfo.getName(); ret.path = fileInfo.getPath();