
164
|
第
6
章
6.3.1
剖析
MapReduce
任务
基本的
MapReduce
任务只有少数必要的功能。重写
run()
方法的实质就是在该方法中包含
Job
类的单例。
public class BasicMapReduceExample extends
Configured
implements
Tool {
public static void
main(String[] args)
throws
Exception {
int
exitCode = ToolRunner.run(
new
BasicMapReduceExample(), args);
System.exit(exitCode);
}
@Override
public int
run(String[] args)
throws
Exception {
Job job = Job.getInstance(getConf());
job.setJarByClass(BasicMapReduceExample.class);
job.setJobName("BasicMapReduceExample");
FileInputFormat.addInputPath(job,
new
Path(args[0]));
FileOutputFormat.setOutputPath(job,
new
Path(args[1]));
return
job.waitForCompletion(
true ...