我需要在我的工作流程中注入条件执行。例如:如果满足特定条件,则应执行特定工作流。如果不是,则应执行不同的工作流程。
据我了解,Azkkaban 中没有直接的功能支持这一点。只有 Oozie 支持它。想知道 Azkkaban 用户是如何处理这个问题的吗?我相信每个人都必须以某种形式面对这个问题。
谢谢,克兰蒂
Azkaban 的路线图表示,此功能仅在他们未来的路线图中存在,因此无法轻松配置。剩下的唯一选择是以编程方式处理此问题。
如果有人有更好的建议,请告诉我。
谢谢,克兰蒂
FWIW,我们在我们的 Azkaban 项目中通过检查 shell 脚本中的条件来执行此操作。然后,如果满足条件,脚本将使用 Azkaban API 触发另一个工作流。
#!/bin/bash
# check some condition
check=`…`;
if [ ! -z "$check" ]; then
# Authenticate ourselves to Azkaban, capturing the session id
auth=`curl -k -X POST --data "action=login&username=my_user&password=my_password" https://localhost:8443 | jq '.["session.id"]' | sed -e 's/\"//g'`;
# Run the workflow using the Auth session id, capturing the response
run=`curl -k --get --data "session.id=$auth" --data 'ajax=executeFlow' --data 'project=my_project' --data "flow=my_flow" https://localhost:8443/executor | jq '.message'`;
# If $run response does not contain "successfully" it failed
if [[ $run = *successfully* ]]; then
echo "'$3': RUN STARTED";
else
echo "'$3': RUN ERROR";
exit 1;
fi;
else …
您需要注意触发的工作流在它自己的执行中运行。
您可以使用 Azkaban 中的触发器插件来执行此操作。这是我想出的一个简单示例:https ://gist.github.com/feliperazeek/faae2fed6aef780442a4 。
您可以实现自己的 Condition 实现。