Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Workflow will have onFinish method which will be called at the end of the every Workflow run.
      

    Code Block
    languagejava
    /**
     * Called when the Workflow run finishes either successfully or on failure.
     * @param isSucceeded flag to indicate the success/failure
     * @param context the Workflow context
     * @param state the state of the Workflow
     */
    void onFinish(boolean isSucceeded, WorkflowContext context, WorkflowState state);
    
    

     

  2. WorkflowState class encapsulate the status of all the nodes executed by the Workflow along with the failure information if any, as - 

    Code Block
    languagejava
    public final class WorkflowState {
      private final Map<String, WorkflowNodeState> nodeState;
      // Failure information for the Workflow run 
      private WorkflowFailureInfo info; 
    }
     
    public final class WorkflowNodeState {
      private final String nodeId;
      private final ProgramRunStatus nodeStatus;
      private final RunId runId; 
    }
     
    public final class WorkflowFailureInfo {
       // id of the node for which the failure occurred in the Workflow.
       private final String failedNodeId;
       // failure cause
       private final Throwable failureCause;  
    }


  3. WorkflowState can be stored as property in the RunRecord of the Workflow. This property will be updated when the action in the Workflow starts and ends.

  4. When the Workflow run finishes, before calling the onFinish method on the Workflow, WorkflowState for that run can be fetched from the store and passed on to the onFinish method. WorkflowState can be used by user in the onFinish method to check what actions ran and accordingly cleanup can be performed.

  5. User can update the WorkflowToken in onFinish method, such as changing the preference for the local datasets. (What should be the nodeId used for these updates?)

  6. Similar to the onFinish method of the MapReduce, Workflow.onFinish will also run in short transaction as a first step. Ideally user would have control over what transaction should be started in the onFinish.