因为之前要写一个程序就是一个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属性
恩恩,事情搞定了
指定oozie java节点的hadoop属性,布布扣,bubuko.com
原文:http://blog.csdn.net/ruishenh/article/details/20371691