我想要一个小的文件传递给我使用GenericOptionsParser
的-files
标志运行的作业:如何在Hadoop Map/Reduce作业中访问DistributedCache?
$ hadoop jar MyJob.jar -conf /path/to/cluster-conf.xml -files /path/to/local-file.csv data/input data/output
据说这是为了将作业发送到我的集群和连接本地文件。 csv在需要时可供Mapper/Reducer使用。当我以伪分布模式运行它时,它工作得很好,但是当我在集群上启动作业时,似乎无法找到该文件。我在读我的映射器的方法setup
文件像这样:
public static class TheMapper extends Mapper<LongWritable, Text, Text, Text> {
@Override
public void setup(Context context) throws IOException, InterruptedException {
URI[] uriList = DistributedCache.getCacheFiles(context.getConfiguration());
CsvReader csv = new CsvReader(uriList[0].getPath());
// work with csv file..
}
// ..
}
当作业运行时,我得到以下异常:
java.io.FileNotFoundException: File /hdfs/tmp/mapred/staging/hduser/.staging/job_201205112311_011/files/local-file.csv does not exist.
at com.csvreader.CsvReader.<init>(Unknown Source)
at com.csvreader.CsvReader.<init>(Unknown Source)
at com.csvreader.CsvReader.<init>(Unknown Source)
at MyJob$TheMapper.setup(MyJob.java:167)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:142)
...
任何想法,我做错了吗?谢谢。
伟大的工作 - 谢谢! – sa125