/** * Promotes block back to top layer after access. * * @param blockIndex the index of the block * @return true if success, false otherwise * @throws IOException if the underlying file does not exist or its metadata is corrupted */ public boolean promoteBlock(int blockIndex) throws IOException { FileBlockInfo fileBlockInfo = getClientBlockInfo(blockIndex); return mTachyonFS.promoteBlock(fileBlockInfo.blockInfo.getBlockId()); }
/** * Returns the net address of all the location hosts * * @return the list of those net address, in String * @throws IOException if the underlying file does not exist or its metadata is corrupted */ public List<String> getLocationHosts() throws IOException { List<String> ret = Lists.newArrayList(); if (getNumberOfBlocks() > 0) { // add tachyon locations first List<BlockLocation> blockLocations = getClientBlockInfo(0).getBlockInfo().getLocations(); if (blockLocations != null) { for (BlockLocation location : blockLocations) { ret.add(location.workerAddress.host); } } // under FS locations List<NetAddress> underFsLocations = getClientBlockInfo(0).getUfsLocations(); if (underFsLocations != null) { for (NetAddress location : underFsLocations) { ret.add(location.host); } } } return ret; }
/** * Returns the local filename for the block if that file exists on the local file system. This is * an alpha power-api feature for applications that want short-circuit-read files directly. There * is no guarantee that the file still exists after this call returns, as Tachyon may evict blocks * from memory at any time. * * @param blockIndex The index of the block in the file * @return filename on local file system or null if file not present on local file system * @throws IOException if the underlying file does not exist or its metadata is corrupted */ public String getLocalFilename(int blockIndex) throws IOException { FileBlockInfo fileBlockInfo = getClientBlockInfo(blockIndex); long blockId = fileBlockInfo.blockInfo.getBlockId(); int blockLockId = mTachyonFS.getBlockLockId(); String filename = mTachyonFS.lockBlock(blockId, blockLockId); if (filename != null) { mTachyonFS.unlockBlock(blockId, blockLockId); } return filename; }