FileStatus srcFile,
BlockAndDatanodeResolver resolver)
throws IOException {
// check the block placement policy
for (BlockInfo srcBlock : srcBlocks) {
LocatedBlockWithMetaInfo locatedBlock = resolver.getLocatedBlock(srcBlock);
DatanodeInfo[] datanodes = locatedBlock.getLocations();
if (datanodes.length != DEFAULT_NON_RAID_FILE_REPLICATION) {
continue;
}
// move the block if all the 3 replicas are in the same rack.
if (blockMover.isOnSameRack(datanodes[0], datanodes[1])
&& blockMover.isOnSameRack(datanodes[1], datanodes[2])) {
Set<DatanodeInfo> excludedNodes = new HashSet<DatanodeInfo>(Arrays.asList(datanodes));
DatanodeInfo target = blockMover.chooseTargetNodes(excludedNodes);
blockMover.move(locatedBlock, datanodes[2], target, excludedNodes, 3,
locatedBlock.getDataProtocolVersion(), locatedBlock.getNamespaceID());
// log the move submit info
if (LOG.isDebugEnabled()) {
LOG.debug("Move src block : " + locatedBlock.getBlock().getBlockId() + " from " +
datanodes[2] + " to target " + target + ", priority: 3. Replica info: " +
datanodes[0] + ", " + datanodes[1] + ", " + datanodes[2] +
". Src file: " + srcFile.getPath());
}
}