GenericOptionsParser 命令行解析器
是hadoop框架中解析命令行參數的基本類。它能夠辨別一些標準的命令行參數,能夠使應用程序輕易地指定namenode,jobtracker,以及其他額外的配置資源
有篇日志寫的很好,自己就不贅述了:http://www.49028c.com/caoyuanzhanlang/archive/2013/02/21/2920934.html
例子:
最簡單的在WordCount中用到了:
1 Configuration conf = new Configuration(); 2 String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs(); 3 if (otherArgs.length != 2) { 4 System.err.比如運行命令為:bin/hadoop dfs -fs master:8020 -ls /data
GenericOptionsParser把 -fs master:8020配置到配置conf中
而getRemainingArgs()方法則得到剩余的參數,就是 -ls /data。供下面使用輸入輸出參數
新聞熱點
疑難解答