代码如下:
mapreduce部分就是Wordcount
运行结果是报错:file:///namenode:9000/out/part-r-00000 not exist
而我明明有 job.waitForCompletion(true); 等前面的完成,不太理解
路径的写法也尝试了很多种,这里应该没有问题的
public static void main(String args[])throws Exception{
Configuration conf = new Configuration();
Job job = new Job(conf);
job.setJarByClass(WordCount.class);
job.setJobName("wordcount");
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
job.setMapperClass(WordCountMap.class);
job.setReducerClass(WordCountReduce.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.waitForCompletion(true);
//download from hdfs
Configuration conf1=new Configuration();
FileSystem fs=FileSystem.get(conf1);
Path local_path=new Path("usr/result");
Path fs_path=new Path("file:///namenode:9000/out/part-r-00000");
fs.copyToLocalFile(true, fs_path, local_path);
}求大神解答
|
|