Search in sources :

Example 1 with WORKFLOW_DEFINITION_KEY

use of com.netflix.conductor.util.Constants.WORKFLOW_DEFINITION_KEY in project conductor by Netflix.

the class CassandraMetadataDAO method getWorkflowDef.

@Override
public Optional<WorkflowDef> getWorkflowDef(String name, int version) {
    try {
        recordCassandraDaoRequests("getWorkflowDef");
        ResultSet resultSet = session.execute(selectWorkflowDefStatement.bind(name, version));
        WorkflowDef workflowDef = Optional.ofNullable(resultSet.one()).map(row -> readValue(row.getString(WORKFLOW_DEFINITION_KEY), WorkflowDef.class)).orElse(null);
        return Optional.ofNullable(workflowDef);
    } catch (Exception e) {
        Monitors.error(CLASS_NAME, "getTaskDef");
        String errorMsg = String.format("Error fetching workflow def: %s/%d", name, version);
        LOGGER.error(errorMsg, e);
        throw new ApplicationException(Code.BACKEND_ERROR, errorMsg, e);
    }
}
Also used : Row(com.datastax.driver.core.Row) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) MetadataDAO(com.netflix.conductor.dao.MetadataDAO) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) PreparedStatement(com.datastax.driver.core.PreparedStatement) Inject(javax.inject.Inject) CassandraConfiguration(com.netflix.conductor.cassandra.CassandraConfiguration) ResultSet(com.datastax.driver.core.ResultSet) Session(com.datastax.driver.core.Session) Map(java.util.Map) Code(com.netflix.conductor.core.execution.ApplicationException.Code) TASK_DEFINITION_KEY(com.netflix.conductor.util.Constants.TASK_DEFINITION_KEY) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) ApplicationException(com.netflix.conductor.core.execution.ApplicationException) Logger(org.slf4j.Logger) Trace(com.netflix.conductor.annotations.Trace) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) TASK_DEFS_KEY(com.netflix.conductor.util.Constants.TASK_DEFS_KEY) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) Monitors(com.netflix.conductor.metrics.Monitors) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) WORKFLOW_DEF_NAME_VERSION_KEY(com.netflix.conductor.util.Constants.WORKFLOW_DEF_NAME_VERSION_KEY) Statements(com.netflix.conductor.util.Statements) WORKFLOW_DEFINITION_KEY(com.netflix.conductor.util.Constants.WORKFLOW_DEFINITION_KEY) Optional(java.util.Optional) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Comparator(java.util.Comparator) WORKFLOW_DEF_INDEX_KEY(com.netflix.conductor.util.Constants.WORKFLOW_DEF_INDEX_KEY) Collections(java.util.Collections) ApplicationException(com.netflix.conductor.core.execution.ApplicationException) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) ResultSet(com.datastax.driver.core.ResultSet) ApplicationException(com.netflix.conductor.core.execution.ApplicationException)

Example 2 with WORKFLOW_DEFINITION_KEY

use of com.netflix.conductor.util.Constants.WORKFLOW_DEFINITION_KEY 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);
    }
}
Also used : Row(com.datastax.driver.core.Row) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) MetadataDAO(com.netflix.conductor.dao.MetadataDAO) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) PreparedStatement(com.datastax.driver.core.PreparedStatement) Inject(javax.inject.Inject) CassandraConfiguration(com.netflix.conductor.cassandra.CassandraConfiguration) ResultSet(com.datastax.driver.core.ResultSet) Session(com.datastax.driver.core.Session) Map(java.util.Map) Code(com.netflix.conductor.core.execution.ApplicationException.Code) TASK_DEFINITION_KEY(com.netflix.conductor.util.Constants.TASK_DEFINITION_KEY) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) ApplicationException(com.netflix.conductor.core.execution.ApplicationException) Logger(org.slf4j.Logger) Trace(com.netflix.conductor.annotations.Trace) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) TASK_DEFS_KEY(com.netflix.conductor.util.Constants.TASK_DEFS_KEY) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) Monitors(com.netflix.conductor.metrics.Monitors) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) WORKFLOW_DEF_NAME_VERSION_KEY(com.netflix.conductor.util.Constants.WORKFLOW_DEF_NAME_VERSION_KEY) Statements(com.netflix.conductor.util.Statements) WORKFLOW_DEFINITION_KEY(com.netflix.conductor.util.Constants.WORKFLOW_DEFINITION_KEY) Optional(java.util.Optional) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Comparator(java.util.Comparator) WORKFLOW_DEF_INDEX_KEY(com.netflix.conductor.util.Constants.WORKFLOW_DEF_INDEX_KEY) Collections(java.util.Collections) ApplicationException(com.netflix.conductor.core.execution.ApplicationException) ResultSet(com.datastax.driver.core.ResultSet) Row(com.datastax.driver.core.Row) ApplicationException(com.netflix.conductor.core.execution.ApplicationException)

Aggregations

PreparedStatement (com.datastax.driver.core.PreparedStatement)2 ResultSet (com.datastax.driver.core.ResultSet)2 Row (com.datastax.driver.core.Row)2 Session (com.datastax.driver.core.Session)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Trace (com.netflix.conductor.annotations.Trace)2 CassandraConfiguration (com.netflix.conductor.cassandra.CassandraConfiguration)2 TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)2 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)2 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)2 Code (com.netflix.conductor.core.execution.ApplicationException.Code)2 MetadataDAO (com.netflix.conductor.dao.MetadataDAO)2 Monitors (com.netflix.conductor.metrics.Monitors)2 TASK_DEFINITION_KEY (com.netflix.conductor.util.Constants.TASK_DEFINITION_KEY)2 TASK_DEFS_KEY (com.netflix.conductor.util.Constants.TASK_DEFS_KEY)2 WORKFLOW_DEFINITION_KEY (com.netflix.conductor.util.Constants.WORKFLOW_DEFINITION_KEY)2 WORKFLOW_DEF_INDEX_KEY (com.netflix.conductor.util.Constants.WORKFLOW_DEF_INDEX_KEY)2 WORKFLOW_DEF_NAME_VERSION_KEY (com.netflix.conductor.util.Constants.WORKFLOW_DEF_NAME_VERSION_KEY)2 Statements (com.netflix.conductor.util.Statements)2