Genericoptionsparser command lineParser
It is a basic class for parsing command line parameters in the hadoop framework. It can identify some standard command line parameters, so that the application can easily specify namenode, jobtracker, and other additional configuration resources.
There is a log written very well, I will not go into details: http://www.cnblogs.com/caoyuanzhanlang/archive/2013/02/21/2920934.html
Example:
The simplest use of wordcount is as follows:
1 Configuration conf = new Configuration(); 2 String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs(); 3 if (otherArgs.length != 2) { 4 System.err.println("Usage: wordcount <in> <out>"); 5 System.exit(2); 6 } 7 Job job = new Job(conf, "word count"); 8 job.setJarByClass(WordCount.class); 9 job.setMapperClass(TokenizerMapper.class);10 job.setCombinerClass(IntSumReducer.class);11 job.setReducerClass(IntSumReducer.class);12 job.setOutputKeyClass(Text.class);13 job.setOutputValueClass(IntWritable.class);14 FileInputFormat.addInputPath(job, new Path(otherArgs[0]));15 FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));16 System.exit(job.waitForCompletion(true) ? 0 : 1);
For example, run the command bin/hadoop DFS-FS master: 8020-ls/Data
Genericoptionsparser configure-FS master: 8020 to configure Conf
The getremainingargs () method returns the remaining parameter-ls/data. Input and Output Parameters
Trivial-genericoptionsparser class for hadoop