code: private int computeReplicationWork(
      int blocksToProcess) throws IOException {
      // stall only useful for unit tests (see TestFileAppend4.java)
      if (stallReplicationWork)  {
        return 0;
      }
  
      // Choose the blocks to be replicated
      List<List<BlockInfo>> blocksToReplicate =
        chooseUnderReplicatedBlocks(blocksToProcess);
  
      // replicate blocks
      return computeReplicationWorkForBlocks(blocksToReplicate);
    }
docs: Scan blocks in {@link #neededReplications} and assign replication
  work to data-nodes they belong to.
  <p/>
  The number of process blocks equals either twice the number of live
  data-nodes or the number of under-replicated blocks whichever is less.
  
  @return number of blocks scheduled for replication during this iteration.