/** * @param blockId id of the block * @return the block info associated with the block id, note that this will be a cached copy * and will not fetch the latest info from the master */ public BlockInfo getBlockInfo(long blockId) { Preconditions.checkArgument(mStatus.getBlockIds().contains(blockId), "blockId"); return mStatus.getFileBlockInfos().stream().map(FileBlockInfo::getBlockInfo) .filter(blockInfo -> blockInfo.getBlockId() == blockId).findFirst().get(); }
for (FileBlockInfo fileBlockInfo : mFileSystemMasterView .getFileBlockInfoList(mFileSystemMasterView.getPath(fileId))) { blockIds.add(fileBlockInfo.getBlockInfo().getBlockId());
/** * Creates a new instance of {@link alluxio.util.webui.UIFileBlockInfo}. * * @param fileBlockInfo underlying {@link FileBlockInfo} */ public UIFileBlockInfo(FileBlockInfo fileBlockInfo) { Preconditions.checkNotNull(fileBlockInfo, "fileBlockInfo"); mId = fileBlockInfo.getBlockInfo().getBlockId(); mBlockLength = fileBlockInfo.getBlockInfo().getLength(); mLastAccessTimeMs = -1; addLocations(fileBlockInfo); for (BlockLocation location : fileBlockInfo.getBlockInfo().getLocations()) { mTierAliases.add(location.getTierAlias()); } }
/** * Converts wire type to proto type. * * @param blockInfo the wire type to convert * @return the converted proto type */ public static alluxio.grpc.BlockInfo toProto(BlockInfo blockInfo) { List<alluxio.grpc.BlockLocation> locations = new ArrayList<>(); for (BlockLocation location : blockInfo.getLocations()) { locations.add(toProto(location)); } return alluxio.grpc.BlockInfo.newBuilder().setBlockId(blockInfo.getBlockId()) .setLength(blockInfo.getLength()).addAllLocations(locations).build(); }
String address = workersWithoutBlock.get(i); WorkerInfo jobWorker = jobWorkersByAddress.get(address); assignments.put(jobWorker, new LoadTask(blockInfo.getBlockInfo().getBlockId()));
if (workerPool.isEmpty()) { throw new NotFoundException( ExceptionMessage.BLOCK_UNAVAILABLE.getMessage(info.getBlockId())); blockWorkerInfo = blockWorkerInfo.stream() .filter(workerInfo -> workers.contains(workerInfo.getNetAddress())).collect(toList()); GetWorkerOptions getWorkerOptions = GetWorkerOptions.defaults().setBlockId(info.getBlockId()) .setBlockSize(info.getLength()).setBlockWorkerInfos(blockWorkerInfo); dataSource = policy.getWorker(getWorkerOptions);
/** * Generates a {@link FileBlockInfo} object from internal metadata. This adds file information to * the block, such as the file offset, and additional UFS locations for the block. * * @param inodePath the file the block is a part of * @param blockInfo the {@link BlockInfo} to generate the {@link FileBlockInfo} from * @return a new {@link FileBlockInfo} for the block */ private FileBlockInfo generateFileBlockInfo(LockedInodePath inodePath, BlockInfo blockInfo) throws FileDoesNotExistException { InodeFile file = inodePath.getInodeFile(); FileBlockInfo fileBlockInfo = new FileBlockInfo(); fileBlockInfo.setBlockInfo(blockInfo); fileBlockInfo.setUfsLocations(new ArrayList<>()); // The sequence number part of the block id is the block index. long offset = file.getBlockSizeBytes() * BlockId.getSequenceNumber(blockInfo.getBlockId()); fileBlockInfo.setOffset(offset); if (fileBlockInfo.getBlockInfo().getLocations().isEmpty() && file.isPersisted()) { // No alluxio locations, but there is a checkpoint in the under storage system. Add the // locations from the under storage system. long blockId = fileBlockInfo.getBlockInfo().getBlockId(); List<String> locations = mUfsBlockLocationCache.get(blockId, inodePath.getUri(), fileBlockInfo.getOffset()); if (locations != null) { fileBlockInfo.setUfsLocations(locations); } } return fileBlockInfo; }
/** * Check if the two BlockInfo object are equal. * * @param a the first BlockInfo object to be checked * @param b the second BlockInfo object to be checked */ public void checkEquality(BlockInfo a, BlockInfo b) { Assert.assertEquals(a.getBlockId(), b.getBlockId()); Assert.assertEquals(a.getLength(), b.getLength()); Assert.assertEquals(a.getLocations(), b.getLocations()); Assert.assertEquals(a, b); }
ReadType readType = ReadType.fromProto(options.getOptions().getReadType()); long blockId = info.getBlockId(); long blockSize = info.getLength();
@Override public void reportLostFile(long fileId) throws FileDoesNotExistException, UnavailableException { try ( LockedInodePath inodePath = mInodeTree.lockFullInodePath(fileId, InodeTree.LockMode.READ)) { Inode<?> inode = inodePath.getInode(); if (inode.isDirectory()) { LOG.warn("Reported file is a directory {}", inode); return; } List<Long> blockIds = new ArrayList<>(); try { for (FileBlockInfo fileBlockInfo : getFileBlockInfoListInternal(inodePath)) { blockIds.add(fileBlockInfo.getBlockInfo().getBlockId()); } } catch (InvalidPathException e) { LOG.info("Failed to get file info {}", fileId, e); } mBlockMaster.reportLostBlocks(blockIds); LOG.info("Reported file loss of blocks {}. Alluxio will recompute it: {}", blockIds, fileId); } }
for (FileBlockInfo fileBlockInfo : mFileSystemMasterView .getFileBlockInfoList(mFileSystemMasterView.getPath(fileId))) { blockIds.add(fileBlockInfo.getBlockInfo().getBlockId());
/** * Creates a new instance of {@link UIFileBlockInfo}. * * @param fileBlockInfo underlying {@link FileBlockInfo} */ public UIFileBlockInfo(FileBlockInfo fileBlockInfo) { Preconditions.checkNotNull(fileBlockInfo, "fileBlockInfo"); mId = fileBlockInfo.getBlockInfo().getBlockId(); mBlockLength = fileBlockInfo.getBlockInfo().getLength(); mLastAccessTimeMs = -1; addLocations(fileBlockInfo); for (BlockLocation location : fileBlockInfo.getBlockInfo().getLocations()) { mTierAliases.add(location.getTierAlias()); } }
/** * Generates a {@link FileBlockInfo} object from internal metadata. This adds file information to * the block, such as the file offset, and additional UFS locations for the block. * * @param inodePath the file the block is a part of * @param blockInfo the {@link BlockInfo} to generate the {@link FileBlockInfo} from * @return a new {@link FileBlockInfo} for the block * @throws InvalidPathException if the mount table is not able to resolve the file */ private FileBlockInfo generateFileBlockInfo(LockedInodePath inodePath, BlockInfo blockInfo) throws InvalidPathException, FileDoesNotExistException { InodeFile file = inodePath.getInodeFile(); FileBlockInfo fileBlockInfo = new FileBlockInfo(); fileBlockInfo.setBlockInfo(blockInfo); fileBlockInfo.setUfsLocations(new ArrayList<>()); // The sequence number part of the block id is the block index. long offset = file.getBlockSizeBytes() * BlockId.getSequenceNumber(blockInfo.getBlockId()); fileBlockInfo.setOffset(offset); if (fileBlockInfo.getBlockInfo().getLocations().isEmpty() && file.isPersisted()) { // No alluxio locations, but there is a checkpoint in the under storage system. Add the // locations from the under storage system. long blockId = fileBlockInfo.getBlockInfo().getBlockId(); List<String> locations = mUfsBlockLocationCache.get(blockId, inodePath.getUri(), fileBlockInfo.getOffset()); if (locations != null) { fileBlockInfo.setUfsLocations(locations); } } return fileBlockInfo; }