[英]Can a reducer pass a message to driver in Hadoop mapreduce?
我必須實現一個map-reduce作業循環。 每次迭代將終止或繼續,具體取決於上一個迭代。 選擇基於“在減速器輸出中是否出現一個字”。
當然,我可以使用驅動程序檢查整個輸出txt文件。 但這只是一個字,瀏覽整個文件會顯得過分殺傷力。 我正在考慮有什么方法可以在減速器和驅動程序之間建立通信,減速器一旦檢測到單詞就可以通知驅動程序? 由於要傳送的消息很少。
您的解決方案將不是一個干凈的解決方案,並且很難維護。
有多種方法可以實現您的要求。
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
最好的解決方案是to,僅在找到單詞時才從mapper發出,否則不發出任何東西。 這樣可以加快您的工作速度,並產生一個減速器。 現在,您可以安全地檢查作業的輸出中是否有任何文件。 使用惰性初始化,以防萬一沒有行進入減速器,則不會創建任何輸出文件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.