use of com.netflix.conductor.core.events.queue.ObservableQueue in project conductor by Netflix.
the class ContribsModule method getQueues.
@Provides
public Map<Status, ObservableQueue> getQueues(Configuration config, AWSCredentialsProvider acp) {
String stack = "";
if (config.getStack() != null && config.getStack().length() > 0) {
stack = config.getStack() + "_";
}
Status[] statuses = new Status[] { Status.COMPLETED, Status.FAILED };
Map<Status, ObservableQueue> queues = new HashMap<>();
for (Status status : statuses) {
String queueName = config.getProperty("workflow.listener.queue.prefix", config.getAppId() + "_sqs_notify_" + stack + status.name());
AmazonSQSClient client = new AmazonSQSClient(acp);
Builder builder = new SQSObservableQueue.Builder().withClient(client).withQueueName(queueName);
String auth = config.getProperty("workflow.listener.queue.authorizedAccounts", "");
String[] accounts = auth.split(",");
for (String accountToAuthorize : accounts) {
accountToAuthorize = accountToAuthorize.trim();
if (accountToAuthorize.length() > 0) {
builder.addAccountToAuthorize(accountToAuthorize.trim());
}
}
ObservableQueue queue = builder.build();
queues.put(status, queue);
}
return queues;
}
use of com.netflix.conductor.core.events.queue.ObservableQueue in project conductor by Netflix.
the class TestEvent method testSinkParam.
@Test
public void testSinkParam() {
String sink = "sqs:queue_name";
WorkflowDef def = new WorkflowDef();
def.setName("wf0");
Workflow workflow = new Workflow();
workflow.setWorkflowDefinition(def);
Task task1 = new Task();
task1.setReferenceTaskName("t1");
task1.getOutputData().put("q", "t1_queue");
workflow.getTasks().add(task1);
Task task2 = new Task();
task2.setReferenceTaskName("t2");
task2.getOutputData().put("q", "task2_queue");
workflow.getTasks().add(task2);
Task task = new Task();
task.setReferenceTaskName("event");
task.getInputData().put("sink", sink);
task.setTaskType(TaskType.EVENT.name());
workflow.getTasks().add(task);
Event event = new Event(eventQueues, parametersUtils, objectMapper);
ObservableQueue queue = event.getQueue(workflow, task);
assertNotNull(task.getReasonForIncompletion(), queue);
assertEquals("queue_name", queue.getName());
assertEquals("sqs", queue.getType());
sink = "sqs:${t1.output.q}";
task.getInputData().put("sink", sink);
queue = event.getQueue(workflow, task);
assertNotNull(queue);
assertEquals("t1_queue", queue.getName());
assertEquals("sqs", queue.getType());
System.out.println(task.getOutputData().get("event_produced"));
sink = "sqs:${t2.output.q}";
task.getInputData().put("sink", sink);
queue = event.getQueue(workflow, task);
assertNotNull(queue);
assertEquals("task2_queue", queue.getName());
assertEquals("sqs", queue.getType());
System.out.println(task.getOutputData().get("event_produced"));
sink = "conductor";
task.getInputData().put("sink", sink);
queue = event.getQueue(workflow, task);
assertNotNull(queue);
assertEquals(workflow.getWorkflowName() + ":" + task.getReferenceTaskName(), queue.getName());
assertEquals("conductor", queue.getType());
System.out.println(task.getOutputData().get("event_produced"));
sink = "sqs:static_value";
task.getInputData().put("sink", sink);
queue = event.getQueue(workflow, task);
assertNotNull(queue);
assertEquals("static_value", queue.getName());
assertEquals("sqs", queue.getType());
assertEquals(sink, task.getOutputData().get("event_produced"));
System.out.println(task.getOutputData().get("event_produced"));
sink = "bad:queue";
task.getInputData().put("sink", sink);
queue = event.getQueue(workflow, task);
assertNull(queue);
assertEquals(Task.Status.FAILED, task.getStatus());
}
use of com.netflix.conductor.core.events.queue.ObservableQueue in project conductor by Netflix.
the class TestEvent method testDynamicSinks.
@Test
public void testDynamicSinks() {
Event event = new Event(eventQueues, parametersUtils, objectMapper);
Workflow workflow = new Workflow();
workflow.setWorkflowDefinition(testWorkflowDefinition);
Task task = new Task();
task.setReferenceTaskName("task0");
task.setTaskId("task_id_0");
task.setStatus(Status.IN_PROGRESS);
task.getInputData().put("sink", "conductor:some_arbitary_queue");
ObservableQueue queue = event.getQueue(workflow, task);
assertEquals(Task.Status.IN_PROGRESS, task.getStatus());
assertNotNull(queue);
assertEquals("testWorkflow:some_arbitary_queue", queue.getName());
assertEquals("testWorkflow:some_arbitary_queue", queue.getURI());
assertEquals("conductor", queue.getType());
assertEquals("conductor:testWorkflow:some_arbitary_queue", task.getOutputData().get("event_produced"));
task.getInputData().put("sink", "conductor");
queue = event.getQueue(workflow, task);
assertEquals("not in progress: " + task.getReasonForIncompletion(), Task.Status.IN_PROGRESS, task.getStatus());
assertNotNull(queue);
assertEquals("testWorkflow:task0", queue.getName());
task.getInputData().put("sink", "sqs:my_sqs_queue_name");
queue = event.getQueue(workflow, task);
assertEquals("not in progress: " + task.getReasonForIncompletion(), Task.Status.IN_PROGRESS, task.getStatus());
assertNotNull(queue);
assertEquals("my_sqs_queue_name", queue.getName());
assertEquals("sqs", queue.getType());
task.getInputData().put("sink", "sns:my_sqs_queue_name");
queue = event.getQueue(workflow, task);
assertEquals(Task.Status.FAILED, task.getStatus());
}
use of com.netflix.conductor.core.events.queue.ObservableQueue in project conductor by Netflix.
the class AMQPEventQueueProviderTest method testAMQPEventQueueProvider_defaultconfig_queue.
@Test
public void testAMQPEventQueueProvider_defaultconfig_queue() {
String exchangestring = "amqp_queue:myQueueName?deliveryMode=2&durable=false&autoDelete=true&exclusive=true";
Mockito.when(config.getProperty(Mockito.anyString(), Mockito.anyString())).thenAnswer(invocation -> invocation.getArgument(1));
Mockito.when(config.getBooleanProperty(Mockito.anyString(), Mockito.anyBoolean())).thenAnswer(invocation -> invocation.getArgument(1));
Mockito.when(config.getIntProperty(Mockito.anyString(), Mockito.anyInt())).thenAnswer(invocation -> invocation.getArgument(1));
AMQPEventQueueProvider eventqProvider = new AMQPEventQueueProvider(config, false);
ObservableQueue queue = eventqProvider.getQueue(exchangestring);
Assert.assertNotNull(queue);
Assert.assertEquals(exchangestring, queue.getName());
Assert.assertEquals(AMQPConstants.AMQP_QUEUE_TYPE, queue.getType());
}
use of com.netflix.conductor.core.events.queue.ObservableQueue in project conductor by Netflix.
the class TestQueueManager method testFailure.
@Test(expected = IllegalArgumentException.class)
public void testFailure() throws Exception {
Map<Status, ObservableQueue> queues = new HashMap<>();
queues.put(Status.COMPLETED, queue);
QueueManager qm = new QueueManager(queues, es, objectMapper);
qm.updateByTaskRefName("v_1", "t1", new HashMap<>(), Status.CANCELED);
Uninterruptibles.sleepUninterruptibly(1_000, TimeUnit.MILLISECONDS);
}
Aggregations