Search in sources :

Example 16 with SubWorkflowParams

use of com.netflix.conductor.common.metadata.workflow.SubWorkflowParams in project conductor by Netflix.

the class AbstractProtoMapper method fromProto.

public SubWorkflowParams fromProto(SubWorkflowParamsPb.SubWorkflowParams from) {
    SubWorkflowParams to = new SubWorkflowParams();
    to.setName(from.getName());
    to.setVersion(from.getVersion());
    to.setTaskToDomain(from.getTaskToDomainMap());
    if (from.hasWorkflowDefinition()) {
        to.setWorkflowDefinition(fromProto(from.getWorkflowDefinition()));
    }
    return to;
}
Also used : SubWorkflowParams(com.netflix.conductor.common.metadata.workflow.SubWorkflowParams)

Example 17 with SubWorkflowParams

use of com.netflix.conductor.common.metadata.workflow.SubWorkflowParams in project conductor by Netflix.

the class AbstractWorkflowServiceTest method createWorkflowWithSubWorkflow.

private void createWorkflowWithSubWorkflow() {
    WorkflowDef defSW = new WorkflowDef();
    defSW.setName(LINEAR_WORKFLOW_T1_T2_SW);
    defSW.setDescription(defSW.getName());
    defSW.setVersion(1);
    defSW.setInputParameters(Arrays.asList("param1", "param2"));
    Map<String, Object> outputParameters = new HashMap<>();
    outputParameters.put("o1", "${workflow.input.param1}");
    outputParameters.put("o2", "${t2.output.uuid}");
    outputParameters.put("o3", "${t1.output.op}");
    defSW.setOutputParameters(outputParameters);
    defSW.setFailureWorkflow("$workflow.input.failureWfName");
    defSW.setSchemaVersion(2);
    LinkedList<WorkflowTask> wftasks = new LinkedList<>();
    WorkflowTask wft1 = new WorkflowTask();
    wft1.setName("junit_task_3");
    Map<String, Object> ip1 = new HashMap<>();
    ip1.put("p1", "${workflow.input.param1}");
    ip1.put("p2", "${workflow.input.param2}");
    wft1.setInputParameters(ip1);
    wft1.setTaskReferenceName("t1");
    WorkflowTask subWorkflow = new WorkflowTask();
    subWorkflow.setType(SUB_WORKFLOW.name());
    SubWorkflowParams sw = new SubWorkflowParams();
    sw.setName(LINEAR_WORKFLOW_T1_T2);
    subWorkflow.setSubWorkflowParam(sw);
    subWorkflow.setTaskReferenceName("sw1");
    Map<String, Object> ip2 = new HashMap<>();
    ip2.put("tp1", "${workflow.input.param1}");
    ip2.put("tp2", "${t1.output.op}");
    subWorkflow.setInputParameters(ip2);
    wftasks.add(wft1);
    wftasks.add(subWorkflow);
    defSW.setTasks(wftasks);
    try {
        metadataService.updateWorkflowDef(defSW);
    } catch (Exception e) {
    }
}
Also used : SubWorkflowParams(com.netflix.conductor.common.metadata.workflow.SubWorkflowParams) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) HashMap(java.util.HashMap) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) LinkedList(java.util.LinkedList) ExpectedException(org.junit.rules.ExpectedException) ApplicationException(com.netflix.conductor.core.execution.ApplicationException)

Example 18 with SubWorkflowParams

use of com.netflix.conductor.common.metadata.workflow.SubWorkflowParams in project conductor by Netflix.

the class AbstractWorkflowServiceTest method createForkJoinWorkflowWithOptionalSubworkflowForks.

private void createForkJoinWorkflowWithOptionalSubworkflowForks() {
    String taskName = "simple_task_in_sub_wf";
    TaskDef task = new TaskDef();
    task.setName(taskName);
    task.setRetryCount(0);
    metadataService.registerTaskDef(Collections.singletonList(task));
    // sub workflow
    WorkflowDef subworkflow_def = new WorkflowDef();
    subworkflow_def.setName("sub_workflow");
    subworkflow_def.setDescription(subworkflow_def.getName());
    subworkflow_def.setVersion(1);
    subworkflow_def.setSchemaVersion(2);
    LinkedList<WorkflowTask> subworkflowDef_Task = new LinkedList<>();
    WorkflowTask simpleTask = new WorkflowTask();
    simpleTask.setName(taskName);
    simpleTask.setInputParameters(new HashMap<>());
    simpleTask.setTaskReferenceName("t1");
    subworkflowDef_Task.add(simpleTask);
    subworkflow_def.setTasks(subworkflowDef_Task);
    metadataService.updateWorkflowDef(subworkflow_def);
    // parent workflow
    WorkflowDef workflowDef = new WorkflowDef();
    workflowDef.setName(WORKFLOW_FORK_JOIN_OPTIONAL_SW);
    workflowDef.setDescription(workflowDef.getName());
    workflowDef.setVersion(1);
    workflowDef.setInputParameters(Arrays.asList("param1", "param2"));
    // fork task
    WorkflowTask fanoutTask = new WorkflowTask();
    fanoutTask.setType(TaskType.FORK_JOIN.name());
    fanoutTask.setTaskReferenceName("fanouttask");
    // sub workflow tasks
    WorkflowTask subWorkflowTask1 = new WorkflowTask();
    subWorkflowTask1.setType(SUB_WORKFLOW.name());
    SubWorkflowParams subWorkflowParams = new SubWorkflowParams();
    subWorkflowParams.setName("sub_workflow");
    subWorkflowTask1.setSubWorkflowParam(subWorkflowParams);
    subWorkflowTask1.setTaskReferenceName("st1");
    subWorkflowTask1.setOptional(true);
    WorkflowTask subWorkflowTask2 = new WorkflowTask();
    subWorkflowTask2.setType(SUB_WORKFLOW.name());
    subWorkflowParams = new SubWorkflowParams();
    subWorkflowParams.setName("sub_workflow");
    subWorkflowTask2.setSubWorkflowParam(subWorkflowParams);
    subWorkflowTask2.setTaskReferenceName("st2");
    subWorkflowTask2.setOptional(true);
    // join task
    WorkflowTask joinTask = new WorkflowTask();
    joinTask.setType(TaskType.JOIN.name());
    joinTask.setTaskReferenceName("fanouttask_join");
    joinTask.setJoinOn(Arrays.asList("st1", "st2"));
    fanoutTask.getForkTasks().add(Collections.singletonList(subWorkflowTask1));
    fanoutTask.getForkTasks().add(Collections.singletonList(subWorkflowTask2));
    workflowDef.getTasks().add(fanoutTask);
    workflowDef.getTasks().add(joinTask);
    metadataService.updateWorkflowDef(workflowDef);
}
Also used : SubWorkflowParams(com.netflix.conductor.common.metadata.workflow.SubWorkflowParams) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) LinkedList(java.util.LinkedList)

Example 19 with SubWorkflowParams

use of com.netflix.conductor.common.metadata.workflow.SubWorkflowParams in project conductor by Netflix.

the class AbstractWorkflowServiceTest method createSubWorkflowTask.

private WorkflowTask createSubWorkflowTask(String subWorkflowName) {
    WorkflowTask subWorkflowTask = new WorkflowTask();
    subWorkflowTask.setType(SUB_WORKFLOW.name());
    SubWorkflowParams subWorkflowParams = new SubWorkflowParams();
    subWorkflowParams.setName(subWorkflowName);
    subWorkflowTask.setSubWorkflowParam(subWorkflowParams);
    subWorkflowTask.setTaskReferenceName(subWorkflowName + "_task");
    return subWorkflowTask;
}
Also used : SubWorkflowParams(com.netflix.conductor.common.metadata.workflow.SubWorkflowParams) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask)

Example 20 with SubWorkflowParams

use of com.netflix.conductor.common.metadata.workflow.SubWorkflowParams in project conductor by Netflix.

the class AbstractWorkflowServiceTest method createWorkflow_TaskSubworkflowTask.

private void createWorkflow_TaskSubworkflowTask() {
    WorkflowDef workflowDef = new WorkflowDef();
    workflowDef.setName(WF_T1_SWF_T2);
    workflowDef.setDescription(workflowDef.getName());
    workflowDef.setVersion(1);
    workflowDef.setInputParameters(Arrays.asList("param1", "param2"));
    Map<String, Object> outputParameters = new HashMap<>();
    outputParameters.put("o3", "${t1.output.op}");
    workflowDef.setOutputParameters(outputParameters);
    workflowDef.setSchemaVersion(2);
    LinkedList<WorkflowTask> wftasks = new LinkedList<>();
    WorkflowTask wft1 = new WorkflowTask();
    wft1.setName("junit_task_1");
    Map<String, Object> ip1 = new HashMap<>();
    ip1.put("tp11", "${workflow.input.param1}");
    ip1.put("tp12", "${workflow.input.param2}");
    wft1.setInputParameters(ip1);
    wft1.setTaskReferenceName("t1");
    // create the sub-workflow def
    WorkflowDef subWorkflowDef = new WorkflowDef();
    subWorkflowDef.setName("one_task_workflow");
    subWorkflowDef.setVersion(1);
    subWorkflowDef.setInputParameters(Arrays.asList("imageType", "op"));
    outputParameters = new HashMap<>();
    outputParameters.put("op", "${t3.output.op}");
    subWorkflowDef.setOutputParameters(outputParameters);
    subWorkflowDef.setSchemaVersion(2);
    LinkedList<WorkflowTask> subWfTasks = new LinkedList<>();
    WorkflowTask wft3 = new WorkflowTask();
    wft3.setName("junit_task_3");
    Map<String, Object> ip3 = new HashMap<>();
    ip3.put("p1", "${workflow.input.imageType}");
    wft3.setInputParameters(ip3);
    wft3.setTaskReferenceName("t3");
    subWfTasks.add(wft3);
    subWorkflowDef.setTasks(subWfTasks);
    metadataService.updateWorkflowDef(subWorkflowDef);
    // create the sub workflow task
    WorkflowTask subWorkflow = new WorkflowTask();
    subWorkflow.setType(SUB_WORKFLOW.name());
    SubWorkflowParams sw = new SubWorkflowParams();
    sw.setName("one_task_workflow");
    subWorkflow.setSubWorkflowParam(sw);
    subWorkflow.setTaskReferenceName("swt");
    Map<String, Object> ipsw = new HashMap<>();
    ipsw.put("imageType", "${t1.output.imageType}");
    ipsw.put("op", "${t1.output.op}");
    subWorkflow.setInputParameters(ipsw);
    WorkflowTask wft2 = new WorkflowTask();
    wft2.setName("junit_task_2");
    Map<String, Object> ip2 = new HashMap<>();
    ip2.put("op", "${t1.output.op}");
    wft2.setInputParameters(ip2);
    wft2.setTaskReferenceName("t2");
    wftasks.add(wft1);
    wftasks.add(subWorkflow);
    wftasks.add(wft2);
    workflowDef.setTasks(wftasks);
    metadataService.updateWorkflowDef(workflowDef);
}
Also used : SubWorkflowParams(com.netflix.conductor.common.metadata.workflow.SubWorkflowParams) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) HashMap(java.util.HashMap) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) LinkedList(java.util.LinkedList)

Aggregations

SubWorkflowParams (com.netflix.conductor.common.metadata.workflow.SubWorkflowParams)26 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)21 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)17 Test (org.junit.Test)13 HashMap (java.util.HashMap)12 LinkedList (java.util.LinkedList)5 Task (com.netflix.conductor.common.metadata.tasks.Task)4 Workflow (com.netflix.conductor.common.run.Workflow)4 SubWorkflow (com.netflix.conductor.core.execution.tasks.SubWorkflow)4 TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 ConstraintViolation (javax.validation.ConstraintViolation)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 DynamicForkJoinTaskList (com.netflix.conductor.common.metadata.workflow.DynamicForkJoinTaskList)1 JsonMapperProvider (com.netflix.conductor.common.utils.JsonMapperProvider)1 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)1 TerminateWorkflowException (com.netflix.conductor.core.execution.TerminateWorkflowException)1