/**
* Given datanode address or host name, returns the DatanodeDescriptor for the
* same, or if it doesn't find the datanode, it looks for a machine local and
* then rack local datanode, if a rack local datanode is not possible either,
* it returns the DatanodeDescriptor of any random node in the cluster.
*
* @param address hostaddress:transfer address
* @return the best match for the given datanode
*/
// If we can't even choose rack local, just choose any node in the
// cluster.
if (node == null) {
node = (DatanodeDescriptor)getNetworkTopology()
.chooseRandom(NodeBase.ROOT);
}
2条答案
按热度按时间niwlg2el1#
我看过源代码,知道相关原理
dced5bon2#
你不能这样做。这对HDFS客户端是透明的。块的放置正是你所要求的。文件被分成块。只有块被放置在数据节点中,而不是文件。创建“文件”的信息只作为元数据存储在名称节点中(数据节点上块列表的文件路径)
https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html