0

我的程序中使用DistributedCache來緩存文件配置()的Hadoop集羣上運行,但可以在Eclipse調用時不被調用,DistributedCache FileNotFoundException異常

JobConf conf = new JobConf(new Configuration(), ItemMining.class); 
DistributedCache.addCacheFile(new URI("output1/FList.txt"), conf); 
DistributedCache.addCacheFile(new URI("output1/GList.txt"), conf); 

我得到的文件

configure(){ 

.. 
localFiles = DistributedCache.getLocalCacheFiles(job); 
FileSystem fs = FileSystem.get(job); 
FSDataInputStream inF = fs.open(localFiles[0]); 
.. 

} 

整個程序可以運行並在Eclipse上獲得正確的結果。但是當我在Hadoop集羣中運行它時,我發現這部分不會被調用! 這是爲什麼發生? 我需要在配置中設置一些東西嗎?

+0

你能爲你的課程發佈更多的代碼/上下文嗎? –

+0

問題解決了,感謝提問@ChrisWhite – user2070763

回答

0

問題解決了,事實證明,我做了兩個錯誤:

1)我在配置()的開頭加了的System.out.println(),但它並沒有顯示出來 事實mapreduce不能在mapreduce階段使用System.out.println(),如果我們想看看它,我們需要檢查我們的日誌,詳情請見Where does hadoop mapreduce framework send my System.out.print() statements ? (stdout)

2)我真正的錯誤與分佈式緩存,我添加了一個文件,並希望將其讀入內存中,以打開路徑,我們需要FileSystem.getLocal(),如下所示:

localFiles = DistributedCache.getLocalCacheFiles(job); 
    FileSystem fs = FileSystem.getLocal(job); 
    FSDataInputStream inF = fs.open(localFiles[0]); 

感謝Hadoop: FileNotFoundExcepion when getting file from DistributedCache

相關問題