use of com.uber.cadence.StartWorkflowExecutionRequest in project cadence-client by uber-java.
the class StateMachines method continueAsNewWorkflow.
private static void continueAsNewWorkflow(RequestContext ctx, WorkflowData data, ContinueAsNewWorkflowExecutionDecisionAttributes d, long decisionTaskCompletedEventId) {
StartWorkflowExecutionRequest sr = ctx.getWorkflowMutableState().getStartRequest();
WorkflowExecutionContinuedAsNewEventAttributes a = new WorkflowExecutionContinuedAsNewEventAttributes();
a.setInput(d.getInput());
if (d.isSetExecutionStartToCloseTimeoutSeconds()) {
a.setExecutionStartToCloseTimeoutSeconds(d.getExecutionStartToCloseTimeoutSeconds());
} else {
a.setExecutionStartToCloseTimeoutSeconds(sr.getExecutionStartToCloseTimeoutSeconds());
}
if (d.isSetTaskList()) {
a.setTaskList(d.getTaskList());
} else {
a.setTaskList(sr.getTaskList());
}
if (d.isSetWorkflowType()) {
a.setWorkflowType(d.getWorkflowType());
} else {
a.setWorkflowType(sr.getWorkflowType());
}
if (d.isSetTaskStartToCloseTimeoutSeconds()) {
a.setTaskStartToCloseTimeoutSeconds(d.getTaskStartToCloseTimeoutSeconds());
} else {
a.setTaskStartToCloseTimeoutSeconds(sr.getTaskStartToCloseTimeoutSeconds());
}
a.setDecisionTaskCompletedEventId(decisionTaskCompletedEventId);
HistoryEvent event = new HistoryEvent().setEventType(EventType.WorkflowExecutionContinuedAsNew).setWorkflowExecutionContinuedAsNewEventAttributes(a);
ctx.addEvent(event);
}
use of com.uber.cadence.StartWorkflowExecutionRequest in project cadence-client by uber-java.
the class StateMachines method initiateChildWorkflow.
private static void initiateChildWorkflow(RequestContext ctx, ChildWorkflowData data, StartChildWorkflowExecutionDecisionAttributes d, long decisionTaskCompletedEventId) {
StartChildWorkflowExecutionInitiatedEventAttributes a = new StartChildWorkflowExecutionInitiatedEventAttributes().setControl(d.getControl()).setInput(d.getInput()).setChildPolicy(d.getChildPolicy()).setDecisionTaskCompletedEventId(decisionTaskCompletedEventId).setDomain(d.getDomain() == null ? ctx.getDomain() : d.getDomain()).setExecutionStartToCloseTimeoutSeconds(d.getExecutionStartToCloseTimeoutSeconds()).setTaskStartToCloseTimeoutSeconds(d.getTaskStartToCloseTimeoutSeconds()).setTaskList(d.getTaskList()).setWorkflowId(d.getWorkflowId()).setWorkflowIdReusePolicy(d.getWorkflowIdReusePolicy()).setWorkflowType(d.getWorkflowType());
HistoryEvent event = new HistoryEvent().setEventType(EventType.StartChildWorkflowExecutionInitiated).setStartChildWorkflowExecutionInitiatedEventAttributes(a);
long initiatedEventId = ctx.addEvent(event);
ctx.onCommit((historySize) -> {
data.initiatedEventId = initiatedEventId;
data.initiatedEvent = a;
StartWorkflowExecutionRequest startChild = new StartWorkflowExecutionRequest().setInput(d.getInput()).setDomain(d.getDomain() == null ? ctx.getDomain() : d.getDomain()).setExecutionStartToCloseTimeoutSeconds(d.getExecutionStartToCloseTimeoutSeconds()).setTaskStartToCloseTimeoutSeconds(d.getTaskStartToCloseTimeoutSeconds()).setTaskList(d.getTaskList()).setWorkflowId(d.getWorkflowId()).setWorkflowIdReusePolicy(d.getWorkflowIdReusePolicy()).setWorkflowType(d.getWorkflowType());
addStartChildTask(ctx, data, initiatedEventId, startChild);
});
}
use of com.uber.cadence.StartWorkflowExecutionRequest in project cadence-client by uber-java.
the class TestWorkflowService method continueAsNew.
/**
* Creates next run of a workflow execution
*
* @return RunId
*/
public String continueAsNew(StartWorkflowExecutionRequest previousRunStartRequest, WorkflowExecutionContinuedAsNewEventAttributes a, String identity, ExecutionId executionId, Optional<TestWorkflowMutableState> parent) throws InternalServiceError, BadRequestError {
StartWorkflowExecutionRequest startRequest = new StartWorkflowExecutionRequest().setInput(a.getInput()).setWorkflowType(a.getWorkflowType()).setExecutionStartToCloseTimeoutSeconds(a.getExecutionStartToCloseTimeoutSeconds()).setTaskStartToCloseTimeoutSeconds(a.getTaskStartToCloseTimeoutSeconds()).setDomain(executionId.getDomain()).setTaskList(a.getTaskList()).setWorkflowId(executionId.getWorkflowId().getWorkflowId()).setWorkflowIdReusePolicy(previousRunStartRequest.getWorkflowIdReusePolicy()).setIdentity(identity);
StartWorkflowExecutionResponse response = startWorkflowExecutionNoRunningCheck(startRequest, parent, executionId.getWorkflowId());
return response.getRunId();
}
use of com.uber.cadence.StartWorkflowExecutionRequest in project cadence-client by uber-java.
the class GenericWorkflowClientExternalImpl method startWorkflow.
@Override
public WorkflowExecution startWorkflow(StartWorkflowExecutionParameters startParameters) throws WorkflowExecutionAlreadyStartedError {
StartWorkflowExecutionRequest request = new StartWorkflowExecutionRequest();
request.setDomain(domain);
request.setInput(startParameters.getInput());
request.setExecutionStartToCloseTimeoutSeconds((int) startParameters.getExecutionStartToCloseTimeoutSeconds());
request.setTaskStartToCloseTimeoutSeconds((int) startParameters.getTaskStartToCloseTimeoutSeconds());
request.setWorkflowIdReusePolicy(startParameters.getWorkflowIdReusePolicy());
String taskList = startParameters.getTaskList();
if (taskList != null && !taskList.isEmpty()) {
TaskList tl = new TaskList();
tl.setName(taskList);
request.setTaskList(tl);
}
String workflowId = startParameters.getWorkflowId();
if (workflowId == null) {
workflowId = UUID.randomUUID().toString();
}
request.setWorkflowId(workflowId);
request.setWorkflowType(startParameters.getWorkflowType());
// if(startParameters.getChildPolicy() != null) {
// request.setChildPolicy(startParameters.getChildPolicy());
// }
StartWorkflowExecutionResponse result;
try {
result = service.StartWorkflowExecution(request);
} catch (WorkflowExecutionAlreadyStartedError e) {
throw e;
} catch (TException e) {
throw CheckedExceptionWrapper.wrap(e);
}
WorkflowExecution execution = new WorkflowExecution();
execution.setRunId(result.getRunId());
execution.setWorkflowId(request.getWorkflowId());
return execution;
}
Aggregations