DistributedCache无法访问存档

问题描述:

我能够使用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可正常工作,但传递存档不起作用。我在这里做错了什么?

你可以尝试给绝对路径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

此链接可能帮助:

http://mail-archives.apache.org/mod_mbox/hadoop-common-user/201105.mbox/%[email protected]%3E

(我没有尝试这样做我自己)。