Created
May 28, 2014 15:10
-
-
Save fivesmallq/70076419684244ee785f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.novacloud.data.job.demo; | |
import java.io.IOException; | |
import java.util.Iterator; | |
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.mapred.FileInputFormat; | |
import org.apache.hadoop.mapred.FileOutputFormat; | |
import org.apache.hadoop.mapred.JobClient; | |
import org.apache.hadoop.mapred.JobConf; | |
import org.apache.hadoop.mapred.MapReduceBase; | |
import org.apache.hadoop.mapred.Mapper; | |
import org.apache.hadoop.mapred.OutputCollector; | |
import org.apache.hadoop.mapred.Reducer; | |
import org.apache.hadoop.mapred.Reporter; | |
public class MyFirstJob { | |
public static void main(String[] args) throws Exception { | |
Configuration config = new Configuration(); | |
config.set("fs.defaultFS", "hdfs://192.168.1.15:8020"); | |
config.set("mapred.job.tracker", "192.168.1.15:8021"); | |
JobConf job = new JobConf(config); | |
job.setJarByClass(MyFirstJob.class); | |
job.setJobName("My first job"); | |
FileInputFormat.setInputPaths(job, new Path("/input/path")); | |
FileOutputFormat.setOutputPath(job, new Path("/out/path")); | |
job.setMapperClass(MyFirstJob.MyFirstMapper.class); | |
job.setReducerClass(MyFirstJob.MyFirstReducer.class); | |
JobClient.runJob(job); | |
} | |
private static class MyFirstMapper extends MapReduceBase implements Mapper { | |
public void map(LongWritable key, Text value, OutputCollector output, | |
Reporter reporter) throws IOException { | |
} | |
@Override | |
public void map(Object arg0, Object arg1, OutputCollector arg2, | |
Reporter arg3) throws IOException { | |
// TODO Auto-generated method stub | |
} | |
} | |
private static class MyFirstReducer extends MapReduceBase implements | |
Reducer { | |
public void reduce(Text key, Iterator values, OutputCollector output, | |
Reporter reporter) throws IOException { | |
} | |
@Override | |
public void reduce(Object arg0, Iterator arg1, OutputCollector arg2, | |
Reporter arg3) throws IOException { | |
// TODO Auto-generated method stub | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment