在client向DataNode写入block之前,会与NameNode有一次通信,由NameNode来选择指定数目的DataNode来存放副本.具体的副本选择策略在BlockPlacementPolicy接口中,其子类实现是BlockPlacementPolicyDefault.该类中会有多个chooseTarget()方法重载,但最终调用了下面的方法: /** * This is not part of the public API but is used by the unit tests…