Question 1:- Write the algorithm for name node to allocate blocks to data nodes?
Ans:- The algorithm follows a master slave relation in which name node is the master and data node is the slave. In order to allocate blocks to data node we follow certain steps, which are mentioned below:
* Clients data which is to be saved is first saved in HDFS (Hadoop Distributed File System), here the physical splitting of data is done in different blocks.
* By default the size of blocks will be 64 MB or it can be configured but in multiples of 64.
* Once the splitting is done then the client request the name node to provide him space to save his data.
* On receiving the request from client name node immediately checks for the available space in data node. This checking of empty space is possible because the communication between name node and data node is very efficient,data node send heart beat about its life status every 3 seconds and even sends periodic block report to name node basing upon which name node decides where to store the data.
* After having information about the vacant space name node suggests client, you can store your data in which data nodes. Simultaneously it creates a replications of all the data blocks but not in the same data nodes rather in different one to increase fault tolerance.
* Once the data is stored it creates a meta data so that it will be easy for him to process further requests made by the client basing upon the requirement.