2013-02-12 61 views
1

我能夠使用DistributedCache訪問單個文件,但無法訪問存檔。 在main方法我加入檔案爲DistributedCache無法訪問存檔

DistributedCache.addCacheArchive(new Path("/stocks.gz").toUri(), job.getConfiguration()); 

其中/stocks.gz是HDFS。在映射器我用,

Path[] paths = DistributedCache.getLocalCacheArchives(context.getConfiguration()); 
File localFile = new File(paths[0].toString()); 

會拋出異常,

java.io.FileNotFoundException: /tmp/hadoop-user/mapred/local/taskTracker/distcache/-8696401910194823450_622739733_1347031628/localhost/stocks.gz (No such file or directory) 

我期待的DistributedCache解壓/stocks.gz和使用基本的文件映射器,但它拋出一個FileNotFound例外。

傳遞單個文件時,DistributedCache.addCacheFile和DistributedCache.getLocalCacheFiles可正常工作,但傳遞存檔不起作用。我在這裏做錯了什麼?

回答

0

你可以嘗試給絕對路徑stocks.gz。

DistributedCache.addCacheArchive(new Path("<Absolute Path To>/stocks.gz").toUri(), job.getConfiguration()); 
+0

我嘗試過使用hdfs:// localhost:8020/stocks.gz,但它給出了相同的例外。 – Chitra 2013-02-13 16:22:51

+0

不是。我的意思是文件系統中的文件絕對路徑。像/home/hadoop/data/stocks.gz – shazin 2013-02-14 03:26:07

+0

不知道我明白這一點。 「/stocks.gz」是hdfs中文件的絕對路徑。 – Chitra 2013-02-14 16:36:41