Oozie coordinator 作业自定义的配置的一些方法

简介:

Oozie的coordinator有啥用?

The Oozie Coordinator system allows the user to define and execute recurrent and interdependent workflow jobs (data application pipelines).

说白了就是可以把各个 workflow作业组织起来。比如,A作业执行完成之后,会有输出,该输出触发B作业的执行。那么 A B 这两个workflow作业就可以通过一个coordinator作业组织起来。

什么是coordinator作业?

Coordinator Job: A coordinator job is an executable instance of a coordination definition. A job submission is done by submitting a job configuration that resolves all parameters in the application definition.

这说明coordinator作业也是需要配置相应的参数的。与提交workflow作业时配置 workflow.xml类似,coordinator作业也有一个名为coordinator.xml的配置文件。

什么是coordinator action?

 

Coordinator Action: A coordinator action is a workflow job that is started when a set of conditions are met (input dataset instances are available).

coordinator action本质上是一个workflow 作业!

Coordinator Application: A coordinator application defines the conditions under which coordinator actions should be created (the frequency) and when the actions can be started. The coordinator application also defines a start and an end time. Normally, coordinator applications are parameterized. A Coordinator application is written in XML.

coordinator application 负责管理各个coordinator action。有start time 和 end time,负责其中定义的action的起动与终止。

前面一直在纠结这个问题:oozie coordinator 作业如何配置???
现在记录如下:
Oozie提供的一个官方的关于定时作业配置文件,内容如下:

复制代码
<coordinator-app name="cron-coord" frequency="${coord:minutes(10)}" start="${start}" end="${end}" timezone="UTC"
                 xmlns="uri:oozie:coordinator:0.2">
        <action>
        <workflow>
            <app-path>${workflowAppUri}</app-path>
            <configuration>
                <property>
                    <name>jobTracker</name>
                    <value>${jobTracker}</value>
                </property>
                <property>
                    <name>nameNode</name>
                    <value>${nameNode}</value>
                </property>
            </configuration>
        </workflow>
    </action>
</coordinator-app>
复制代码


从上面可以看出, frequency已经写死了,指定为每十分钟执行一次。其中启动时间和结束时间以变量的形式给出,如start="start"end="start"end="{end}"
这两个变量可以通过job.properties 文件或者在命令行提交时指定参数即可。此外,还可以通过HTTP POST请求的形式,带着相关的参数进行作业提交(Oozie 提供了WebService API。)

其实,frequency和 start、end 一样,也可以用变量来代替,这样就可以实现我前面帖子里面的问题了---定时提交作业,且只运行一次。
但是,需要注意的是 frequency的格式问题:它只能是 cron expression。否则就会报以下的错误:
Invalid coordinator application attributes, parameter [frequency] = [10 * ? ? ?]  must be an integer or a cron syntax. Parsing error For input string: "10 * ? ? ?"
关于 cron expression可以参考Quartz,因为Oozie的定时功能是基于它实现的。
此外,我还碰到了一个这样的问题:
Coordinator job with frequency '10 * * * *' materializes no actions between start and end time.
从Oozie的源代码可以看出,抛出该异常的程序代码如下:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if (nextTime == null) {
        throw new IllegalArgumentException("Invalid coordinator cron frequency: " + coordJob.getFrequency());
     }
        if (!nextTime.before(coordJob.getEndTime())) {
            throw new IllegalArgumentException("Coordinator job with frequency '" +
                coordJob.getFrequency() + "' materializes no actions between start and end time.");
 }
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
这是因为我的start time 和 end time设置的不合理,下一次作业的运行时间在结束时间之前了,就会出现下面的错误。
Coordinator job with frequency '10 * * * *' materializes no actions between start and end time. 

 

文章开头说了Coordinator作业可以把其他作业组织起来。因此,提交一个Coordinator作业时,会生成一个 父作业ID 和 若干子作业的ID,子作业就是Coordinator作业的配置文件中的 <workflow>标签中指定的子作业。比如:

生成的一个父作业ID:0000033-160516121313115-oozie-oozi-C

相应的子作业ID:0000033-160516121313115-oozie-oozi-C@1

由于该子作业是一个workflow作业,workflow作业的ID:0000034-160516121313115-oozie-oozi-W



另外,相关的具体规则可参考Oozie官网文档

本文转自hapjin博客园博客,原文链接:http://www.cnblogs.com/hapjin/p/5329823.html,如需转载请自行联系原作者


相关文章
|
24天前
|
存储 监控 调度
【Flink】怎么提交的实时任务,有多少Job Manager?
【4月更文挑战第18天】【Flink】怎么提交的实时任务,有多少Job Manager?
|
3月前
|
SQL Prometheus Cloud Native
Flink启动问题之job启动失败如何解决
Apache Flink是由Apache软件基金会开发的开源流处理框架,其核心是用Java和Scala编写的分布式流数据流引擎。本合集提供有关Apache Flink相关技术、使用技巧和最佳实践的资源。
|
5月前
|
网络协议 Java 流计算
当你在Flink客户端提交一个作业到JobManager时
当你在Flink客户端提交一个作业到JobManager时
18 2
|
7月前
|
SQL 资源调度 安全
开启 Kerberos 安全的大数据环境中,Yarn Container 启动失败导致作业失败
开启 Kerberos 安全的大数据环境中,Yarn Container 启动失败导致作业失败
|
流计算
flink 单作业模式部署提交作业爆:Trying to access closed classloader. Please check if you store classloaders direc
flink 单作业模式部署提交作业爆:Trying to access closed classloader. Please check if you store classloaders direc
flink 单作业模式部署提交作业爆:Trying to access closed classloader. Please check if you store classloaders direc
|
12月前
|
SQL 分布式计算 Hadoop
|
XML Shell 调度
Apache Oozie-- 实战操作--集成 hue- 定时调度配置|学习笔记
快速学习 Apache Oozie-- 实战操作--集成 hue- 定时调度配置
420 0
Apache Oozie-- 实战操作--集成  hue- 定时调度配置|学习笔记
|
资源调度 流计算
Flink 1.12 yarn-cluster模式触发Savepoint with Yarn指定-yid报异常failed timeout问题及解决
官方给出触发Savepoint with YARN的命令指定了-yid,测试后发现不应指定-yid。分析应该是早期版本需指定-yid,后期版本(至少Flink 1.12)不需要指定-yid,而官网文档未及时更新这个细节问题。
756 0
Flink 1.12 yarn-cluster模式触发Savepoint with Yarn指定-yid报异常failed timeout问题及解决
|
机器学习/深度学习 分布式计算 网络协议
Spark练习 - 提交作业到集群 - submit job via cluster
Spark练习 - 提交作业到集群 - submit job via cluster
102 0
Spark练习 - 提交作业到集群 - submit job via cluster