Search in sources :

Example 66 with ApplicationException

use of com.netflix.conductor.core.execution.ApplicationException 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());
    });
}
Also used : ApplicationException(com.netflix.conductor.core.execution.ApplicationException) EventHandler(com.netflix.conductor.common.metadata.events.EventHandler)

Example 67 with ApplicationException

use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.

the class Query method executeUpdate.

/**
 * @return The result of {@link PreparedStatement#executeUpdate()}
 */
public int executeUpdate() {
    try {
        Long start = null;
        if (logger.isTraceEnabled()) {
            start = System.currentTimeMillis();
        }
        final int val = this.statement.executeUpdate();
        if (null != start && logger.isTraceEnabled()) {
            long end = System.currentTimeMillis();
            logger.trace("[{}ms] {}: {}", (end - start), val, rawQuery);
        }
        return val;
    } catch (SQLException ex) {
        throw new ApplicationException(Code.BACKEND_ERROR, ex.getMessage(), ex);
    }
}
Also used : ApplicationException(com.netflix.conductor.core.execution.ApplicationException) SQLException(java.sql.SQLException)

Example 68 with ApplicationException

use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.

the class RedisExecutionDAO method removeEventExecution.

@Override
public void removeEventExecution(EventExecution eventExecution) {
    try {
        String key = nsKey(EVENT_EXECUTION, eventExecution.getName(), eventExecution.getEvent(), eventExecution.getMessageId());
        logger.info("removing event execution {}", key);
        dynoClient.hdel(key, eventExecution.getId());
        recordRedisDaoEventRequests("removeEventExecution", eventExecution.getEvent());
    } catch (Exception e) {
        throw new ApplicationException(Code.BACKEND_ERROR, "Unable to remove event execution for " + eventExecution.getId(), e);
    }
}
Also used : ApplicationException(com.netflix.conductor.core.execution.ApplicationException) ApplicationException(com.netflix.conductor.core.execution.ApplicationException)

Example 69 with ApplicationException

use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.

the class RedisExecutionDAO method validate.

/**
 * @param task
 * @throws ApplicationException
 */
private void validate(Task task) {
    try {
        Preconditions.checkNotNull(task, "task object cannot be null");
        Preconditions.checkNotNull(task.getTaskId(), "Task id cannot be null");
        Preconditions.checkNotNull(task.getWorkflowInstanceId(), "Workflow instance id cannot be null");
        Preconditions.checkNotNull(task.getReferenceTaskName(), "Task reference name cannot be null");
    } catch (NullPointerException npe) {
        throw new ApplicationException(Code.INVALID_INPUT, npe.getMessage(), npe);
    }
}
Also used : ApplicationException(com.netflix.conductor.core.execution.ApplicationException)

Example 70 with ApplicationException

use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.

the class RedisExecutionDAO method getEventExecutions.

public List<EventExecution> getEventExecutions(String eventHandlerName, String eventName, String messageId, int max) {
    try {
        String key = nsKey(EVENT_EXECUTION, eventHandlerName, eventName, messageId);
        logger.info("getting event execution {}", key);
        List<EventExecution> executions = new LinkedList<>();
        for (int i = 0; i < max; i++) {
            String field = messageId + "_" + i;
            String value = dynoClient.hget(key, field);
            if (value == null) {
                break;
            }
            recordRedisDaoEventRequests("getEventExecution", eventHandlerName);
            recordRedisDaoPayloadSize("getEventExecution", value.length(), eventHandlerName, "n/a");
            EventExecution eventExecution = objectMapper.readValue(value, EventExecution.class);
            executions.add(eventExecution);
        }
        return executions;
    } catch (Exception e) {
        throw new ApplicationException(Code.BACKEND_ERROR, "Unable to get event executions for " + eventHandlerName, e);
    }
}
Also used : ApplicationException(com.netflix.conductor.core.execution.ApplicationException) EventExecution(com.netflix.conductor.common.metadata.events.EventExecution) LinkedList(java.util.LinkedList) ApplicationException(com.netflix.conductor.core.execution.ApplicationException)

Aggregations

ApplicationException (com.netflix.conductor.core.execution.ApplicationException)93 Task (com.netflix.conductor.common.metadata.tasks.Task)22 Workflow (com.netflix.conductor.common.run.Workflow)22 HashMap (java.util.HashMap)19 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)16 IOException (java.io.IOException)16 Map (java.util.Map)15 ArrayList (java.util.ArrayList)14 List (java.util.List)14 Inject (javax.inject.Inject)14 Singleton (javax.inject.Singleton)14 Logger (org.slf4j.Logger)14 LoggerFactory (org.slf4j.LoggerFactory)14 Trace (com.netflix.conductor.annotations.Trace)13 EventExecution (com.netflix.conductor.common.metadata.events.EventExecution)13 Monitors (com.netflix.conductor.metrics.Monitors)13 Collectors (java.util.stream.Collectors)13 ResultSet (com.datastax.driver.core.ResultSet)12 EventHandler (com.netflix.conductor.common.metadata.events.EventHandler)12 TimeUnit (java.util.concurrent.TimeUnit)12