尝试从 HDFS 读取一些作业配置文件时遇到一个奇怪的错误。我正在尝试从文件中检索作业,然后循环读取它们的作业配置 XML 文件。
摘抄:
for(JobStatus status : statuses)
{
JobID jobId = null;
try
{
jobId = status.getJobID(); //TODO check the hash-code/equals implementation of JobID
if(!jobIdsUnderObservation.contains(jobId))
{ //explore jobs if it's new
RunningJob runningJob = jobClient.getJob(jobId);
if(runningJob != null)
{
String jobFile = runningJob.getJobFile();
FileSystem fs = FileSystem.get(conf);
if(fs.exists(new Path(jobFile)))
{
String sessionId = null;
InputStream is = fs.open(new Path(jobFile));
conf.addResource(is);
sessionId = conf.get("hive.session.id"); //this particular line breaks
//from the second file onwards
if(sessionId.equals(this.sessionId))
{
jobIdsUnderObservation.add(jobId);
}
}
}
}
}
catch(IOException ioe)
{
ioe.printStackTrace();
}
int prevStatus = 0;
它可以很好地读取第一个文件,但它会从第二个文件开始中断。它抛出一个 IOException:流已关闭。