use of com.netflix.conductor.common.metadata.tasks.Task in project conductor by Netflix.
the class TestElasticSearchDAOV5 method indexTask.
@Test
public void indexTask() throws Exception {
String correlationId = "some-correlation-id";
Task task = new Task();
task.setTaskId("some-task-id");
task.setWorkflowInstanceId("some-workflow-instance-id");
task.setTaskType("some-task-type");
task.setStatus(Status.FAILED);
task.setInputData(new HashMap<String, Object>() {
{
put("input_key", "input_value");
}
});
task.setCorrelationId(correlationId);
task.setTaskDefName("some-task-def-name");
task.setReasonForIncompletion("some-failure-reason");
indexDAO.indexTask(task);
await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
SearchResult<String> result = indexDAO.searchTasks("correlationId='" + correlationId + "'", "*", 0, 10000, null);
assertTrue("should return 1 or more search results", result.getResults().size() > 0);
assertEquals("taskId should match the indexed task", "some-task-id", result.getResults().get(0));
});
}
use of com.netflix.conductor.common.metadata.tasks.Task in project conductor by Netflix.
the class TestElasticSearchRestDAOV5 method createTestWorkflow.
@Before
public void createTestWorkflow() throws Exception {
// define indices
indexDAO.setup();
// initialize workflow
workflow = new Workflow();
workflow.getInput().put("requestId", "request id 001");
workflow.getInput().put("hasAwards", true);
workflow.getInput().put("channelMapping", 5);
Map<String, Object> name = new HashMap<>();
name.put("name", "The Who");
name.put("year", 1970);
Map<String, Object> name2 = new HashMap<>();
name2.put("name", "The Doors");
name2.put("year", 1975);
List<Object> names = new LinkedList<>();
names.add(name);
names.add(name2);
workflow.getOutput().put("name", name);
workflow.getOutput().put("names", names);
workflow.getOutput().put("awards", 200);
Task task = new Task();
task.setReferenceTaskName("task2");
task.getOutputData().put("location", "http://location");
task.setStatus(Task.Status.COMPLETED);
Task task2 = new Task();
task2.setReferenceTaskName("task3");
task2.getOutputData().put("refId", "abcddef_1234_7890_aaffcc");
task2.setStatus(Task.Status.SCHEDULED);
workflow.getTasks().add(task);
workflow.getTasks().add(task2);
}
use of com.netflix.conductor.common.metadata.tasks.Task in project conductor by Netflix.
the class TestElasticSearchDAOV5 method createTestWorkflow.
@Before
public void createTestWorkflow() throws Exception {
// define indices
indexDAO.setup();
// initialize workflow
workflow = new Workflow();
workflow.getInput().put("requestId", "request id 001");
workflow.getInput().put("hasAwards", true);
workflow.getInput().put("channelMapping", 5);
Map<String, Object> name = new HashMap<>();
name.put("name", "The Who");
name.put("year", 1970);
Map<String, Object> name2 = new HashMap<>();
name2.put("name", "The Doors");
name2.put("year", 1975);
List<Object> names = new LinkedList<>();
names.add(name);
names.add(name2);
workflow.getOutput().put("name", name);
workflow.getOutput().put("names", names);
workflow.getOutput().put("awards", 200);
Task task = new Task();
task.setReferenceTaskName("task2");
task.getOutputData().put("location", "http://location");
task.setStatus(Task.Status.COMPLETED);
Task task2 = new Task();
task2.setReferenceTaskName("task3");
task2.getOutputData().put("refId", "abcddef_1234_7890_aaffcc");
task2.setStatus(Task.Status.SCHEDULED);
workflow.getTasks().add(task);
workflow.getTasks().add(task2);
}
use of com.netflix.conductor.common.metadata.tasks.Task in project conductor by Netflix.
the class TestElasticSearchDAOV5 method indexTaskWithBatchSizeTwo.
@Test
public void indexTaskWithBatchSizeTwo() throws Exception {
embeddedElasticSearch.stop();
startElasticSearchWithBatchSize(2);
String correlationId = "some-correlation-id";
Task task = new Task();
task.setTaskId("some-task-id");
task.setWorkflowInstanceId("some-workflow-instance-id");
task.setTaskType("some-task-type");
task.setStatus(Status.FAILED);
task.setInputData(new HashMap<String, Object>() {
{
put("input_key", "input_value");
}
});
task.setCorrelationId(correlationId);
task.setTaskDefName("some-task-def-name");
task.setReasonForIncompletion("some-failure-reason");
indexDAO.indexTask(task);
indexDAO.indexTask(task);
await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
SearchResult<String> result = indexDAO.searchTasks("correlationId='" + correlationId + "'", "*", 0, 10000, null);
assertTrue("should return 1 or more search results", result.getResults().size() > 0);
assertEquals("taskId should match the indexed task", "some-task-id", result.getResults().get(0));
});
embeddedElasticSearch.stop();
startElasticSearchWithBatchSize(1);
}
use of com.netflix.conductor.common.metadata.tasks.Task in project conductor by Netflix.
the class WorkflowExecutor method resetCallbacksForWorkflow.
/**
* @param workflowId the id of the workflow for which task callbacks are to be reset
* @throws ApplicationException if the workflow is in terminal state
*/
public void resetCallbacksForWorkflow(String workflowId) {
Workflow workflow = executionDAOFacade.getWorkflowById(workflowId, true);
if (workflow.getStatus().isTerminal()) {
throw new ApplicationException(CONFLICT, "Workflow is in terminal state. Status =" + workflow.getStatus());
}
// Get SIMPLE tasks in SCHEDULED state that have callbackAfterSeconds > 0 and set the callbackAfterSeconds to 0
workflow.getTasks().stream().filter(task -> !isSystemTask.test(task) && SCHEDULED.equals(task.getStatus()) && task.getCallbackAfterSeconds() > 0).forEach(task -> {
if (queueDAO.resetOffsetTime(QueueUtils.getQueueName(task), task.getTaskId())) {
task.setCallbackAfterSeconds(0);
executionDAOFacade.updateTask(task);
}
});
}
Aggregations