On what basis NameNode will decide which DataNode to write on?
As the Namenode has the metadata (information) related to all the data nodes, it knows which datanode is free.