use of com.netflix.conductor.common.metadata.events.EventHandler in project conductor by Netflix.
the class PostgresMetadataDAO method updateEventHandler.
@Override
public void updateEventHandler(EventHandler eventHandler) {
Preconditions.checkNotNull(eventHandler.getName(), "EventHandler name cannot be null");
// @formatter:off
final String UPDATE_EVENT_HANDLER_QUERY = "UPDATE meta_event_handler SET " + "event = ?, active = ?, json_data = ?, " + "modified_on = CURRENT_TIMESTAMP WHERE name = ?";
// @formatter:on
withTransaction(tx -> {
EventHandler existing = getEventHandler(tx, eventHandler.getName());
if (existing == null) {
throw new ApplicationException(ApplicationException.Code.NOT_FOUND, "EventHandler with name " + eventHandler.getName() + " not found!");
}
execute(tx, UPDATE_EVENT_HANDLER_QUERY, q -> q.addParameter(eventHandler.getEvent()).addParameter(eventHandler.isActive()).addJsonParameter(eventHandler).addParameter(eventHandler.getName()).executeUpdate());
});
}
use of com.netflix.conductor.common.metadata.events.EventHandler in project conductor by Netflix.
the class PostgresMetadataDAO 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 RedisEventHandlerDAO method getEventHandlersForEvent.
@Override
public List<EventHandler> getEventHandlersForEvent(String event, boolean activeOnly) {
String key = nsKey(EVENT_HANDLERS_BY_EVENT, event);
Set<String> names = dynoClient.smembers(key);
List<EventHandler> handlers = new LinkedList<>();
for (String name : names) {
try {
EventHandler eventHandler = getEventHandler(name);
recordRedisDaoEventRequests("getEventHandler", event);
if (eventHandler.getEvent().equals(event) && (!activeOnly || eventHandler.isActive())) {
handlers.add(eventHandler);
}
} catch (ApplicationException ae) {
if (ae.getCode() == Code.NOT_FOUND) {
LOGGER.info("No matching event handler found for event: {}", event);
}
throw ae;
}
}
return handlers;
}
use of com.netflix.conductor.common.metadata.events.EventHandler in project conductor by Netflix.
the class RedisEventHandlerDAO method updateEventHandler.
@Override
public void updateEventHandler(EventHandler eventHandler) {
Preconditions.checkNotNull(eventHandler.getName(), "Missing Name");
EventHandler existing = getEventHandler(eventHandler.getName());
if (existing == null) {
throw new ApplicationException(Code.NOT_FOUND, "EventHandler with name " + eventHandler.getName() + " not found!");
}
index(eventHandler);
dynoClient.hset(nsKey(EVENT_HANDLERS), eventHandler.getName(), toJson(eventHandler));
recordRedisDaoRequests("updateEventHandler");
}
use of com.netflix.conductor.common.metadata.events.EventHandler in project conductor by Netflix.
the class RedisEventHandlerDAO method getAllEventHandlers.
@Override
public List<EventHandler> getAllEventHandlers() {
Map<String, String> all = dynoClient.hgetAll(nsKey(EVENT_HANDLERS));
List<EventHandler> handlers = new LinkedList<>();
all.forEach((key, json) -> {
EventHandler eventHandler = readValue(json, EventHandler.class);
handlers.add(eventHandler);
});
recordRedisDaoRequests("getAllEventHandlers");
return handlers;
}
Aggregations