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());
});
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations