【发布时间】:2012-08-28 00:16:39
【问题描述】:
我正在尝试在分布式缓存中放置一个文件。为了做到这一点,我使用 -files 选项调用我的驱动程序类,例如:
hadoop jar job.jar my.driver.class -files MYFILE input output
getCacheFiles() 和 getLocalCacheFiles() 返回包含 MYFILE 的 URI/路径数组。
(例如:hdfs://localhost/tmp/hadoopuser/mapred/staging/knappy/.staging/job_201208262359_0005/files/histfile#histfile)
不幸的是,当尝试在 map 任务中检索 MYFILE 时,它会抛出 FileNotFoundException。
我在独立(本地)模式和伪分布式模式下都试过了。
你知道可能是什么原因吗?
更新:
以下三行:
System.out.println("cache files:"+ctx.getConfiguration().get("mapred.cache.files"));
uris = DistributedCache.getLocalCacheFiles(ctx.getConfiguration());
for(Path uri: uris){
System.out.println(uri.toString());
System.out.println(uri.getName());
if(uri.getName().contains(Constants.PATH_TO_HISTFILE)){
histfileName = uri.getName();
}
}
打印出来:
cache files:file:/home/knappy/histfile#histfile
/tmp/hadoop-knappy/mapred/local/archive/-7231_-1351_105/file/home/knappy/histfile
histfile
因此,该文件似乎列在 job.xml mapred.cache.files 属性中,并且似乎存在本地文件。尽管如此,还是会抛出 FileNotFoundException。
【问题讨论】:
标签: hadoop filenotfoundexception distributed-caching distributed-cache