Query source, you can draw Hadoop 1.x mapreduce default driver configuration:
Package org.dragon.hadoop.mr;
Import org.apache.hadoop.conf.Configuration;
Import Org.apache.hadoop.fs.Path;
Import org.apache.hadoop.io.LongWritable;
Import Org.apache.hadoop.io.Text;
Import Org.apache.hadoop.mapreduce.Job;
Import Org.apache.hadoop.mapreduce.Mapper;
Import Org.apache.hadoop.mapreduce.Reducer;
Import Org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
Import Org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
Import Org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
Import Org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
Import Org.apache.hadoop.mapreduce.lib.partition.HashPartitioner; /** * MapReduce Default driver configuration * @author Administrator * * */public class Defaultmapreduce {public static void main (string[ ] args throws Exception {args = new string[]{"Hdfs://hadoop-master.dragon.org:9000/opt/data/test/input/simple_
File.txt "," hdfs://hadoop-master.dragon.org:9000/opt/data/test/output7/"}; 1, conf Configuration conf = new COnfiguration ();
2. Create job Job Job = new Job (Conf,defaultmapreduce.class.getsimplename ());
3, set run Jar Job.setjarbyclass (Defaultmapreduce.class);
4, set InputFormat Job.setinputformatclass (Textinputformat.class);
5, set input path Fileinputformat.addinputpath (Job, New Path (args[0));
6, set mapper Job.setmapperclass (Mapper.class);
7, set map Output Key/value class Job.setmapoutputkeyclass (Longwritable.class);
Job.setmapoutputvalueclass (Text.class);
8, set partion Job.setpartitionerclass (Hashpartitioner.class);
9, set reduce number job.setnumreducetasks (1);
10, set Sort Comparator class Job.setsortcomparatorclass (LongWritable.Comparator.class);
11, set Group Comparator class Job.setgroupingcomparatorclass (LongWritable.Comparator.class);
12, Set combiner class Job.setcombinerclass (null);
13, Set Reducer class Job.setreducerclass (Reducer.class); 14, Set output class JOB.SETOUTPUTformatclass (Textoutputformat.class);
15, set job Output Key/value class Job.setoutputkeyclass (Longwritable.class);
Job.setoutputvalueclass (Text.class);
16, set job output path Fileoutputformat.setoutputpath (Job, New Path (args[1));
17. Submit Job Boolean issuccess = Job.waitforcompletion (true);
18, Exit System.exit (Issuccess?0:1);
}
}