maxLen - (lastBlock != null ? lastBlock.length() : 0), (blockIdx + 1) * blockSize - offset); lastBlock = new IgfsBlockLocationImpl(offset, lenStep, lastNodes); else lastBlock.increaseLength(lenStep); if (lastBlock.length() == maxLen || lastBlock.start() + lastBlock.length() == end) { blocks.add(lastBlock);
/** * @param start Start. * @param len Length. * @param nodes Affinity nodes. */ public IgfsBlockLocationImpl(long start, long len, Collection<ClusterNode> nodes) { assert start >= 0; assert len > 0; assert nodes != null && !nodes.isEmpty(); this.start = start; this.len = len; convertFromNodes(nodes); }
IgfsBlockLocationImpl location = new IgfsBlockLocationImpl(); location.readExternal(in);
/** * Split blocks according to maximum split length. * * @param start Start position. * @param len Length. * @param maxLen Maximum allowed length. * @param nodes Affinity nodes. * @param res Where to put results. */ private void splitBlocks(long start, long len, long maxLen, Collection<ClusterNode> nodes, Collection<IgfsBlockLocation> res) { if (maxLen > 0) { long end = start + len; long start0 = start; while (start0 < end) { long len0 = Math.min(maxLen, end - start0); res.add(new IgfsBlockLocationImpl(start0, len0, nodes)); start0 += len0; } } else res.add(new IgfsBlockLocationImpl(start, len, nodes)); }
IgfsBlockLocationImpl location = new IgfsBlockLocationImpl(); location.readExternal(in);
/** * Convert IGFS affinity block location into Hadoop affinity block location. * * @param block IGFS affinity block location. * @return Hadoop affinity block location. */ private IgfsBlockLocation convertBlockLocation(BlockLocation block) { try { String[] names = block.getNames(); String[] hosts = block.getHosts(); return new IgfsBlockLocationImpl( block.getOffset(), block.getLength(), Arrays.asList(names), Arrays.asList(hosts)); } catch (IOException e) { throw handleSecondaryFsError(e, "Failed convert block location: " + block); } }
maxLen - (lastBlock != null ? lastBlock.length() : 0), (blockIdx + 1) * blockSize - offset); lastBlock = new IgfsBlockLocationImpl(offset, lenStep, lastNodes); else lastBlock.increaseLength(lenStep); if (lastBlock.length() == maxLen || lastBlock.start() + lastBlock.length() == end) { blocks.add(lastBlock);
/** * Split blocks according to maximum split length. * * @param start Start position. * @param len Length. * @param maxLen Maximum allowed length. * @param nodes Affinity nodes. * @param res Where to put results. */ private void splitBlocks(long start, long len, long maxLen, Collection<ClusterNode> nodes, Collection<IgfsBlockLocation> res) { if (maxLen > 0) { long end = start + len; long start0 = start; while (start0 < end) { long len0 = Math.min(maxLen, end - start0); res.add(new IgfsBlockLocationImpl(start0, len0, nodes)); start0 += len0; } } else res.add(new IgfsBlockLocationImpl(start, len, nodes)); }
/** * @param start Start. * @param len Length. * @param nodes Affinity nodes. */ public IgfsBlockLocationImpl(long start, long len, Collection<ClusterNode> nodes) { assert start >= 0; assert len > 0; assert nodes != null && !nodes.isEmpty(); this.start = start; this.len = len; convertFromNodes(nodes); }