【发布时间】:2018-04-19 05:55:26
【问题描述】:
我开发了一个使用分布式缓存的 Hadoop 应用程序。我使用了 Hadoop 2.9.0。在独立和伪分布式模式下一切正常。
司机:
public class MyApp extends Configured implements Tool{
public static void main(String[] args) throws Exception{
if(args.length < 2) {
System.err.println("Usage: Myapp -files cache.txt <inputpath> <outputpath>");
System.exit(-1);
}
int res = ToolRunner.run(new Configuration(), new IDS(), args);
System.exit(res);
...
映射器:
public class IDSMapper extends Mapper<LongWritable, Text, Text, LongWritable> {
@Override
protected void setup(Context context) throws IOException {
BufferedReader bfr = new BufferedReader(new FileReader(new File("cache.txt")));
开始:sudo bin/hadoop jar MyApp.jar -files cache.txt /input /output
现在我需要在真实的 Hadoop 集群上测量执行时间。不幸的是,我有 Hadoop 集群和 Hadoop 1.2.1 版本可供使用。所以我创建了新的 Eclipse 项目,引用了适当的 Hadoop 1.2.1 jar 文件,并且evertything 在独立模式下工作正常。但是,当尝试读取分布式缓存文件时,使用 Hadoop 1.2.1 的伪分布式模式失败并在 Mapper 类(设置方法)中出现 FileNotFoundException。
我是否必须在 Hadoop 1.2.1 中以其他方式处理分布式缓存文件?
【问题讨论】:
标签: java hadoop distributed-cache