FileNotFoundException但该文件存在

时间:2014-12-22 08:48:32

标签: hadoop distributed-caching distributed-cache

我在尝试读取添加到分布式缓存的文件时在Hadoop中遇到此异常,奇怪的是该文件存在于给定位置

java.io.FileNotFoundException: File does not exist: /tmp/hadoop-pera/mapred/local/taskTracker/distcache/-1517670662102870873_-1918892372_1898431787/localhost/work/output/temporalcentroids/centroids-iteration0-noOfClusters2/part-r-00000

我在使用

开始工作之前添加了文件
DistributedCache.addCacheFile(URI.create(args[2]), job.getConfiguration());

我正在尝试使用

从我的mapper中的setup metod中读取文件
DistributedCache.getLocalCacheFiles(conf);

正如我所说,我可以确认该文件是在本地系统上,但抛出了异常。

我正在一台计算机上以伪分布式模式运行该作业。

有什么想法吗?

由于

1 个答案:

答案 0 :(得分:0)

您可以发布阅读文件的方式吗?

如果您使用的是默认文件系统,并且默认配置为HDFS,则可能是错误。如果您尝试从本地文件系统读取文件,则必须使用:

FileSystem.getLocal(context.getConfiguration())