歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> 指定Oozie Java節點的Hadoop屬性

指定Oozie Java節點的Hadoop屬性

日期:2017/3/1 9:42:39   编辑:Linux編程

因為之前要寫一個程序就是一個java節點可以搞定的事情,但是無奈需要配置一下Hadoop的屬性值,mapreduce.task.classpath.user.precedence,結果沒查了半天沒想到怎麼配置,沒辦法,當時只能寫了一個mapreduce跑一個java程序。後來想了一下還是喽一眼源碼吧,結果還真查到了,在啟動javaAction的時候可以配置hadoop的屬性

一路追蹤,

從開始servlet到一直調用後端的

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

在這個函數中的關鍵代碼

--------------------------------------分割線 --------------------------------------

推薦閱讀

Hadoop平台上Oozie調度系統的安裝配置 http://www.linuxidc.com/Linux/2014-04/100382.htm

Ubuntu 13.04上搭建Hadoop環境 http://www.linuxidc.com/Linux/2013-06/86106.htm

Ubuntu 12.10 +Hadoop 1.2.1版本集群配置 http://www.linuxidc.com/Linux/2013-09/90600.htm

Ubuntu上搭建Hadoop環境(單機模式+偽分布模式) http://www.linuxidc.com/Linux/2013-01/77681.htm

Ubuntu下Hadoop環境的配置 http://www.linuxidc.com/Linux/2012-11/74539.htm

單機版搭建Hadoop環境圖文教程詳解 http://www.linuxidc.com/Linux/2012-02/53927.htm

搭建Hadoop環境(在Winodws環境下用虛擬機虛擬兩個Ubuntu系統進行搭建) http://www.linuxidc.com/Linux/2011-12/48894.htm

--------------------------------------分割線 --------------------------------------

最後調用

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屬性

恩恩,事情搞定了

更多Hadoop相關信息見Hadoop 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=13

Copyright © Linux教程網 All Rights Reserved