Pari
Pari

Reputation: 1493

Oozie <job-xml> not working in global section with subworkflow action

I am trying to shorten my oozie workflow and I am referring this cloudera post. http://blog.cloudera.com/blog/2013/11/how-to-shorten-your-oozie-workflow-definitions/

Per this post, we can add job.xml file in global section, but its not working for me.

   <global>
   <job-tracker>${jobTracker}</job-tracker>
   <name-node>${nameNode}</name-node>
   <job-xml>job1.xml</job-xml>
   <configuration>
        <property>
            <name>mapred.job.queue.name</name>
            <value>${queueName}</value>
        </property>
    </configuration>
</global>

-----------------------Main Workflow------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<workflow-app xmlns="uri:oozie:workflow:0.4" name="main-wf">
   <global>
    <job-xml>/user/${wf:user()}/${examplesRoot}/apps/map-reduce/job.xml</job-xml>
   </global>
    <start to="main-node"/>
    <action name="main-node">
      <sub-workflow>
         <app-path>/user/${wf:user()}/${examplesRoot}/apps/map-reduce/workflow.xml</app-path>
      </sub-workflow>
      <ok to="end" />
      <error to="fail" />
   </action>
    <kill name="fail">
        <message>MR failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    <end name="end"/>
</workflow-app>

-----------------------Sub Workflow------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<workflow-app xmlns="uri:oozie:workflow:0.4" name="OozieBDU-wf">
    <start to="wordcount-node"/>
    <action name="wordcount-node">
        <map-reduce>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
        <prepare>
         <delete path="${nameNode}/user/${wf:user()}/${examplesRoot}/output-data/${outputDir}"/>
        </prepare>
            <configuration>
                <property>
                    <name>mapred.job.queue.name</name>
                    <value>${queueName}</value>
                </property>
        <property>
               <name>mapred.mapper.new-api</name>
               <value>true</value>
        </property>
        <property>
               <name>mapred.reducer.new-api</name>
               <value>true</value>
             </property>
        <property>
               <name>mapreduce.map.class</name>
               <value>com.yumecorp.WordCount$TokenizerMapper</value>
        </property>
        <property>
               <name>mapreduce.reduce.class</name>
               <value>com.yumecorp.WordCount$IntSumReducer</value>
        </property>
             <property>
               <name>mapred.output.key.class</name>
               <value>org.apache.hadoop.io.Text</value>
             </property>
             <property>
               <name>mapred.output.value.class</name>
               <value>org.apache.hadoop.io.IntWritable</value>
             </property>
             <property>
               <name>mapred.input.dir</name>
               <value>/user/${wf:user()}/${examplesRoot}/input-data/decodeAndProfile</value>
             </property>
             <property>
               <name>mapred.output.dir</name>
               <value>/user/${wf:user()}/${examplesRoot}/output-data/${outputDir}</value>
             </property>
             <property>
               <name>mapreduce.job.outputformat.class</name>
               <value>org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat</value>
             </property>
             <property>
               <name>mapred.mapoutput.key.class</name>
               <value>org.apache.hadoop.io.Text</value>
             </property>
             <property>
               <name>mapred.mapoutput.value.class</name>
               <value>org.apache.hadoop.io.IntWritable</value>
             </property>
            </configuration>
        </map-reduce>
        <ok to="end"/>
        <error to="fail"/>
    </action>
    <kill name="fail">
        <message>MR failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    <end name="end"/>
</workflow-app>

-----------------------job.xml------------------------------

<configuration>
            <property>
               <name>jobTracker</name>
               <value>pari.hhh.com:8021</value>
            </property>
            <property>
               <name>nameNode</name>
               <value>hdfs://pari.hhh.com:8020</value>
            </property>
            <property>
               <name>queueName</name>
               <value>default</value>
            </property>
            <property>
               <name>examplesRoot</name>
               <value>wordcount</value>
            </property>
            <property>
               <name>outputDir</name>
               <value>map-reduce</value>
            </property>    
</configuration>

-----------------------job.properties------------------------------ examplesRoot=wordcount oozie.wf.application.path=${nameNode}/user/${user.name}/${examplesRoot}/apps/map-reduce/mainworkflow.xml

-----------------------oozie command ----------------------------- oozie job -config job.properties -run

-----------------------ERROR ------------------------------------- OB[0000012-150131091133585-oozie-oozi-W] ACTION[0000012-150131091133585-oozie-oozi-W@wordcount-node] ELException in ActionStartXCommand javax.servlet.jsp.el.ELException: variable [jobTracker] cannot be resolved at org.apache.oozie.util.ELEvaluator$Context.resolveVariable(ELEvaluator.java:106) at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124) at org.apache.commons.el.ExpressionString.evaluate(ExpressionString.java:114) at org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:274) at org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:190) at org.apache.oozie.util.ELEvaluator.evaluate(ELEvaluator.java:203) at org.apache.oozie.command.wf.ActionStartXCommand.execute(ActionStartXCommand.java:188) at org.apache.oozie.command.wf.ActionStartXCommand.execute(ActionStartXCommand.java:63) at org.apache.oozie.command.XCommand.call(XCommand.java:281) at org.apache.oozie.service.CallableQueueService$CompositeCallable.call(CallableQueueService.java:323) at org.apache.oozie.service.CallableQueueService$CompositeCallable.call(CallableQueueService.java:252) at org.apache.oozie.service.CallableQueueService$CallableWrapper.run(CallableQueueService.java:174) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)

Anybody can help??

Cheers Pari

Upvotes: 2

Views: 5016

Answers (1)

Jeremy Beard
Jeremy Beard

Reputation: 2725

To pass properties from a workflow to its sub-workflow you need to add the <propagate-configuration/> tag to the <sub-workflow> action.

For example:

<action name="main-node">
  <sub-workflow>
     <app-path>/user/${wf:user()}/${examplesRoot}/apps/map-reduce/workflow.xml</app-path>
     <propagate-configuration/>
  </sub-workflow>
  <ok to="end" />
  <error to="fail" />
</action>

Upvotes: 3

Related Questions