指定oozie java节点的hadoop属性

 

因为之前要写一个程序就是一个java节点可以搞定的事情,但是无奈需要配置一下hadoop的属性值,mapreduce.task.classpath.user.precedence,结果没查了半天没想到怎么配置,没办法,当时只能写了一个mapreduce跑一个java程序。后来

想了一下还是喽一眼源码吧,结果还真查到了,在启动javaAction的时候可以配置hadoop的属性

 

一路追踪,

从开始servlet到一直调用后端的

org.apache.oozie.action.hadoop.JavaActionExecutor.submitLauncher(Context context, WorkflowAction action);

 

在这个函数中的关键代码

最后调用

 

runningJob =jobClient.submitJob(launcherJobConf);

在这个提交job的时候参数JobConf就是launcherJobConf

而launcherJobConf的生成是

JobConf launcherJobConf =createLauncherConf(context, action, actionXml, actionConf);

当这个在创建的时候会使用到workflow.xml的节点信息actionXMl

 

在createLauncherConf函数中会有个

 setupLauncherConf(launcherConf, actionXml, appPathRoot, context);

上边这个函数中写着如何加入启动hadoop的一些参数

 

 

 

Configuration setupLauncherConf(Configuration conf, Element actionXml,Path appPath, Context context) throws ActionExecutorException {
       try {
           Namespace ns = actionXml.getNamespace();
           Element e = actionXml.getChild("configuration", ns);
           if (e != null) {
                String strConf =XmlUtils.prettyPrint(e).toString();
                XConfiguration inlineConf = newXConfiguration(new StringReader(strConf));
 
                XConfiguration launcherConf =new XConfiguration();
                for (Map.Entry<String,String> entry : inlineConf) {
                    if(entry.getKey().startsWith("oozie.launcher.")) {
                        String name =entry.getKey().substring("oozie.launcher.".length());
                        String value =entry.getValue();
                        // setting original KEY
                       launcherConf.set(entry.getKey(), value);
                        // setting un-prefixedkey (to allow Hadoop job config
                        // for the launcher job
                        launcherConf.set(name,value);
                    }
                }
                checkForDisallowedProps(launcherConf,"inline launcher configuration");
               XConfiguration.copy(launcherConf, conf);
           }
           return conf;
       }
       catch (IOException ex) {
           throw convertException(ex);
       }
    }

 

 

 

上边函数已经写着很明白了,当以oozie.launcher.开头的

Configuration节点中的属性,都会被加入到    Configuration中

 

 

 

这个时候只要在自己写的oozie节点中加入如下参数就ok了

 


<actionname="java_checkApp">
                <java>
                       <job-tracker>${jobTracker}</job-tracker>
                       <name-node>${nameNode}</name-node>
                        <configuration>
                                <property>
                                       <name>mapred.job.queue.name</name>
                                       <value>${queueName}</value>
                               </property>
                                <property>
                                        <name>oozie.launcher.mapreduce.task.classpath.user.precedence</name>
                                       <value>true</value>
                               </property>
                        </configuration>
                       <main-class>com.jd.ebsdi.hadoop.mapreduce.ooziemain.main.DoCheck
                        </main-class>
                       <arg>{"dbSetPointerType":"pointerTime","wfName":"${wf:name()}","coorTime":"${wf:conf("nominalTime")}","wfPath":"${wf_app_path}","failClockThresholdValue":"${failThreshold}","checkLockFrequence":"${checkLockSequence}","waitingThresholdValue":"${waitingThreshold}"}
                        </arg>
                        <capture-output/>
                </java>
                <okto="java_InitialData" />
                <error to="kill"/>
       </action>

 

 

在hadoop的job配置文件中

hdfs://hadoop-master.xxx.com:8020/home/data/hadoop/cache/mapred/staging/houchangren/.staging/job_201401261826_18982/job.xml

可以看到

如下的属性

这个是oozie的属性




下边中是解析后的hadoop属性


 

恩恩,事情搞定了

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值