use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.
the class CassandraMetadataDAO method removeTaskDef.
@Override
public void removeTaskDef(String name) {
try {
recordCassandraDaoRequests("removeTaskDef");
session.execute(deleteTaskDefStatement.bind(name));
} catch (Exception e) {
Monitors.error(CLASS_NAME, "removeTaskDef");
String errorMsg = String.format("Failed to remove task definition: %s", name);
LOGGER.error(errorMsg, e);
throw new ApplicationException(Code.BACKEND_ERROR, errorMsg, e);
}
refreshTaskDefsCache();
}
use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.
the class CassandraMetadataDAO method createWorkflowDef.
@Override
public void createWorkflowDef(WorkflowDef workflowDef) {
try {
String workflowDefinition = toJson(workflowDef);
if (!session.execute(insertWorkflowDefStatement.bind(workflowDef.getName(), workflowDef.getVersion(), workflowDefinition)).wasApplied()) {
throw new ApplicationException(Code.CONFLICT, String.format("Workflow: %s, version: %s already exists!", workflowDef.getName(), workflowDef.getVersion()));
}
String workflowDefIndex = getWorkflowDefIndexValue(workflowDef.getName(), workflowDef.getVersion());
session.execute(insertWorkflowDefVersionIndexStatement.bind(workflowDefIndex, workflowDefIndex));
recordCassandraDaoRequests("createWorkflowDef");
recordCassandraDaoPayloadSize("createWorkflowDef", workflowDefinition.length(), "n/a", workflowDef.getName());
} catch (ApplicationException ae) {
throw ae;
} catch (Exception e) {
Monitors.error(CLASS_NAME, "createWorkflowDef");
String errorMsg = String.format("Error creating workflow definition: %s/%d", workflowDef.getName(), workflowDef.getVersion());
LOGGER.error(errorMsg, e);
throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, errorMsg, e);
}
}
use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.
the class CassandraMetadataDAO method getAllWorkflowDefVersions.
private List<WorkflowDef> getAllWorkflowDefVersions(String name) {
try {
ResultSet resultSet = session.execute(selectAllWorkflowDefVersionsByNameStatement.bind(name));
recordCassandraDaoRequests("getAllWorkflowDefVersions", "n/a", name);
List<Row> rows = resultSet.all();
if (rows.size() == 0) {
LOGGER.info("Not workflow definitions were found for : {}", name);
return null;
}
return rows.stream().map(row -> readValue(row.getString(WORKFLOW_DEFINITION_KEY), WorkflowDef.class)).collect(Collectors.toList());
} catch (Exception e) {
Monitors.error(CLASS_NAME, "getAllWorkflowDefVersions");
String errorMsg = String.format("Failed to get workflows defs for : %s", name);
LOGGER.error(errorMsg, e);
throw new ApplicationException(Code.BACKEND_ERROR, errorMsg, e);
}
}
Aggregations