Original post blog: http://www.oratea.net /? P = 799, add some modifications.
Datanodeprotocol. Java
Path: hadoop-0.19.2 \ SRC \ HDFS \ org \ apache \ hadoop \ HDFS \ Server \ protocol \ datanodeprotocol. Java
Datanodeprotocol is an information interface for communication between datanode and namenode. It defines all operations initiated by datanode to amenode.
1 public static final long versionid = 19l;
This identifies the Protocol version information, which is 19l for 0.19.2.
2 Final Static int running y = 0;
Final Static int disk_error = 1;
Final Static int invalid_block = 2;
Defines common error codes
3 Final Static int DNA _ Unknown = 0; // unknown action
Final Static int DNA _transfer = 1; // transfer blocks to another datanode
Final Static int DNA _ invalidate = 2; // invalidate Blocks
Final Static int DNA _ shutdown = 3; // shutdown Node
Final Static int DNA _ register = 4; // re-register
Final Static int DNA _ finalize = 5; // finalize previous upgrade
Final Static int DNA _ recoverblock = 6; // request a block recovery
Defines the code of the command that namenode sends to datanode
4 Public datanoderegistration register (datanoderegistration Registration
) Throws ioexception;
When HDFS is started, register the datanode with namenode. Registration indicates the registration information of datanode,
It mainly includes the machine name of datanode, the port of datanode, storageid, the port of infoserver, the port of IPC server, and storageinfo.
5 Public datanodecommand [] sendheartbeat (datanoderegistration registration,
Long capacity,
Long dfsused, long remaining,
Int xmitsinprogress,
Int xceivercount) throws ioexception;
During HDFS's work, the heartbeat information sent to namenode regularly tells namenode that it is still alive. Some datanode status information will also be sent during heartbeat sending.
For example, the storage capability of the current datanode. Available space, available space, and so on.
The sending heartbeat frequency is controlled by the DFS. Heartbeat. interval parameter. The default value is 3 seconds.
After receiving the heartbeat information of datanode, namenode returns some command information about the datanode to datanode and uses the datanodecommand [] structure.
6 Public datanodecommand blockreport (datanoderegistration registration,
Long [] blocks) throws ioexception;
After datanode is started, all block information stored locally is reported to namenode.
Block information is stored in the long array blocks. The block type is replaced by long to save memory usage.
7 public void blockreceived (datanoderegistration registration,
Block blocks [],
String [] delhints) throws ioexception;
This method allows datanode to report the block information received recently to namenode. For example, when the datanode generates a new block, or another datanode replicates a block to the datanode,
Datanode will call this method to report to namenode.
8 Public void errorreport (datanoderegistration registration,
Int errorcode,
String MSG) throws ioexception;
Datanode reports error information to namenode through this method, mainly for debugging
9 Public namespaceinfo versionrequest () throws ioexception;
Obtain namespaceinfo information from namenode. namespaceinfo mainly contains buildversion and distributedupgradeversion information.
10 upgradecommand processupgradecommand (upgradecommand comm) throws ioexception;
This method sends Command Information to namenode during distributed upgrade.
11 Public void reportbadblocks (locatedblock [] blocks) throws ioexception;
Datanode sends bad block information to namenode through this method
12 public long nextgenerationstamp (Block block) throws ioexception;
Obtain the new stamp information, which is the version information of each block.
13 public void commitblocksynchronization (Block block,
Long newgenerationstamp, long newlength,
Boolean closefile, Boolean deleteblock, datanodeid [] newtargets
) Throws ioexception;
Status information of the submitted Block