code: boolean internalReleaseLeaseOne(Lease lease, String src,
          INodeFileUnderConstruction pendingFile, boolean discardLastBlock) throws IOException {
      // if it is safe to discard the last block, then do so
      if (discardLastBlock && discardDone(pendingFile, src)) {
        // Have client retry lease recovery.
        return false;
      }
  
      // Initialize lease recovery for pendingFile. If there are no blocks
      // associated with this file, then reap lease immediately. Otherwise
      // renew the lease and trigger lease recovery.
      if (pendingFile.getTargets() == null ||
        pendingFile.getTargets().length == 0) {
        if (pendingFile.getBlocks().length == 0) {
          finalizeINodeFileUnderConstruction(src, pendingFile);
          NameNode.stateChangeLog.warn("BLOCK*"
            + " internalReleaseLease: No blocks found, lease removed for " +  src);
          // Tell the client that lease recovery has succeeded.
          return true;
        }
        // setup the Inode.targets for the last block from the blocksMap
        //
        Block[] blocks = pendingFile.getBlocks();
        Block last = blocks[blocks.length - 1];
        DatanodeDescriptor[] targets =
          new DatanodeDescriptor[blocksMap.numNodes(last)];
        Iterator<DatanodeDescriptor> it = blocksMap.nodeIterator(last);
        for (int i = 0; it != null && it.hasNext(); i++) {
          targets[i] = it.next();
        }
        pendingFile.setTargets(targets, last.getGenerationStamp());
      }
      // start lease recovery of the last block for this file.
      pendingFile.assignPrimaryDatanode();
      Lease reassignedLease = reassignLease(
        lease, src, HdfsConstants.NN_RECOVERY_LEASEHOLDER, pendingFile
      );
      getEditLog().logOpenFile(src, pendingFile);
      leaseManager.renewLease(reassignedLease);
      return false;  // Have the client retry lease recovery.
    }
docs: Move a file that is being written to be immutable.
  
  @param src   The filename
  @param lease The lease for the client creating the file
  @return true if lease recovery has completed, false if the client has to retry