/** * Returns the number of blocks the file has. * * @return the number of blocks * @throws IOException if the underlying file does not exist or its metadata is corrupted */ public int getNumberOfBlocks() throws IOException { return getUnCachedFileStatus().getBlockIds().size(); }
/** * Displays the file's all blocks info * * @param path The TachyonURI path as the input of the command * @return 0 if command is successful, -1 if an error occurred * @throws IOException */ public int fileinfo(TachyonURI path) throws IOException { TachyonFile fd; FileInfo fInfo; try { fd = mTfs.open(path); fInfo = mTfs.getInfo(fd); } catch (TachyonException e) { throw new IOException(e.getMessage()); } if (fInfo.isFolder) { System.out.println(path + " is a directory path so does not have file blocks."); return -1; } System.out.println(path + " with file id " + fd.getFileId() + " has the following blocks: "); for (long blockId : fInfo.getBlockIds()) { System.out.println(TachyonBlockStore.get().getInfo(blockId)); } return 0; }
/** * Displays a list of hosts that have the file specified in argv stored. * * @param path The TachyonURI path as the input of the command * @return 0 if command is successful, -1 if an error occurred * @throws IOException */ public int location(TachyonURI path) throws IOException { TachyonFile fd; FileInfo fInfo; try { fd = mTfs.open(path); fInfo = mTfs.getInfo(fd); } catch (TachyonException e) { throw new IOException(e.getMessage()); } System.out.println(path + " with file id " + fd.getFileId() + " is on nodes: "); for (long blockId : fInfo.getBlockIds()) { for (BlockLocation location : TachyonBlockStore.get().getInfo(blockId).getLocations()) { System.out.println(location.getWorkerAddress().getHost()); } } return 0; }
for (long blockId : fileInfo.getBlockIds()) { if (mBlockDataManager.hasBlockMeta(blockId)) { blockExistOnWorker = true;