包含关系
几个包含关系:
action∈workflow∈coordinatorㄈbundle
就是workflow可以包含多可action,通过coordinator来定时调度workflow,通过bundle来绑定多个coordinator
实例
workflow1.xml
<workflow-app xmlns="uri:oozie:workflow:0.4" name="shell-wf">
<start to="shell-node"/>
<action name="shell-node">
<shell xmlns="uri:oozie:shell-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<exec>echo</exec>
<argument>xx="=======111111...======="</argument>
<capture-output/>
</shell>
<ok to="second"/>
<error to="fail"/>
</action>
<action name="second">
<shell xmlns="uri:oozie:shell-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<exec>echo</exec>
<argument>xx="=======second...======="</argument>
<capture-output/>
</shell>
<ok to="third"/>
<error to="fail"/>
</action>
<action name="third">
<app-path>${workflowAppUri3}</app-path>
</action>
<kill name="fail">
<message>Shell action failed, error message</message>
</kill>
<end name="end"/>
</workflow-app>
workflow2.xml
<workflow-app xmlns="uri:oozie:workflow:0.4" name="shell-wf">
<start to="shell-node"/>
<action name="shell-node">
<shell xmlns="uri:oozie:shell-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<exec>echo</exec>
<argument>xx="=======222222...======="</argument>
<capture-output/>
</shell>
<ok to="end"/>
<error to="fail"/>
</action>
<kill name="fail">
<message>Shell action failed, error message</message>
</kill>
<end name="end"/>
</workflow-app>
coordinator1.xml
<coordinator-app name="cron-coord1" frequency="${coord:minutes(5)}" start="${start}" end="${end}" timezone="UTC"
xmlns="uri:oozie:coordinator:0.2">
<action>
<workflow>
<app-path>${workflowAppUri1}</app-path>
<configuration>
<property>
<name>jobTracker</name>
<value>${jobTracker}</value>
</property>
<property>
<name>nameNode</name>
<value>${nameNode}</value>
</property>
<property>
<name>queueName</name>
<value>${queueName}</value>
</property>
</configuration>
</workflow>
</action>
</coordinator-app>
coordinator2.xml
<coordinator-app name="cron-coord2" frequency="${coord:minutes(7)}" start="${start}" end="${end}" timezone="UTC"
xmlns="uri:oozie:coordinator:0.2">
<action>
<workflow>
<app-path>${workflowAppUri2}</app-path>
<configuration>
<property>
<name>jobTracker</name>
<value>${jobTracker}</value>
</property>
<property>
<name>nameNode</name>
<value>${nameNode}</value>
</property>
<property>
<name>queueName</name>
<value>${queueName}</value>
</property>
</configuration>
</workflow>
</action>
</coordinator-app>
bundle.xml
<bundle-app name='bundle-app' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:bundle:0.1'>
<coordinator name='cron-coord1'>
<app-path>${coordinator1}</app-path>
</coordinator>
<coordinator name='cron-coord2'>
<app-path>${coordinator2}</app-path>
</coordinator>
</bundle-app>
job.properties
nameNode=hdfs://nameservice1
jobTracker=cm:8032
queueName=default
examplesRoot=examples
oozie.libpath=${nameNode}/user/${user.name}/share/lib
# 定时任务设置
# 设置bundle路径
oozie.bundle.application.path=${nameNode}/user/${user.name}/shell/bundle.xml
start=2017-06-30T08:56Z
end=2017-06-30T09:20Z
# 定义workflow路径
workflowAppUri2=${nameNode}/user/${user.name}/shell/workflow2.xml
workflowAppUri1=${nameNode}/user/${user.name}/shell/workflow1.xml
# 定义coordinator
coordinator1=${nameNode}/user/${user.name}/shell/coordinator1.xml
coordinator2=${nameNode}/user/${user.name}/shell/coordinator2.xml