我在工作流程中有2个操作节点:javaMainAction
和javaMainAction2
。
我的LoadApplicationService
方法在执行后返回SUCCESS或FAILURE。
如果返回SUCCESS,如何检查响应?
workflow.xml:
<workflow-app name="WorkflowJavaMainAction" xmlns="uri:oozie:workflow:0.1">
<start to="javaMainAction" />
<action name="javaMainAction">
<java>
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<main-class>in.augmentiq.maxiq.dataschedular.services.LoadApplicationService</main-class>
<arg>${workflowAppPath}/javaMainActionInput/schedule_config.properties</arg>
<arg>${workflowAppPath}/javaMainActionInput/appRequestParams.json</arg>
<capture-output/>
</java>
<ok to="javaMainAction2" />
<error to="killJobAction" />
</action>
<action name="javaMainAction2">
<java>
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<main-class>in.augmentiq.maxiq.dataschedular.services.LoadApplicationService</main-class>
<arg>${workflowAppPath}/javaMainAction2Input/schedule_config.properties</arg>
<arg>${workflowAppPath}/javaMainAction2Input/appRequestParams.json</arg>
<capture-output/>
</java>
<ok to="end" />
<error to="killJobAction" />
</action>
<kill name="killJobAction">
<message>"Killed job due to error: ${wf:errorMessage(wf:lastErrorNode())}"</message>
</kill>
<end name="end" />
</workflow-app>
答案 0 :(得分:3)
LoadApplicationService
需要将输出写入key=pair
格式,例如response=SUCCESS
。您可以像这样检查输出:
${wf:actionData("action-name")["key"]}
使用决策控制节点进行比较并做出决策Decision_Control_Node。
编辑注释:如何在java操作中编写属性。
main()方法将Property文件写入oozie.action.output.properties
ENVIRONMENT变量中指定的路径。 Reference
public static void main (String[] args)
{
String fileName = args[0];
try{
File file = new File(System.getProperty("oozie.action.output.properties"));
Properties props = new Properties();
props.setProperty("PASS_ME", "123456");
OutputStream os = new FileOutputStream(file);
props.store(os, "");
os.close();
System.out.println(file.getAbsolutePath());
}
catch (Exception e) {
e.printStackTrace();
}
}