private void addTaskToQueue(final List<Task> tasks) { for (Task task : tasks) { addTaskToQueue(task); } }
/** * @throws ApplicationException */ public String startWorkflow(String name, Integer version, String correlationId, Map<String, Object> input, String externalInputPayloadStoragePath) { return startWorkflow(name, version, correlationId, input, externalInputPayloadStoragePath, null); }
/** * Ensures the truth of an condition involving one or more parameters to the calling method. * * @param condition a boolean expression * @param errorMessage The exception message use if the input condition is not valid * @throws com.netflix.conductor.core.execution.ApplicationException if input condition is not valid */ public static void checkArgument(boolean condition, String errorMessage){ if(!condition) { throw new ApplicationException(ApplicationException.Code.INVALID_INPUT, errorMessage); } }
public String rerun(RerunWorkflowRequest request) { Preconditions.checkNotNull(request.getReRunFromWorkflowId(), "reRunFromWorkflowId is missing"); if (!rerunWF(request.getReRunFromWorkflowId(), request.getReRunFromTaskId(), request.getTaskInput(), request.getWorkflowInput(), request.getCorrelationId())) { throw new ApplicationException(INVALID_INPUT, "Task " + request.getReRunFromTaskId() + " not found"); } return request.getReRunFromWorkflowId(); }
/** * Used to determine if the exception is thrown due to a transient failure * and the operation is expected to succeed upon retrying. * * @param throwableException the exception that is thrown * @return true - if the exception is a transient failure * false - if the exception is non-transient */ private boolean isTransientException(Throwable throwableException) { if (throwableException != null) { return !((throwableException instanceof UnsupportedOperationException) || (throwableException instanceof ApplicationException && ((ApplicationException) throwableException).getCode() != ApplicationException.Code.BACKEND_ERROR)); } return true; }
public Map<String, Object> getTaskInput(Map<String, Object> inputParams, Workflow workflow, TaskDef taskDefinition, String taskId) { if (workflow.getSchemaVersion() > 1) { return getTaskInputV2(inputParams, workflow, taskId, taskDefinition); } return getTaskInputV1(workflow, inputParams); }
public void updateTask(TaskResult taskResult) { workflowExecutor.updateTask(taskResult); }
/** * Retries the last failed task. * @param workflowId WorkflowId of the workflow. */ @Service public void retryWorkflow(String workflowId) { workflowExecutor.retry(workflowId); }
/** * Restarts a completed workflow. * * @param workflowId WorkflowId of the workflow. * @param useLatestDefinitions if true, use the latest workflow and task definitions upon restart */ @Service public void restartWorkflow(String workflowId, boolean useLatestDefinitions) { workflowExecutor.rewind(workflowId, useLatestDefinitions); }
public List<Task> getTasksToBeScheduled(Workflow workflow, WorkflowTask taskToSchedule, int retryCount) { return getTasksToBeScheduled(workflow, taskToSchedule, retryCount, null); }
public Task getTask(String taskId) { return workflowExecutor.getTask(taskId); }
public ApplicationException(Code code, Throwable t){ super(code.name(), t); this.code = code; }
public Task getPendingTaskForWorkflow(String taskReferenceName, String workflowId) { return workflowExecutor.getPendingTaskByWorkflow(taskReferenceName, workflowId); }
public int getHttpStatusCode(){ return this.code.getStatusCode(); }
public List<Task> getTasks(String taskType, String startKey, int count) { return workflowExecutor.getTasks(taskType, startKey, count); }
private void failWorkflow(String errorMsg) { logger.error(errorMsg); throw new TerminateWorkflowException(errorMsg); } }
protected String toJson(Object value) { try { return objectMapper.writeValueAsString(value); } catch (JsonProcessingException ex) { throw new ApplicationException(ApplicationException.Code.INTERNAL_ERROR, ex); } }
/** * @throws ApplicationException */ public String startWorkflow(String name, Integer version, String correlationId, Map<String, Object> input, String externalInputPayloadStoragePath, String event) { return startWorkflow( name, version, input, externalInputPayloadStoragePath, correlationId, null, null, event ); }
protected <T> T readValue(String json, TypeReference<T> typeReference) { try { return objectMapper.readValue(json, typeReference); } catch (IOException ex) { throw new ApplicationException(ApplicationException.Code.INTERNAL_ERROR, ex); } }
@Override String startOrLoadWorkflowExecution(String snapshotResourceName, String workflowName, int version, String correlationId, Map<String, Object> input, String event, Map<String, String> taskToDomain) { return workflowExecutor.startWorkflow(workflowName, version, correlationId, input, null, event, taskToDomain); } }