use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.
the class ExecutionDAOFacadeTest method testAddEventExecution.
@Test
public void testAddEventExecution() {
when(executionDAO.addEventExecution(any())).thenReturn(false);
boolean added = executionDAOFacade.addEventExecution(new EventExecution());
assertFalse(added);
verify(indexDAO, never()).addEventExecution(any());
when(executionDAO.addEventExecution(any())).thenReturn(true);
added = executionDAOFacade.addEventExecution(new EventExecution());
assertTrue(added);
verify(indexDAO, times(1)).asyncAddEventExecution(any());
}
use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.
the class PostgresExecutionDAO method getEventExecutions.
public List<EventExecution> getEventExecutions(String eventHandlerName, String eventName, String messageId, int max) {
try {
List<EventExecution> executions = Lists.newLinkedList();
withTransaction(tx -> {
for (int i = 0; i < max; i++) {
// see SimpleEventProcessor.handle to understand how the
String executionId = messageId + "_" + i;
// execution id is set
EventExecution ee = readEventExecution(tx, eventHandlerName, eventName, messageId, executionId);
if (ee == null) {
break;
}
executions.add(ee);
}
});
return executions;
} catch (Exception e) {
String message = String.format("Unable to get event executions for eventHandlerName=%s, eventName=%s, messageId=%s", eventHandlerName, eventName, messageId);
throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, message, e);
}
}
use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.
the class MySQLExecutionDAO method getEventExecutions.
public List<EventExecution> getEventExecutions(String eventHandlerName, String eventName, String messageId, int max) {
try {
List<EventExecution> executions = Lists.newLinkedList();
withTransaction(tx -> {
for (int i = 0; i < max; i++) {
// see SimpleEventProcessor.handle to understand how the
String executionId = messageId + "_" + i;
// execution id is set
EventExecution ee = readEventExecution(tx, eventHandlerName, eventName, messageId, executionId);
if (ee == null) {
break;
}
executions.add(ee);
}
});
return executions;
} catch (Exception e) {
String message = String.format("Unable to get event executions for eventHandlerName=%s, eventName=%s, messageId=%s", eventHandlerName, eventName, messageId);
throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, message, e);
}
}
use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.
the class TestSimpleEventProcessor method testExecuteRetriableApplicationException.
@Test
public void testExecuteRetriableApplicationException() {
AtomicInteger executeInvoked = new AtomicInteger(0);
doAnswer((Answer<Map<String, Object>>) invocation -> {
executeInvoked.incrementAndGet();
throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, "some retriable error");
}).when(actionProcessor).execute(any(), any(), any(), any());
SimpleEventProcessor eventProcessor = new SimpleEventProcessor(executionService, metadataService, actionProcessor, eventQueues, jsonUtils, new TestConfiguration(), objectMapper);
EventExecution eventExecution = new EventExecution("id", "messageId");
eventExecution.setStatus(EventExecution.Status.IN_PROGRESS);
eventExecution.setEvent("event");
Action action = new Action();
action.setAction(Type.start_workflow);
eventProcessor.execute(eventExecution, action, "payload");
assertEquals(3, executeInvoked.get());
assertNull(eventExecution.getOutput().get("exception"));
}
use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.
the class TestSimpleEventProcessor method testExecuteInvalidAction.
@SuppressWarnings("unchecked")
@Test
public void testExecuteInvalidAction() {
AtomicInteger executeInvoked = new AtomicInteger(0);
doAnswer((Answer<Map<String, Object>>) invocation -> {
executeInvoked.incrementAndGet();
throw new UnsupportedOperationException("error");
}).when(actionProcessor).execute(any(), any(), any(), any());
SimpleEventProcessor eventProcessor = new SimpleEventProcessor(executionService, metadataService, actionProcessor, eventQueues, jsonUtils, new TestConfiguration(), objectMapper);
EventExecution eventExecution = new EventExecution("id", "messageId");
eventExecution.setName("handler");
eventExecution.setStatus(EventExecution.Status.IN_PROGRESS);
eventExecution.setEvent("event");
Action action = new Action();
eventExecution.setAction(Type.start_workflow);
eventProcessor.execute(eventExecution, action, "payload");
assertEquals(1, executeInvoked.get());
assertEquals(EventExecution.Status.FAILED, eventExecution.getStatus());
assertNotNull(eventExecution.getOutput().get("exception"));
}
Aggregations