use of com.netflix.conductor.common.metadata.events.EventHandler in project conductor by Netflix.
the class MySQLMetadataDAO method removeEventHandler.
@Override
public void removeEventHandler(String name) {
final String DELETE_EVENT_HANDLER_QUERY = "DELETE FROM meta_event_handler WHERE name = ?";
withTransaction(tx -> {
EventHandler existing = getEventHandler(tx, name);
if (existing == null) {
throw new ApplicationException(ApplicationException.Code.NOT_FOUND, "EventHandler with name " + name + " not found!");
}
execute(tx, DELETE_EVENT_HANDLER_QUERY, q -> q.addParameter(name).executeDelete());
});
}
use of com.netflix.conductor.common.metadata.events.EventHandler in project conductor by Netflix.
the class EventResourceTest method testGetEventHandlers.
@Test
public void testGetEventHandlers() {
EventHandler eventHandler = new EventHandler();
eventResource.addEventHandler(eventHandler);
List<EventHandler> listOfEventHandler = new ArrayList<>();
listOfEventHandler.add(eventHandler);
when(mockEventService.getEventHandlers()).thenReturn(listOfEventHandler);
assertEquals(listOfEventHandler, eventResource.getEventHandlers());
}
use of com.netflix.conductor.common.metadata.events.EventHandler in project conductor by Netflix.
the class PostgresMetadataDAOTest method testEventHandlers.
@Test
public void testEventHandlers() {
String event1 = "SQS::arn:account090:sqstest1";
String event2 = "SQS::arn:account090:sqstest2";
EventHandler eh = new EventHandler();
eh.setName(UUID.randomUUID().toString());
eh.setActive(false);
EventHandler.Action action = new EventHandler.Action();
action.setAction(EventHandler.Action.Type.start_workflow);
action.setStart_workflow(new EventHandler.StartWorkflow());
action.getStart_workflow().setName("workflow_x");
eh.getActions().add(action);
eh.setEvent(event1);
dao.addEventHandler(eh);
List<EventHandler> all = dao.getAllEventHandlers();
assertNotNull(all);
assertEquals(1, all.size());
assertEquals(eh.getName(), all.get(0).getName());
assertEquals(eh.getEvent(), all.get(0).getEvent());
List<EventHandler> byEvents = dao.getEventHandlersForEvent(event1, true);
assertNotNull(byEvents);
// event is marked as in-active
assertEquals(0, byEvents.size());
eh.setActive(true);
eh.setEvent(event2);
dao.updateEventHandler(eh);
all = dao.getAllEventHandlers();
assertNotNull(all);
assertEquals(1, all.size());
byEvents = dao.getEventHandlersForEvent(event1, true);
assertNotNull(byEvents);
assertEquals(0, byEvents.size());
byEvents = dao.getEventHandlersForEvent(event2, true);
assertNotNull(byEvents);
assertEquals(1, byEvents.size());
}
use of com.netflix.conductor.common.metadata.events.EventHandler in project conductor by Netflix.
the class RedisEventHandlerDAO method removeEventHandler.
@Override
public void removeEventHandler(String name) {
EventHandler existing = getEventHandler(name);
if (existing == null) {
throw new ApplicationException(Code.NOT_FOUND, "EventHandler with name " + name + " not found!");
}
dynoClient.hdel(nsKey(EVENT_HANDLERS), name);
recordRedisDaoRequests("removeEventHandler");
removeIndex(existing);
}
use of com.netflix.conductor.common.metadata.events.EventHandler in project conductor by Netflix.
the class CassandraEventHandlerDAO method getAllEventHandlersFromDB.
@SuppressWarnings("unchecked")
private List<EventHandler> getAllEventHandlersFromDB() {
try {
ResultSet resultSet = session.execute(selectAllEventHandlersStatement.bind(HANDLERS_KEY));
List<Row> rows = resultSet.all();
if (rows.size() == 0) {
LOGGER.info("No event handlers were found.");
return Collections.EMPTY_LIST;
}
return rows.stream().map(row -> readValue(row.getString(EVENT_HANDLER_KEY), EventHandler.class)).collect(Collectors.toList());
} catch (Exception e) {
Monitors.error(CLASS_NAME, "getAllEventHandlersFromDB");
String errorMsg = "Failed to get all event handlers";
LOGGER.error(errorMsg, e);
throw new ApplicationException(Code.BACKEND_ERROR, errorMsg, e);
}
}
Aggregations