In hadoop cluster, finished mapreduce did not complete the work, need to fight jar package, and then submitted to the cluster jar. hadoop provides access to the submission jar.
2018/1/14 the Created by Frankie ON *. * The KEYIN: By default, the start offset is mr framework read a line of text, Long has its own sequence of streamlining the hadoop interface, it is not used directly long, but with LongWritable * VALUEIN: by default, the content framework mr read a line of text, String * KEYOUT: user-defined logic is processed output data key, here is the word, String * VALUEOUT: vlaue is custom logic output data after treatment is completed, the number of times a word, Integer * * ** /
/ * * The Map stage of the business logic written on the Map Custom () method * map task would be called once for each line of input data our custom map () method * * / protected void the Map (LongWritable Key, Text value, context the context) throws IOException, InterruptedException { String = value.toString Line (); String [] = line.split words ( "" ); for (String Word: words) { // the word as a key, the number 1 as the value for distribution in subsequent data can be distributed according to the word, so that the same will be used the same word Task the reduce // the Map Task collects, written on a document context.write ( new new Text (Word), new new IntWritable ( 1 )); } }
/ ** * the Created by Frankie ON 2018/1/14. * * The KEYIN, the corresponding mapper output VALUEIN KEYOUT, VALUEOUT type corresponds * KEYOUT, VALUEOUT reduce custom logic processing result output data type * KEYOUT a word, * of VALUE is the total number * / public class WordCountReducer the extends the Reducer < the Text , IntWritable , the Text , IntWritable > {
@Override protected void the reduce (the Text key, the Iterable <IntWritable> values, Context context) throws IOException, InterruptedException { / * parameters into the key, a set key is on the same word kv Context context * * / int COUNT = 0 ;
leiline@master:~/Documents/hadoop/myJars$ hadoop jar HadoopMapReduce.jar com.hadoop.mapreduce.WordCount /data/adult /data/out
Note, out document is automatically created by the process does not require the user to manually create. Finally, after the code is completed, you can see the results in the implementation of the hdfs: