How does one check completion status of LoadApplicationService?

1.1k views Asked by At

I have 2 action nodes in workflow : javaMainAction and javaMainAction2.

My LoadApplicationService method returns SUCCESS or FAILURE after execution.

How to check response if SUCCESS is returned?

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

There are 1 answers

4
YoungHobbit On BEST ANSWER

LoadApplicationService needs to write the output into a key=pair format e.g. response=SUCCESS. The you can inspect the output like this:

${wf:actionData("action-name")["key"]}

Use Decision control node for comparing and taking decision Decision_Control_Node.


Edit for the comment: How to write property in a java action.

The main() method writes a Property file to the path specified in the oozie.action.output.properties ENVIRONMENT variable. 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();
      }
   }