use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.
the class TestWorkflowExecutor method testTaskToDomain.
@Test
public void testTaskToDomain() {
Workflow workflow = generateSampleWorkflow();
List<Task> tasks = generateSampleTasks(3);
Map<String, String> taskToDomain = new HashMap<>();
taskToDomain.put("*", "mydomain");
workflow.setTaskToDomain(taskToDomain);
PollData pollData1 = new PollData("queue1", "mydomain", "worker1", System.currentTimeMillis() - 99 * 100);
when(executionDAOFacade.getTaskPollDataByDomain(anyString(), anyString())).thenReturn(pollData1);
workflowExecutor.setTaskDomains(tasks, workflow);
assertNotNull(tasks);
tasks.forEach(task -> assertEquals("mydomain", task.getDomain()));
}
use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.
the class TestWorkflowExecutor method testInactiveDomains.
@Test
public void testInactiveDomains() {
String taskType = "test-task";
String[] domains = new String[] { "domain1", "domain2" };
PollData pollData1 = new PollData("queue1", domains[0], "worker1", System.currentTimeMillis() - 99 * 10000);
when(executionDAOFacade.getTaskPollDataByDomain(taskType, domains[0])).thenReturn(pollData1);
when(executionDAOFacade.getTaskPollDataByDomain(taskType, domains[1])).thenReturn(null);
String activeDomain = workflowExecutor.getActiveDomain(taskType, domains);
assertEquals("domain2", activeDomain);
}
use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.
the class TestWorkflowExecutor method testTaskToDomainsPerTask.
@Test
public void testTaskToDomainsPerTask() {
Workflow workflow = generateSampleWorkflow();
List<Task> tasks = generateSampleTasks(2);
Map<String, String> taskToDomain = new HashMap<>();
taskToDomain.put("*", "mydomain, NO_DOMAIN");
workflow.setTaskToDomain(taskToDomain);
PollData pollData1 = new PollData("queue1", "mydomain", "worker1", System.currentTimeMillis() - 99 * 100);
when(executionDAOFacade.getTaskPollDataByDomain(eq("task1"), anyString())).thenReturn(pollData1);
when(executionDAOFacade.getTaskPollDataByDomain(eq("task2"), anyString())).thenReturn(null);
workflowExecutor.setTaskDomains(tasks, workflow);
assertEquals("mydomain", tasks.get(0).getDomain());
assertNull(tasks.get(1).getDomain());
}
use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.
the class MySQLExecutionDAO method updateLastPollData.
@Override
public void updateLastPollData(String taskDefName, String domain, String workerId) {
Preconditions.checkNotNull(taskDefName, "taskDefName name cannot be null");
PollData pollData = new PollData(taskDefName, domain, workerId, System.currentTimeMillis());
String effectiveDomain = (domain == null) ? "DEFAULT" : domain;
withTransaction(tx -> insertOrUpdatePollData(tx, pollData, effectiveDomain));
}
use of com.netflix.conductor.common.metadata.tasks.PollData in project conductor by Netflix.
the class TaskResourceTest method testGetAllPollData.
@Test
public void testGetAllPollData() {
PollData pollData = new PollData("queue", "test", "w123", 100);
List<PollData> listOfPollData = new ArrayList<>();
listOfPollData.add(pollData);
when(mockTaskService.getAllPollData()).thenReturn(listOfPollData);
assertEquals(listOfPollData, taskResource.getAllPollData());
}
Aggregations