reducer可以将消息传递给Hadoop mapreduce中的驱动程序吗?

时间:2017-10-29 04:55:37

标签: java hadoop mapreduce

我必须实现map-reduce作业循环。每次迭代都将终止或继续,具体取决于前一次迭代。要做的选择是基于“减速器输出中出现一个单词”。

当然我可以用我的驱动程序检查整个输出txt文件。但这只是一个单词,整个文件都会过度杀伤。我在考虑是否有任何方法可以在减速器和驱动器之间建立通信,减速器可以在检测到字后通知驱动程序?由于要传输的消息很少。

1 个答案:

答案 0 :(得分:-1)

您的解决方案将不是一个干净的解决方案,难以维护。

有多种方法可以实现您的要求。

 1. Reducer as soon as it finds a word writes to a HDFS location (opens file on hdfs predefine filedir and writes there)
 2. client keeps polling the predefined filedir / output dir of the job. If the output dir is found and there is no filedir it means word wasnt there. 
 3. Use Zookeper
  

最佳解决方案是,只有找到单词时才从mapper发出,   否则不发射任何东西。这将紧固你的工作,并产生一个单一的   减速器。现在,您可以安全地检查作业的输出是否有输出文件。使用延迟初始化,如果没有行到reducer,则不会创建输出文件