After understanding the name nodes, data nodes, and clients in the HDFS architecture, we analyze the source code structure of the HDFS implementation. The HDFs source code is under the Org.apache.hadoop.hdfs package, which is shown in structure 6-3.
The source code for HDFS is distributed in the I6 directory, which can be divided into the following four classes.
1. Basic Package
Includes tools and security packs. Among them, Hdfs.util contains some of the auxiliary data structures required for HDFS implementations: Hdfs.security.token.hlock and Hdfs.security.token.delegation combine the security framework of HADAOP to provide a secure access to HDFS mechanism. This security feature was first developed by Yahoo, and integrates the enterprise's widely used Kerberos standards to enable users to manage a wide range of commercially sensitive data in a single cluster.
2.HDFS Entity Implementation Package
This is the focus of code analysis, which consists of 7 packages:
Hdfs.server.common includes features that are shared by name nodes and data nodes, such as system upgrades, storage space information, and so on.
Hdfs.protocol provides an interface through IPC interactions between various entities in HDFs. Hdfs.server.datanode and HDFs contain the implementation of the name node, data node, and client respectively. The above code is the focus of HDFS code analysis.
Hdfs.server.namennde.metrics and Hdfs.server.datanode.metrics implement the collection of metric data on name nodes and data nodes. The metric data includes information such as the name node process and the count of events on the data node, such as the number of bytes written, the number of blocks copied, etc. on the data node.
3. Application Package
including Hdfs.tools and Hdfs.server.balancer, these two packages provide the query HDFs status information tool dfsadmin, the file system Check tool fsck, and the HDFs equalizer balancer (via Start-balancer. SH-start) implementation.
4. Webhdfs Related Packages
including Hdfs.web.resources, Hdfs.server.namenode.web.resourees, Hdfs.server.datanode.web.resources and Hdfs.web a total of 4 packages.
Webhdfs is a new feature introduced in HDFs 1.0, which provides a complete mechanism for accessing HDFS over HTTP. Compared to the read-only hftp file system, WEBHDFS provides the ability to read and write HDFs on HTTP, and on this basis implements the C client and user space file system (fuse that accesses HDFs.
HDFs Source code Structure