org.apache.hadoop.dfs.DataNode
DataNode is a class (and program) that stores a set of blocks for a DFS deployment. A single deployment can have one or many DataNodes. Each DataNode communicates regularly with a single NameNode. It also communicates with client code and other DataNodes from time to time.
[译]DataNode是一个为DFS deployment存储一系列blocks的类。一个单一的deployment可以有很多个DataNode。每一个DataNode规律地和一个单一的NameNode交互。它也与client和其他DataNode交互
DataNodes store a series of named blocks. The DataNode allows client code to read these blocks, or to write new block data. The DataNode may also, in response to instructions from its NameNode, delete blocks or copy blocks to/from other DataNodes.
[译]DataNodes存储了一系列有名字的block。DataNode允许client代码读这些block,或者写新的block数据。DataNode也会遵照它所属的NameNode的指令,删除或者拷贝来自或者去往其他DataNodes的block
The DataNode maintains just one critical table: block-> stream of bytes (of BLOCK_SIZE or less) This info is stored on a local disk. The DataNode reports the table's contents to the NameNode upon startup and every so often afterwards.
[译]DataNode只维护了一个关键的表:block到比特流。这个信息保存在一个本地磁盘上。在DataNode启动时或者每隔一段时间,DataNode将表的内容报告给NameNode。
DataNodes spend their lives in an endless loop of asking the NameNode for something to do. A NameNode cannot connect to a DataNode directly; a NameNode simply returns values from functions invoked by a DataNode. DataNodes maintain an open server socket so that client code or other DataNodes can read/write data. The host/port for this server is reported to the NameNode, which then sends that information to clients or other DataNodes that might be interested.
[译]DataNodes 花费自己全部的生命(……)用在一个无限的循环中,在这个循环中它一直在找NameNode求活干。一个NameNode不能够直接连接一个DataNode。一个NameNode只能返回DataNode调用的函数返回的值(换句话说是被动模式)。DataNodes维护一个server socket,因此client代码和其他的DataNodes也可以读写数据。DataNode上关于这个server的host/port信息会报告给NameNode,然后再发送给client和其他感兴趣的DataNodes.
与DataNodes相关的类也有许多,下面我们自上而下的慢慢拆解:
从他的类变量中,我们可以得到下面的变量:
DatanodeProtocol namenode:这个是datanode和namenode交互的接口、
FSDataSet data:存储真实结构的地方
DatanodeRegistration dnRegistration:这个是Datanode和namenode交互的凭证,有了它Datanode就可以和Namenode交互了
Vector receivedBlockList:这个是干啥用的?
Daemon dataXceiveServer:
Block:这个类只作记录数据块的基本信息之用。里面有两个变量:blockId和blockLen