As the Namenode has the metadata (information) related to all the data nodes, it knows which datanode is free.