Azkaban Job

Azkaban Job

1 串行定时任务工作流

zip目录结构:

|--start.job
|--finish.job

start.job

type=command
command=echo "this is start.job"

finish.job

type=command
dependencies=start
command=echo "this is finish.job"
[email protected]
[email protected]

2 并行定时任务工作流

zip目录结构:

|--start.job
|--step1.job
|--step2.job
|--step3.job

step1.job

type=command
dependencies=start
command=echo "this is step1.job"

step2.job

type=command
dependencies=start
command=echo "this is step2.job"

step3.job

type=command
dependencies=step1,step2
command=echo "this is step3.job"

3 java定时任务工作流

zip目录结构:

|--lib
|  |--AzkabanJob.jar
|--azkabanJava.job

AzkabanJob.java

package com.example;
 
public class AzkabanJob {
 
    public void run() {
        // 根据需求编写具体代码
    }
 
    public static void main(String[] args) {
        AzkabanJob azkabanJob = new AzkabanJob();
        azkabanJob.run();
    }
}

azkabanJava.job

# azkabanJob.job
type=javaprocess
java.class=com.example.AzkabanJob
classpath=lib/*

4 嵌入式定时任务工作流

也可以将工作流作为其他工作流程中的节点包含为嵌入流。要创建一个嵌入式流,只需创建一个.job文件,type=flow并将其flow.name设置为嵌入式工作流的名称。并且嵌入式的工作流是可以单独配置定时任务的,例如:

zip目录结构:

|--bin
|  |--flow1.sh
|  |--flow2.sh
|  |--flow3.sh
|
|--start.job
|--step1.job
|--step2.job
|--flow1.job
|--flow2.job
|--flow3.job
|--subflow1.job
|--subflow2.job

subflow1.job

type=flow
flow.name=flow1
dependencies=start

subflow2.job

type=flow
flow.name=flow2
dependencies=start

flow1.job

type=command
dependencies=step1
command=sh ./bin/flow1.sh

flow2.job

type=command
dependencies=step2
command=sh ./bin/flow2.sh

flow3.job

type=command
dependencies=subflow1,subflow2
command=sh ./bin/flow3.sh

注意:这里的bin目录和所有的.job位于同级目录下,./bin/flow.sh其中的.表示当前目录。

5 全局变量

后戳名为.properties的文件将会作为参数文件加载,并且在flow中每个job共享,属性文件通过目录的分层结构继承

zip目录结构

|--common.properties
|--bin
|  |--start.sh
|  |--finish.sh
|--start.job
|--finish.job
|--flow
|  |flow.properties
|  |step1

common.properties

[email protected]
[email protected]
[email protected]

start.job

type=command
command=sh ./bin/start.sh
notify.emails=${start.nofity.email}

finish.job

type=command
command=sh ./bin/finish.sh
dependencies=start
notify.emails=${finish.nofity.email}

flow.properties

[email protected]

step.job

type=command
command=echo "this is step"
notify.emails=${step.nofity.email}
success.email=${success.email}

common.properties是全局属性,将会被start.job、finish.job以及flow下的step.job使用,但是start.job和finish.job不能继承flow .properties的属性,因为他是在其下层,而step.job是可以继承flow.properties的。

注意:xxx.properties中声明的属性名不能包含空格,比如${success email}

猜你喜欢

转载自blog.csdn.net/lishuan182/article/details/82429238
job