如何检查LoadApplicationService的完成状态?

时间:2016-12-29 14:17:34

标签: java xml oozie oozie-coordinator

我在工作流程中有2个操作节点:javaMainActionjavaMainAction2

我的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>

1 个答案:

答案 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();
      }
   }