Hadoop 1.x MapReduce Default driver configuration __hadoop

Source: Internet
Author: User

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);
 }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.