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 the read-write operation as per request for the clients.
In HDFS, each DataNode sends Heartbeat and Data Blocks report to NameNode. Receipt of a heartbeat implies that the datanode is functioning properly. A block report contains a list of all blocks on a datanode.
Data node passes a heartbeat signal to Name node in an interval of 2 minutes.When Name node does not receive heartbeat signals from Data node, it assumes that the data node is either dead or non-functional.
As soon as the data node is declared dead/non-functional all the data blocks it hosts are transferred to the other data nodes with which the blocks are replicated initially. This is how Namenode handles datanode failures.
HDFS works in Master/Slave mode where NameNode act as a Master and DataNodes act as a Slave.
NameNode periodically receives a Heartbeat and a Data Blocks report from each of the DataNodes in the cluster in an interval of specified time. Receipt of a Heartbeat indicates that the DataNodes are functioning well.
When Name node does not receive heartbeat signals from Data node, it assumes that the data node is either dead or non-functional. When we declare data node as dead/non-functional all the data blocks it hosts is transferred to the other data nodes with which the blocks are replicated initially.
In this process of transferring the data blocks from dead name node to other data nodes, Name node is not involved