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