Search in sources :

Example 11 with Decision

use of com.uber.cadence.Decision in project cadence-client by uber-java.

the class DecisionsHelper method continueAsNewWorkflowExecution.

void continueAsNewWorkflowExecution(ContinueAsNewWorkflowExecutionParameters continueParameters) {
    WorkflowExecutionStartedEventAttributes startedEvent = task.getHistory().getEvents().get(0).getWorkflowExecutionStartedEventAttributes();
    ContinueAsNewWorkflowExecutionDecisionAttributes attributes = new ContinueAsNewWorkflowExecutionDecisionAttributes();
    attributes.setWorkflowType(task.getWorkflowType());
    attributes.setInput(continueParameters.getInput());
    int executionStartToClose = continueParameters.getExecutionStartToCloseTimeoutSeconds();
    if (executionStartToClose == 0) {
        executionStartToClose = startedEvent.getExecutionStartToCloseTimeoutSeconds();
    }
    attributes.setExecutionStartToCloseTimeoutSeconds(executionStartToClose);
    int taskStartToClose = continueParameters.getTaskStartToCloseTimeoutSeconds();
    if (taskStartToClose == 0) {
        taskStartToClose = startedEvent.getTaskStartToCloseTimeoutSeconds();
    }
    attributes.setTaskStartToCloseTimeoutSeconds(taskStartToClose);
    String taskList = continueParameters.getTaskList();
    if (taskList == null || taskList.isEmpty()) {
        taskList = startedEvent.getTaskList().getName();
    }
    TaskList tl = new TaskList();
    tl.setName(taskList);
    attributes.setTaskList(tl);
    Decision decision = new Decision();
    decision.setDecisionType(DecisionType.ContinueAsNewWorkflowExecution);
    decision.setContinueAsNewWorkflowExecutionDecisionAttributes(attributes);
    DecisionId decisionId = new DecisionId(DecisionTarget.SELF, null);
    addDecision(decisionId, new CompleteWorkflowStateMachine(decisionId, decision));
}
Also used : ContinueAsNewWorkflowExecutionDecisionAttributes(com.uber.cadence.ContinueAsNewWorkflowExecutionDecisionAttributes) TaskList(com.uber.cadence.TaskList) ChildWorkflowExecutionStartedEventAttributes(com.uber.cadence.ChildWorkflowExecutionStartedEventAttributes) WorkflowExecutionStartedEventAttributes(com.uber.cadence.WorkflowExecutionStartedEventAttributes) Decision(com.uber.cadence.Decision)

Example 12 with Decision

use of com.uber.cadence.Decision in project cadence-client by uber-java.

the class DecisionsHelper method completeWorkflowExecution.

void completeWorkflowExecution(byte[] output) {
    Decision decision = new Decision();
    CompleteWorkflowExecutionDecisionAttributes complete = new CompleteWorkflowExecutionDecisionAttributes();
    complete.setResult(output);
    decision.setCompleteWorkflowExecutionDecisionAttributes(complete);
    decision.setDecisionType(DecisionType.CompleteWorkflowExecution);
    DecisionId decisionId = new DecisionId(DecisionTarget.SELF, null);
    addDecision(decisionId, new CompleteWorkflowStateMachine(decisionId, decision));
}
Also used : CompleteWorkflowExecutionDecisionAttributes(com.uber.cadence.CompleteWorkflowExecutionDecisionAttributes) Decision(com.uber.cadence.Decision)

Example 13 with Decision

use of com.uber.cadence.Decision in project cadence-client by uber-java.

the class DecisionsHelper method failWorkflowExecution.

void failWorkflowExecution(WorkflowExecutionException failure) {
    Decision decision = new Decision();
    FailWorkflowExecutionDecisionAttributes failAttributes = new FailWorkflowExecutionDecisionAttributes();
    failAttributes.setReason(failure.getReason());
    failAttributes.setDetails(failure.getDetails());
    decision.setFailWorkflowExecutionDecisionAttributes(failAttributes);
    decision.setDecisionType(DecisionType.FailWorkflowExecution);
    DecisionId decisionId = new DecisionId(DecisionTarget.SELF, null);
    addDecision(decisionId, new CompleteWorkflowStateMachine(decisionId, decision));
}
Also used : FailWorkflowExecutionDecisionAttributes(com.uber.cadence.FailWorkflowExecutionDecisionAttributes) Decision(com.uber.cadence.Decision)

Example 14 with Decision

use of com.uber.cadence.Decision in project cadence-client by uber-java.

the class WorkflowExecutionUtils method prettyPrintDecisions.

public static String prettyPrintDecisions(Iterable<Decision> decisions) {
    StringBuilder result = new StringBuilder();
    result.append("{");
    boolean first = true;
    for (Decision decision : decisions) {
        if (first) {
            first = false;
        } else {
            result.append(",");
        }
        result.append("\n    ");
        result.append(prettyPrintDecision(decision));
    }
    result.append("\n}");
    return result.toString();
}
Also used : Decision(com.uber.cadence.Decision)

Example 15 with Decision

use of com.uber.cadence.Decision in project cadence-client by uber-java.

the class ChildWorkflowDecisionStateMachine method createRequestCancelExternalWorkflowExecutionDecision.

private Decision createRequestCancelExternalWorkflowExecutionDecision() {
    RequestCancelExternalWorkflowExecutionDecisionAttributes tryCancel = new RequestCancelExternalWorkflowExecutionDecisionAttributes();
    tryCancel.setWorkflowId(startAttributes.getWorkflowId());
    tryCancel.setRunId(runId);
    Decision decision = new Decision();
    decision.setRequestCancelExternalWorkflowExecutionDecisionAttributes(tryCancel);
    decision.setDecisionType(DecisionType.RequestCancelExternalWorkflowExecution);
    return decision;
}
Also used : RequestCancelExternalWorkflowExecutionDecisionAttributes(com.uber.cadence.RequestCancelExternalWorkflowExecutionDecisionAttributes) Decision(com.uber.cadence.Decision)

Aggregations

Decision (com.uber.cadence.Decision)15 BadRequestError (com.uber.cadence.BadRequestError)1 CancelTimerDecisionAttributes (com.uber.cadence.CancelTimerDecisionAttributes)1 CancelWorkflowExecutionDecisionAttributes (com.uber.cadence.CancelWorkflowExecutionDecisionAttributes)1 ChildWorkflowExecutionStartedEventAttributes (com.uber.cadence.ChildWorkflowExecutionStartedEventAttributes)1 CompleteWorkflowExecutionDecisionAttributes (com.uber.cadence.CompleteWorkflowExecutionDecisionAttributes)1 ContinueAsNewWorkflowExecutionDecisionAttributes (com.uber.cadence.ContinueAsNewWorkflowExecutionDecisionAttributes)1 EntityNotExistsError (com.uber.cadence.EntityNotExistsError)1 FailWorkflowExecutionDecisionAttributes (com.uber.cadence.FailWorkflowExecutionDecisionAttributes)1 InternalServiceError (com.uber.cadence.InternalServiceError)1 PollForDecisionTaskResponse (com.uber.cadence.PollForDecisionTaskResponse)1 RequestCancelActivityTaskDecisionAttributes (com.uber.cadence.RequestCancelActivityTaskDecisionAttributes)1 RequestCancelExternalWorkflowExecutionDecisionAttributes (com.uber.cadence.RequestCancelExternalWorkflowExecutionDecisionAttributes)1 RespondDecisionTaskCompletedRequest (com.uber.cadence.RespondDecisionTaskCompletedRequest)1 RespondDecisionTaskFailedRequest (com.uber.cadence.RespondDecisionTaskFailedRequest)1 RespondQueryTaskCompletedRequest (com.uber.cadence.RespondQueryTaskCompletedRequest)1 StartTimerDecisionAttributes (com.uber.cadence.StartTimerDecisionAttributes)1 TaskList (com.uber.cadence.TaskList)1 WorkflowExecution (com.uber.cadence.WorkflowExecution)1 WorkflowExecutionStartedEventAttributes (com.uber.cadence.WorkflowExecutionStartedEventAttributes)1