code: private void replicateLastBlock(String src, INodeFileUnderConstruction file) {
      BlockInfo[] blks = file.getBlocks();
      if (blks == null || blks.length == 0)
        return;
      BlockInfo block = blks[blks.length-1];
      DatanodeDescriptor[] targets = file.getValidTargets();
      final int numOfTargets = targets == null ? 0 : targets.length;
      NumberReplicas status = countNodes(block);
      int totalReplicas = status.getTotal();
      if (numOfTargets > totalReplicas) {
        pendingReplications.add(block, numOfTargets-totalReplicas);
      }
      int expectedReplicas = file.getReplication();
      if (numOfTargets < expectedReplicas || 
          status.decommissionedReplicas != 0 ||
          status.corruptReplicas != 0) {
        LOG.info("Add " + block + " of " + src + " to needReplication queue: " + 
            " numOfTargets = " + numOfTargets +
            " decomissionedReplicas = " + status.decommissionedReplicas +
            " corruptReplicas = " + status.corruptReplicas);
        neededReplications.add(block, status.liveReplicas, 
            status.decommissionedReplicas, expectedReplicas);
      }
      
      // update metrics
      if (numOfTargets < expectedReplicas) {
        if (numOfTargets == 1) {
          myFSMetrics.numNewBlocksWithOneReplica.inc();
        }
      } else {
        myFSMetrics.numNewBlocksWithoutFailure.inc();
      }
      myFSMetrics.numNewBlocks.inc();
    }
docs: Check last block of the file under construction
  Replicate it if it is under replicated
  @param src the file name
  @param file the file's inode