由于集群为hadoop配置了执行队列,所以如果我们程序写成下面这样的话:
我们在运行mapreduce的时候命令上要加
-D mapreduce.job.queuename参数
hadoop jar WordCount.jar WordCount.WordCount -Dmapreduce.job.queuename=root.default xrli/input xrli/output
如果实在想把这些参数都写到代码里面的话,就照着下面写:
这样运行的时候只要执行以下命令就行了。
hadoop jar WordCount.jar WordCount.WordCount
这里分析以下Hadoop的GenericOptionsParser类
它能够解析命令行参数的基本类。它能够辨别一些标准的命令行参数。
比如这里的-D
mapreduce.job.queuename
就被它识别了,并且配置到了参数文件中去,而函数
getRemainingArgs()就是获取了剩余的两个参数
"xrli/STJoin_in","xrli/STJoin_out",并且将它们组合为数组
otherArgs。
它能够识别的参数包括: fs jt libjars files archives D tokenCacheFile
http://www.cnblogs.com/caoyuanzhanlang/archive/2013/02/21/2920934.htmlhttp://www.cnblogs.com/caoyuanzhanlang/archive/2013/02/21/2920934.html