Hadoop MapReduce任务设置yarn的队列

网上很多回答,都是:
yarn jar app.jar com.xxx.mainClass -D mapreduce.job.queuename=default args1 args2

但是这样设置并不能生效!!!!!是有问题的!!!!!

网上的所有设置都是基于hadoop官方的example。
example中有这样一段代码。
会将-D的配置进行处理,加入到Configuration中

以wordcount为例

  public static void main(String[] args) throws Exception {
    Configuration conf = new Configuration();
    //!!!这里会处理一些系统参数。之后会留下其他用户真正想传入的其他参数otherArgs
    String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
    if (otherArgs.length < 2) {
      System.err.println("Usage: wordcount <in> [<in>...] <out>");
      System.exit(2);
    }
   /**GenericOptionsParser 中处理-D */
    if (line.hasOption('D')) {
      String[] property = line.getOptionValues('D');
      for(String prop : property) {
        String[] keyval = prop.split("=", 2);
        if (keyval.length == 2) {
          conf.set(keyval[0], keyval[1], "from command line");
        }
      }
    }

因此用户编程时建议加上这段配置。

 String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();

便于传入外部系统参数。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值