我把工作连在一起。 reduce at round i
的输出是round Mapper
的setup()
i+1
中所需的文件。我正在尝试在reduce
中获取此文件的名称。什么是访问作业索引的好方法?也许给作业指定名称i
并在reduce
中访问该名称?
更新对于每个作业,我需要报告一个值,该值是我在reduce
中计算的每个作业的摘要统计信息(我有一个reducer)。如何将该值输出到其自己的文件中或追加到单个文件中?我的输出路径已经用于主要计算。
最后,我将摘要统计信息附加到每个 reducer 的cleanup
中的HDFS文件中,并且每个作业只有一个 reducer 。
@Override
protected void cleanup(Context context) throws IOException, InterruptedException {
FileSystem hdfs = FileSystem.get(context.getConfiguration());
FSDataOutputStream os = hdfs.append(new Path(COST_FILENAME));
PrintStream out = new PrintStream(os);
out.println(String.valueOf(cost));
out.close();
}
最佳答案
一种简单的解决方案是使用Job#setInputPath()
和Job#setOutputPath()
为作业使用不同的输入/输出文件夹。
input
,输出:output-1
output-1
,输出:output-2
output-(N-1)
,输出:output-N
关于java - Hadoop作业链:跟踪作业索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21539184/