Search in sources :

Example 1 with StartWorkflowExecutionResponse

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

the class TestWorkflowService method startWorkflowExecutionNoRunningCheck.

private StartWorkflowExecutionResponse startWorkflowExecutionNoRunningCheck(StartWorkflowExecutionRequest startRequest, Optional<TestWorkflowMutableState> parent, WorkflowId workflowId) throws InternalServiceError, BadRequestError {
    String domain = startRequest.getDomain();
    TestWorkflowMutableState result = new TestWorkflowMutableStateImpl(startRequest, parent, this, store);
    WorkflowExecution execution = result.getExecutionId().getExecution();
    ExecutionId executionId = new ExecutionId(domain, execution);
    lock.lock();
    try {
        openExecutions.put(workflowId, result);
        executions.put(executionId, result);
    } finally {
        lock.unlock();
    }
    result.startWorkflow();
    return new StartWorkflowExecutionResponse().setRunId(execution.getRunId());
}
Also used : StartWorkflowExecutionResponse(com.uber.cadence.StartWorkflowExecutionResponse) WorkflowExecution(com.uber.cadence.WorkflowExecution)

Example 2 with StartWorkflowExecutionResponse

use of com.uber.cadence.StartWorkflowExecutionResponse 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();
}
Also used : StartWorkflowExecutionResponse(com.uber.cadence.StartWorkflowExecutionResponse) StartWorkflowExecutionRequest(com.uber.cadence.StartWorkflowExecutionRequest)

Example 3 with StartWorkflowExecutionResponse

use of com.uber.cadence.StartWorkflowExecutionResponse 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;
}
Also used : TException(org.apache.thrift.TException) TaskList(com.uber.cadence.TaskList) StartWorkflowExecutionResponse(com.uber.cadence.StartWorkflowExecutionResponse) WorkflowExecutionAlreadyStartedError(com.uber.cadence.WorkflowExecutionAlreadyStartedError) WorkflowExecution(com.uber.cadence.WorkflowExecution) StartWorkflowExecutionRequest(com.uber.cadence.StartWorkflowExecutionRequest)

Aggregations

StartWorkflowExecutionResponse (com.uber.cadence.StartWorkflowExecutionResponse)3 StartWorkflowExecutionRequest (com.uber.cadence.StartWorkflowExecutionRequest)2 WorkflowExecution (com.uber.cadence.WorkflowExecution)2 TaskList (com.uber.cadence.TaskList)1 WorkflowExecutionAlreadyStartedError (com.uber.cadence.WorkflowExecutionAlreadyStartedError)1 TException (org.apache.thrift.TException)1