在了解您的完整设置之前,我无法确定,但很有可能这些异常是在附加到管道设置时发生的,就代码而言,您可以说stage == BlockConstructionStage.PIPELINE_SETUP_APPEND。
在任何情况下,由于您的工作已成功完成,您不必担心,为什么它会成功完成是因为尝试打开 DataOutputStream 到 DataNode 管道时会发生一些异常它一直在尝试,直到建立管道。
异常发生在org.apache.hadoop.hdfs.DFSOutputStream,下面是重要的代码sn-ps,供大家理解。
private boolean createBlockOutputStream(DatanodeInfo[] nodes, long newGS, boolean recoveryFlag) {
//Code..
if (pipelineStatus != SUCCESS) {
if (pipelineStatus == Status.ERROR_ACCESS_TOKEN) {
throw new InvalidBlockTokenException(
"Got access token error for connect ack with firstBadLink as "
+ firstBadLink);
} else {
throw new IOException("Bad connect ack with firstBadLink as "
+ firstBadLink);
}
}
//Code..
}
现在,createBlockOutputStream 是从 setupPipelineForAppendOrRecovery 调用的,正如此方法的代码注释所提到的 - “它会一直尝试直到设置管道”。
/**
* Open a DataOutputStream to a DataNode pipeline so that
* it can be written to.
* This happens when a file is appended or data streaming fails
* It keeps on trying until a pipeline is setup
*/
private boolean setupPipelineForAppendOrRecovery() throws IOException {
//Code..
while (!success && !streamerClosed && dfsClient.clientRunning) {
//Code..
success = createBlockOutputStream(nodes, newGS, isRecovery);
}
//Code..
}
如果您仔细阅读完整的 org.apache.hadoop.hdfs.DFSOutputStream 代码,您将了解管道设置试验将继续进行,直到创建管道以供追加或重新使用。
如果你想处理它,那么你可以尝试从hdfs-site.xml 调整dfs.datanode.max.xcievers 属性,最多人报告相同的解决方案。请注意,设置属性后,您需要重新启动 hadoop 服务。
<property>
<name>dfs.datanode.max.xcievers</name>
<value>8192</value>
</property>