use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class TerminateTaskMapper method getMappedTasks.
@Override
public List<Task> getMappedTasks(TaskMapperContext taskMapperContext) {
logger.debug("TaskMapperContext {} in TerminateTaskMapper", taskMapperContext);
WorkflowTask taskToSchedule = taskMapperContext.getTaskToSchedule();
Workflow workflowInstance = taskMapperContext.getWorkflowInstance();
String taskId = taskMapperContext.getTaskId();
Map<String, Object> taskInput = parametersUtils.getTaskInputV2(taskMapperContext.getTaskToSchedule().getInputParameters(), workflowInstance, taskId, null);
Task task = new Task();
task.setTaskType(Terminate.TASK_NAME);
task.setTaskDefName(taskToSchedule.getName());
task.setReferenceTaskName(taskToSchedule.getTaskReferenceName());
task.setWorkflowInstanceId(workflowInstance.getWorkflowId());
task.setWorkflowType(workflowInstance.getWorkflowName());
task.setCorrelationId(workflowInstance.getCorrelationId());
task.setScheduledTime(System.currentTimeMillis());
task.setStartTime(System.currentTimeMillis());
task.setInputData(taskInput);
task.setTaskId(taskId);
task.setStatus(Task.Status.IN_PROGRESS);
task.setWorkflowTask(taskToSchedule);
task.setWorkflowPriority(workflowInstance.getPriority());
return singletonList(task);
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class ExecutionDAOTest method testTaskExceedsLimit.
@Test
public void testTaskExceedsLimit() {
TaskDef taskDefinition = new TaskDef();
taskDefinition.setName("task1");
taskDefinition.setConcurrentExecLimit(1);
WorkflowTask workflowTask = new WorkflowTask();
workflowTask.setName("task1");
workflowTask.setTaskDefinition(taskDefinition);
workflowTask.setTaskDefinition(taskDefinition);
List<Task> tasks = new LinkedList<>();
for (int i = 0; i < 15; i++) {
Task task = new Task();
task.setScheduledTime(1L);
task.setSeq(i + 1);
task.setTaskId("t_" + i);
task.setWorkflowInstanceId("workflow_" + i);
task.setReferenceTaskName("task1");
task.setTaskDefName("task1");
tasks.add(task);
task.setStatus(Task.Status.SCHEDULED);
task.setWorkflowTask(workflowTask);
}
getExecutionDAO().createTasks(tasks);
assertFalse(getExecutionDAO().exceedsInProgressLimit(tasks.get(0)));
tasks.get(0).setStatus(Task.Status.IN_PROGRESS);
getExecutionDAO().updateTask(tasks.get(0));
for (Task task : tasks) {
assertTrue(getExecutionDAO().exceedsInProgressLimit(task));
}
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class MetadataMapperServiceTest method testShouldNotPopulateTaskDefinition.
@Test
public void testShouldNotPopulateTaskDefinition() {
WorkflowTask workflowTask = createWorkflowTask("");
assertFalse(metadataMapperService.shouldPopulateTaskDefinition(workflowTask));
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class MetadataMapperServiceTest method testVersionPopulationForSubworkflowTaskIfVersionIsNotAvailable.
@Test
public void testVersionPopulationForSubworkflowTaskIfVersionIsNotAvailable() {
String nameTaskDefinition = "taskSubworkflow6";
String workflowDefinitionName = "subworkflow";
Integer version = 3;
WorkflowDef subWorkflowDefinition = createWorkflowDefinition("workflowDefinitionName");
subWorkflowDefinition.setVersion(version);
WorkflowTask workflowTask = createWorkflowTask(nameTaskDefinition);
workflowTask.setWorkflowTaskType(TaskType.SUB_WORKFLOW);
SubWorkflowParams subWorkflowParams = new SubWorkflowParams();
subWorkflowParams.setName(workflowDefinitionName);
workflowTask.setSubWorkflowParam(subWorkflowParams);
WorkflowDef workflowDefinition = createWorkflowDefinition("testMetadataPopulation");
workflowDefinition.setTasks(ImmutableList.of(workflowTask));
when(metadataDAO.getLatestWorkflowDef(workflowDefinitionName)).thenReturn(Optional.of(subWorkflowDefinition));
metadataMapperService.populateTaskDefinitions(workflowDefinition);
assertEquals(1, workflowDefinition.getTasks().size());
List<WorkflowTask> workflowTasks = workflowDefinition.getTasks();
SubWorkflowParams params = workflowTasks.get(0).getSubWorkflowParam();
assertEquals(workflowDefinitionName, params.getName());
assertEquals(version, params.getVersion());
verify(metadataDAO).getLatestWorkflowDef(workflowDefinitionName);
verify(metadataDAO).getTaskDef(nameTaskDefinition);
verifyNoMoreInteractions(metadataDAO);
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowTask in project conductor by Netflix.
the class MetadataMapperServiceTest method createWorkflowTask.
private WorkflowTask createWorkflowTask(String name) {
WorkflowTask workflowTask = new WorkflowTask();
workflowTask.setName(name);
workflowTask.setType(TaskType.SIMPLE.name());
return workflowTask;
}
Aggregations