Hadoop: Hadoop oozie main sub workflow.xml configuration

The job.properties file content

job.properties

user.name=admin
oozie.use.system.libpath=true
nameNode=hdfs://nameNode-value:8020
jobTracker=nameNode-value:8021
queueName=default

propertyB1=B1
propertyB2=B2
propertyB3=B3
propertyC1=C1
propertyC2=C2
propertyC3=C3
hdfs_target_path=/tmp/workspace
hdfs_main_target_path=/tmp/main_workflow_space
hdfs_target_file_path=${hdfs_target_path}/files

oozie.wf.application.path=${hdfs_main_target_path}

The main workflow.xml content

main workflow.xml

<workflow-app name="main-workflow" xmlns="uri:oozie:workflow:0.4">     <!-- This xml file is in: ${nameNode}/tmp/main_workflow_space -->
    <start to="fork-begin"/>
    <fork name="fork-begin">
        <path start="sub1" />
        <path start="sub2" />
        <path start="sub3" />
    </fork>
    <action name="sub1">
        <sub-workflow>
            <app-path>${nameNode}/tmp/sub_workflow_space</app-path>    <!-- The place where sub-workflow(sub workflow.xml) is in -->
            <propagate-configuration/>
            <configuration>
                <property>
                    <name>propertyC</name>            <!-- Can not be used in this way: property.C -->
                    <value>${propertyC1}</value>      <!-- From job.properties -->
                </property>
                <property>
                    <name>propertyB</name>            <!-- Can not be used in this way: property.B -->
                    <value>${propertyB1}</value>      <!-- From job.properties -->
                </property>
            </configuration>
        </sub-workflow>
        <ok to="join-end"/>
        <error to="kill"/>
    </action>
    <action name="sub2">
        <sub-workflow>
            <app-path>${nameNode}/tmp/sub_workflow_space</app-path>
            <propagate-configuration/>
            <configuration>
                <property>
                    <name>propertyC</name>
                    <value>${propertyC2}</value>
                </property>
                <property>
                    <name>propertyB</name>
                    <value>${propertyB2}</value>
                </property>
            </configuration>
        </sub-workflow>
        <ok to="join-end"/>
        <error to="kill"/>
    </action>
    <action name="sub3">
        <sub-workflow>
            <app-path>${nameNode}/tmp/sub_workflow_space</app-path>
            <propagate-configuration/>
            <configuration>
                <property>
                    <name>propertyC</name>
                    <value>${propertyC3}</value>
                </property>
                <property>
                    <name>propertyB</name>
                    <value>${propertyB3}</value>
                </property>
            </configuration>
        </sub-workflow>
        <ok to="join-end"/>
        <error to="kill"/>
    </action>
    <join name="join-end" to="end"/>
    <kill name="kill">
        <message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    <end name="end"/>
</workflow-app>

The sub workflow.xml content

sub workflow.xml

<workflow-app name="sub-workflow" xmlns="uri:oozie:workflow:0.4">      <!-- This file is in: ${nameNode}/tmp/sub_workflow_space -->
    <start to="step1"/>
    <action name="step1">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <prepare>
                <delete path="${nameNode}${hdfs_target_file_path}/${propertyB}"/>   <!-- ${propertyB} is from main workflow.xml property -->
            </prepare>
            <configuration>
                <property>
                    <name>property.X</name>
                    <value>${propertyX}</value>        <!-- From job.properties -->
                </property>
                <property>
                    <name>property.Y</name>
                    <value>${propertyY}</value>        <!-- From job.properties -->
                </property>
                <property>
                    <name>property.B</name>
                    <value>${propertyB}</value>         <!-- ${propertyB} is from main workflow.xml property -->
                </property>
            </configuration>
            <main-class>com.vandy.example.transToHdfs</main-class>
            <file>${hdfs_target_file_path}/id_rsa#id_rsa</file>
        </java>
        <ok to="step2"/>
        <error to="kill"/>
    </action>
    <action name="step2">
        <pig>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <prepare>
                <delete path="${nameNode}${hdfs_target_file_path}/${propertyC}"/>    <!-- ${propertyC} is from main workflow.xml property -->
            </prepare>
            <script>${hdfs_target_file_path}/Merger.pig</script>
            <param>fileA=&#39;${hdfs_target_file_path}/A&#39;</param>
            <param>fileB=&#39;${hdfs_target_file_path}/${propertyB}&#39;</param>     <!-- ${propertyB} is from main workflow.xml property -->
        </pig>
        <ok to="step3"/>
        <error to="kill"/>
    </action>
    <action name="step3">
        <java>
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <configuration>
                <property>
                    <name>property.X</name>
                    <value>${propertyX}</value>
                </property>
                <property>
                    <name>property.Y</name>
                    <value>${propertyY}</value>
                </property>
                <property>
                    <name>property.C</name>
                    <value>${propertyC}</value>               <!-- ${propertyC} is from main workflow.xml property -->
                </property>
            </configuration>
            <main-class>com.vandy.example.transToSFTP</main-class>
            <file>${hdfs_target_file_path}/id_rsa#id_rsa</file>
        </java>
        <ok to="end"/>
        <error to="kill"/>
    </action>
    <kill name="kill">
        <message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    <end name="end"/>
</workflow-app>

In a word, the real workflow sequence is : job.properties –> main workflow.xml –> sub workflow.xml.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值