编写一个Driver 来执行Map-Reduce过程
- public class MyDriver {
- public static void main(String [] args) throws Exception{
- Configuration conf = new Configuration();
- conf.set("Hadoop.job.ugi", "root,root123");
- Job job = new Job(conf,"Hello,hadoop! ^_^");
- job.setJarByClass(MyDriver.class);
- job.setMapOutputKeyClass(Text.class);
- job.setMapOutputValueClass(IntWritable.class);
- job.setMapperClass(MyMap.class);
- job.setCombinerClass(MyReduce.class);
- job.setReducerClass(MyReduce.class);
- job.setInputFormatClass(TextInputFormat.class);
- job.setOutputFormatClass(TextOutputFormat.class);
- FileInputFormat.setInputPaths(job, new Path(args[0]));
- FileOutputFormat.setOutputPath(job,new Path(args[1]));
- job.waitForCompletion(true);
- }
- }
