HDFS has Master Slave architecture in which Master is Namenode and slave is Datanode.
HDFS cluster has single namenode that manages file system namespace (metadata) and multiple datanodes that are responsible for storing actual data in HDFS and performing read-write operation.
In HDFS, Each Datanode in the cluster sends a heartbeat in an interval of specified time to the Namenode. If it receives any heartbeat that means the Datanodes are working properly.
If the Namenode doesn’t receive the heartbeat signal, it assumes that either Datanode is dead or non-functioning properly. As soon as the datanodes are declared dead. Data blocks on the failed Datanode are replicated on other Datanodes based on the specified replication factor in hdfs-site.xml file.
Once the failed datanodes comes back the Name node will manage the replication factor again. This is how Namenode handles the failure of data node.