Search in sources :

Example 1 with HANDLERS_KEY

use of com.netflix.conductor.util.Constants.HANDLERS_KEY 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);
    }
}
Also used : Row(com.datastax.driver.core.Row) LoggerFactory(org.slf4j.LoggerFactory) EVENT_HANDLER_KEY(com.netflix.conductor.util.Constants.EVENT_HANDLER_KEY) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) PreparedStatement(com.datastax.driver.core.PreparedStatement) Inject(javax.inject.Inject) CassandraConfiguration(com.netflix.conductor.cassandra.CassandraConfiguration) ResultSet(com.datastax.driver.core.ResultSet) Session(com.datastax.driver.core.Session) Map(java.util.Map) Code(com.netflix.conductor.core.execution.ApplicationException.Code) ApplicationException(com.netflix.conductor.core.execution.ApplicationException) Logger(org.slf4j.Logger) Trace(com.netflix.conductor.annotations.Trace) EventHandlerDAO(com.netflix.conductor.dao.EventHandlerDAO) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) EventHandler(com.netflix.conductor.common.metadata.events.EventHandler) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) Monitors(com.netflix.conductor.metrics.Monitors) TimeUnit(java.util.concurrent.TimeUnit) HANDLERS_KEY(com.netflix.conductor.util.Constants.HANDLERS_KEY) List(java.util.List) Statements(com.netflix.conductor.util.Statements) Collections(java.util.Collections) ApplicationException(com.netflix.conductor.core.execution.ApplicationException) ResultSet(com.datastax.driver.core.ResultSet) Row(com.datastax.driver.core.Row) ApplicationException(com.netflix.conductor.core.execution.ApplicationException)

Aggregations

PreparedStatement (com.datastax.driver.core.PreparedStatement)1 ResultSet (com.datastax.driver.core.ResultSet)1 Row (com.datastax.driver.core.Row)1 Session (com.datastax.driver.core.Session)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Trace (com.netflix.conductor.annotations.Trace)1 CassandraConfiguration (com.netflix.conductor.cassandra.CassandraConfiguration)1 EventHandler (com.netflix.conductor.common.metadata.events.EventHandler)1 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)1 Code (com.netflix.conductor.core.execution.ApplicationException.Code)1 EventHandlerDAO (com.netflix.conductor.dao.EventHandlerDAO)1 Monitors (com.netflix.conductor.metrics.Monitors)1 EVENT_HANDLER_KEY (com.netflix.conductor.util.Constants.EVENT_HANDLER_KEY)1 HANDLERS_KEY (com.netflix.conductor.util.Constants.HANDLERS_KEY)1 Statements (com.netflix.conductor.util.Statements)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1