Versions Compared

Key

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

...

Approach for CDAP-4075

  1. Workflow will have the onFinish method which will be called at the end of the every Workflow run. This is similar to the MapReduce programs.
      

    Code Block
    languagejava
    /**
     * Called when the Workflow run finishes either successfully or on failure.
     * @param isSucceeded contextflag contextto ofindicate the Workflowsuccess/failure
     * @param context causethe non-nullWorkflow valuecontext
    indicates that* there@param isstate athe failurestate inof the Workflow
    run  */
    void onFinish(boolean isSucceeded, WorkflowContext context, @NullableWorkflowState WorkflowFailure causestate);
    
    

     

  2. WorkflowFailure WorkflowState class encapsulate the failure cause and the id of the node which failedthe status of all the nodes executed by the Workflow along with the failure information if any, as - 

    Code Block
    languagejava
    public final class WorkflowFailureWorkflowState {
       // id of the node which failed the executionprivate final Map<String, WorkflowNodeState> nodeState;
      // Failure information for the Workflow run 
      private finalWorkflowFailureInfo String nodeIdinfo; 
    }
     
    public final class WorkflowNodeState {
      private final String nodeId;
      //private failurefinal reasonProgramRunStatus nodeStatus;
      private final ThrowableRunId failureReasonrunId;
    }
    WorkflowFailure will be set by the WorkflowDriver when there is any exception while executing the node in the Workflow.
    In the current implementation of the WorkflowDriver, when there is a failure in the fork node, we interrupt the nodes executing on the other branches. WorkflowFailure will still correspond to the first failure that occurred in the Workflow.
     
    }
     
    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.

  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?)