azkaban mysql参数_azkaban job参数传递

Parameter Passing

There is often a desire to pass these parameters to the executing job code. The method of passing these parameters is dependent on the jobtype that is run, but usually Azkaban writes these parameters to a temporary file that is readable by the job.

The path of the file is set in JOB_PROP_FILE environment variable. The format is the same key value pair property files. Certain built-in job types do this automatically for you. The java type, for instance, will invoke your Runnable and given a proper constructor, Azkaban can pass parameters to your code automatically.

Parameter Output

Properties can be exported to be passed to its dependencies. A second environment variable JOB_OUTPUT_PROP_FILE is set by Azkaban. If a job writes a file to that path, Azkaban will read this file and then pass the output to the next jobs in the flow.

The output file should be in json format. Certain built-in job types can handle this automatically, such as the java type.

以上是官方的使用描述,相对来说比较简单,给初用者带来一定的难度。下面举个例子说明。

JOB_OUTPUT_PROP_FILE和JOB_PROP_FILE都是一个环境变量,指向文件路径。上游节点把需要输出的值以json的格式写入JOB_OUTPUT_PROP_FILE文件,下游节点就可以在JOB_PROP_FILE中看到key-value形式的输出,用${key}的方式使用变量。

实际例子:

baseflow.flow

nodes:

- name: jobB

type: command

dependsOn:

- jobA

config:

command: sh commandB.sh "${firstName}"

- name: jobA

type: command

config:

command: sh commandA.sh

commandA.sh

#!/bin/bash

echo '{ "firstName":"John" , "lastName":"Doe" }' >> ${JOB_OUTPUT_PROP_FILE}

commandB.sh

#!/bin/bash

#cat ${JOB_PROP_FILE} >> /root/azkaban.txt

echo $1 >> /root/azkaban.txt

commandB.sh 脚本执行完成之后,将会把firstName变量值John的值写入文件/root/azkaban.txt文件。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值