use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.
the class CassandraEventHandlerDAO method insertOrUpdateEventHandler.
private void insertOrUpdateEventHandler(EventHandler eventHandler) {
try {
String handler = toJson(eventHandler);
session.execute(insertEventHandlerStatement.bind(eventHandler.getName(), handler));
recordCassandraDaoRequests("storeEventHandler");
recordCassandraDaoPayloadSize("storeEventHandler", handler.length(), "n/a", "n/a");
} catch (Exception e) {
Monitors.error(CLASS_NAME, "insertOrUpdateEventHandler");
String errorMsg = String.format("Error creating/updating event handler: %s/%s", eventHandler.getName(), eventHandler.getEvent());
LOGGER.error(errorMsg, e);
throw new ApplicationException(Code.BACKEND_ERROR, errorMsg, e);
}
refreshEventHandlersCache();
}
use of com.netflix.conductor.core.execution.ApplicationException 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);
}
}
use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.
the class CassandraExecutionDAO method getWorkflowMetadata.
@VisibleForTesting
WorkflowMetadata getWorkflowMetadata(String workflowId) {
ResultSet resultSet = session.execute(selectTotalStatement.bind(UUID.fromString(workflowId)));
recordCassandraDaoRequests("getWorkflowMetadata");
return Optional.ofNullable(resultSet.one()).map(row -> {
WorkflowMetadata workflowMetadata = new WorkflowMetadata();
workflowMetadata.setTotalTasks(row.getInt(TOTAL_TASKS_KEY));
workflowMetadata.setTotalPartitions(row.getInt(TOTAL_PARTITIONS_KEY));
return workflowMetadata;
}).orElseThrow(() -> new ApplicationException(Code.NOT_FOUND, String.format("Workflow with id: %s not found in data store", workflowId)));
}
use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.
the class CassandraExecutionDAO method exceedsInProgressLimit.
/**
* This is a dummy implementation and this feature is not implemented
* for Cassandra backed Conductor
*/
@Override
public boolean exceedsInProgressLimit(Task task) {
Optional<TaskDef> taskDefinition = task.getTaskDefinition();
if (!taskDefinition.isPresent()) {
return false;
}
int limit = taskDefinition.get().concurrencyLimit();
if (limit <= 0) {
return false;
}
try {
recordCassandraDaoRequests("selectTaskDefLimit", task.getTaskType(), task.getWorkflowType());
ResultSet resultSet = session.execute(selectTasksFromTaskDefLimitStatement.bind(task.getTaskDefName()));
List<String> taskIds = resultSet.all().stream().map(row -> row.getUUID(TASK_ID_KEY).toString()).collect(Collectors.toList());
long current = taskIds.size();
if (!taskIds.contains(task.getTaskId()) && current >= limit) {
LOGGER.info("Task execution count limited. task - {}:{}, limit: {}, current: {}", task.getTaskId(), task.getTaskDefName(), limit, current);
Monitors.recordTaskConcurrentExecutionLimited(task.getTaskDefName(), limit);
return true;
}
} catch (Exception e) {
Monitors.error(CLASS_NAME, "exceedsInProgressLimit");
String errorMsg = String.format("Failed to get in progress limit - %s:%s in workflow :%s", task.getTaskDefName(), task.getTaskId(), task.getWorkflowInstanceId());
LOGGER.error(errorMsg, e);
throw new ApplicationException(Code.BACKEND_ERROR, errorMsg);
}
return false;
}
use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.
the class CassandraExecutionDAO method removeEventExecution.
@Override
public void removeEventExecution(EventExecution eventExecution) {
try {
recordCassandraDaoEventRequests("removeEventExecution", eventExecution.getEvent());
session.execute(deleteEventExecutionStatement.bind(eventExecution.getMessageId(), eventExecution.getName(), eventExecution.getId()));
} catch (Exception e) {
Monitors.error(CLASS_NAME, "removeEventExecution");
String errorMsg = String.format("Failed to remove event execution for event: %s, handler: %s", eventExecution.getEvent(), eventExecution.getName());
LOGGER.error(errorMsg, e);
throw new ApplicationException(Code.BACKEND_ERROR, errorMsg);
}
}
Aggregations