Skip to main content

MAP REDUCE LIFE CYCLE

MAP REDUCE LIFE CYCLE
  • DRIVER
  • MAPPER 
  • COMBINER (If Any)
  • PARTITIONER
  • REDUCER
  • INPUTFORMAT
  • OUTPUTFORMAT

Syntax of configuring Job using JobConf:

    // Create a new JobConf
     JobConf job = new JobConf(new Configuration(), MyJob.class);
    
     // Specify various job-specific parameters    
     job.setJobName("myjob");
  
     FileInputFormat.setInputPaths(job, new Path("in"));
     FileOutputFormat.setOutputPath(job, new Path("out"));
  
     job.setMapperClass(MyJob.MyMapper.class);
     job.setCombinerClass(MyJob.MyReducer.class);
     job.setReducerClass(MyJob.MyReducer.class);

     job.setInputFormat(SequenceFileInputFormat.class);
     job.setOutputFormat(SequenceFileOutputFormat.class);

Skeleton of the MAP REDUCE job:

public class SamplePgm {
 
    public static void main(String[] args) throws Exception {
 
        // Create configuration
        Configuration conf = new Configuration();
 
        // Create job
        Job job = new Job(conf, "Sample Pgm");
        job.setJarByClass(SamplePgm.class);
 
        // Setup MapReduce job
        job.setMapperClass(Mapper.class);
        job.setReducerClass(Reducer.class);
 
        // Set only 1 reduce task
        job.setNumReduceTasks(1);
 
        // Specify key / value
        job.setOutputKeyClass(LongWritable.class);
        job.setOutputValueClass(Text.class);
 
        // Input
        FileInputFormat.addInputPath(job, new Path(args[0]));
        job.setInputFormatClass(TextInputFormat.class);
 
        // Output
        FileOutputFormat.setOutputPath(job, new Path(args[1]));
        job.setOutputFormatClass(TextOutputFormat.class);
 
        // Execute job
        int code = job.waitForCompletion(true) ? 0 : 1;
        System.exit(code);
    }
}


Comments

Popular posts from this blog

Deprecated API Versus New API

Seq No Deprecated API NEW API 1 Release 0.20 Release 1.X and 2.X 2 Interfaces (means you can add a method with default implementation to an abstract class without breaking old implementations of class Abstract classes For Example Mapper and Reducer interfaces in Old API are abstract classes in new API 3 Package org.apache.hadoop.mapred org.apache.hadoop.mapreduce 4 JobConf,the OutputCollector and the Reporter Context Object   (allows the user code to communicate with MapReduce System) 5 Both API’s, Key-Value record pairs are pushed to mapper and reducer In addition execution flow can be controlled by run() method 6 Job Control by JobClient class Job class 7 Output file are named as Part-nnnnn Part-m-nnnnn( mapper) , part-r-nnnnn(reducer) 8 ...

Apache Hadoop

The project includes these modules: Hadoop Common : The common utilities that support the other Hadoop modules. Hadoop Distributed File System (HDFS™) : A distributed file system that provides high-throughput access to application data. Hadoop YARN : A framework for job scheduling and cluster resource management. Hadoop MapReduce : A YARN-based system for parallel processing of large data sets. Other Hadoop-related projects at Apache include: Ambari™ : A web-based tool for provisioning, managing, and monitoring Apache Hadoop clusters which includes support for Hadoop HDFS, Hadoop MapReduce, Hive, HCatalog, HBase, ZooKeeper, Oozie, Pig and Sqoop. Ambari also provides a dashboard for viewing cluster health such as heatmaps and ability to view MapReduce, Pig and Hive applications visually alongwith features to diagnose their performance characteristics in a user-friendly manner. Avro™...