use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.
the class CassandraDAOTest method testInvalid.
@Test
public void testInvalid() {
Task task = null;
String id = "invalid_id";
try {
task = executionDAO.getTask(id);
} catch (ApplicationException e) {
assertEquals(INVALID_INPUT, e.getCode());
}
assertNull(task);
Workflow workflow = null;
try {
workflow = executionDAO.getWorkflow(id, true);
} catch (ApplicationException e) {
assertEquals(INVALID_INPUT, e.getCode());
}
assertNull(workflow);
id = IDGenerator.generate();
task = executionDAO.getTask(id);
assertNull(task);
workflow = executionDAO.getWorkflow(id, true);
assertNull(workflow);
}
use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.
the class CassandraMetadataDAO method updateWorkflowDef.
@Override
public void updateWorkflowDef(WorkflowDef workflowDef) {
try {
String workflowDefinition = toJson(workflowDef);
session.execute(updateWorkflowDefStatement.bind(workflowDefinition, workflowDef.getName(), workflowDef.getVersion()));
String workflowDefIndex = getWorkflowDefIndexValue(workflowDef.getName(), workflowDef.getVersion());
session.execute(insertWorkflowDefVersionIndexStatement.bind(workflowDefIndex, workflowDefIndex));
recordCassandraDaoRequests("updateWorkflowDef");
recordCassandraDaoPayloadSize("updateWorkflowDef", workflowDefinition.length(), "n/a", workflowDef.getName());
} catch (Exception e) {
Monitors.error(CLASS_NAME, "updateWorkflowDef");
String errorMsg = String.format("Error updating 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 getAllWorkflowDefs.
@SuppressWarnings("unchecked")
@Override
public List<WorkflowDef> getAllWorkflowDefs() {
try {
ResultSet resultSet = session.execute(selectAllWorkflowDefsStatement.bind(WORKFLOW_DEF_INDEX_KEY));
List<Row> rows = resultSet.all();
if (rows.size() == 0) {
LOGGER.info("No workflow definitions were found.");
return Collections.EMPTY_LIST;
}
return rows.stream().map(row -> {
String defNameVersion = row.getString(WORKFLOW_DEF_NAME_VERSION_KEY);
String[] tokens = defNameVersion.split(INDEX_DELIMITER);
return getWorkflowDef(tokens[0], Integer.parseInt(tokens[1])).orElse(null);
}).filter(Objects::nonNull).collect(Collectors.toList());
} catch (Exception e) {
Monitors.error(CLASS_NAME, "getAllWorkflowDefs");
String errorMsg = "Error retrieving all workflow defs";
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 CassandraMetadataDAO method insertOrUpdateTaskDef.
private String insertOrUpdateTaskDef(TaskDef taskDef) {
try {
String taskDefinition = toJson(taskDef);
session.execute(insertTaskDefStatement.bind(taskDef.getName(), taskDefinition));
recordCassandraDaoRequests("storeTaskDef");
recordCassandraDaoPayloadSize("storeTaskDef", taskDefinition.length(), taskDef.getName(), "n/a");
} catch (Exception e) {
Monitors.error(CLASS_NAME, "insertOrUpdateTaskDef");
String errorMsg = String.format("Error creating/updating task definition: %s", taskDef.getName());
LOGGER.error(errorMsg, e);
throw new ApplicationException(Code.BACKEND_ERROR, errorMsg, e);
}
refreshTaskDefsCache();
return taskDef.getName();
}
use of com.netflix.conductor.core.execution.ApplicationException in project conductor by Netflix.
the class CassandraMetadataDAO method getAllTaskDefsFromDB.
@SuppressWarnings("unchecked")
private List<TaskDef> getAllTaskDefsFromDB() {
try {
ResultSet resultSet = session.execute(selectAllTaskDefsStatement.bind(TASK_DEFS_KEY));
List<Row> rows = resultSet.all();
if (rows.size() == 0) {
LOGGER.info("No task definitions were found.");
return Collections.EMPTY_LIST;
}
return rows.stream().map(row -> readValue(row.getString(TASK_DEFINITION_KEY), TaskDef.class)).collect(Collectors.toList());
} catch (Exception e) {
Monitors.error(CLASS_NAME, "getAllTaskDefs");
String errorMsg = "Failed to get all task defs";
LOGGER.error(errorMsg, e);
throw new ApplicationException(Code.BACKEND_ERROR, errorMsg, e);
}
}
Aggregations