Search in sources :

Example 1 with PAYLOAD_KEY

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

the class CassandraExecutionDAO method getTask.

@Override
public Task getTask(String taskId) {
    try {
        String workflowId = lookupWorkflowIdFromTaskId(taskId);
        if (workflowId == null) {
            return null;
        }
        // TODO: implement for query against multiple shards
        ResultSet resultSet = session.execute(selectTaskStatement.bind(UUID.fromString(workflowId), DEFAULT_SHARD_ID, taskId));
        return Optional.ofNullable(resultSet.one()).map(row -> {
            Task task = readValue(row.getString(PAYLOAD_KEY), Task.class);
            recordCassandraDaoRequests("getTask", task.getTaskType(), task.getWorkflowType());
            recordCassandraDaoPayloadSize("getTask", toJson(task).length(), task.getTaskType(), task.getWorkflowType());
            return task;
        }).orElse(null);
    } catch (ApplicationException ae) {
        throw ae;
    } catch (Exception e) {
        Monitors.error(CLASS_NAME, "getTask");
        String errorMsg = String.format("Error getting task by id: %s", taskId);
        LOGGER.error(errorMsg, e);
        throw new ApplicationException(Code.BACKEND_ERROR, errorMsg);
    }
}
Also used : DEFAULT_TOTAL_PARTITIONS(com.netflix.conductor.util.Constants.DEFAULT_TOTAL_PARTITIONS) Row(com.datastax.driver.core.Row) WORKFLOW_ID_KEY(com.netflix.conductor.util.Constants.WORKFLOW_ID_KEY) LoggerFactory(org.slf4j.LoggerFactory) ExecutionDAO(com.netflix.conductor.dao.ExecutionDAO) Task(com.netflix.conductor.common.metadata.tasks.Task) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) PreparedStatement(com.datastax.driver.core.PreparedStatement) Inject(javax.inject.Inject) ENTITY_KEY(com.netflix.conductor.util.Constants.ENTITY_KEY) CassandraConfiguration(com.netflix.conductor.cassandra.CassandraConfiguration) DEFAULT_SHARD_ID(com.netflix.conductor.util.Constants.DEFAULT_SHARD_ID) ResultSet(com.datastax.driver.core.ResultSet) TOTAL_PARTITIONS_KEY(com.netflix.conductor.util.Constants.TOTAL_PARTITIONS_KEY) Workflow(com.netflix.conductor.common.run.Workflow) IN_PROGRESS(com.netflix.conductor.common.metadata.tasks.Task.Status.IN_PROGRESS) Session(com.datastax.driver.core.Session) PollDataDAO(com.netflix.conductor.dao.PollDataDAO) PollData(com.netflix.conductor.common.metadata.tasks.PollData) EventExecution(com.netflix.conductor.common.metadata.events.EventExecution) LinkedList(java.util.LinkedList) BatchStatement(com.datastax.driver.core.BatchStatement) Code(com.netflix.conductor.core.execution.ApplicationException.Code) 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) RetryUtil(com.netflix.conductor.common.utils.RetryUtil) TASK_ID_KEY(com.netflix.conductor.util.Constants.TASK_ID_KEY) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) PAYLOAD_KEY(com.netflix.conductor.util.Constants.PAYLOAD_KEY) Monitors(com.netflix.conductor.metrics.Monitors) TOTAL_TASKS_KEY(com.netflix.conductor.util.Constants.TOTAL_TASKS_KEY) List(java.util.List) ENTITY_TYPE_WORKFLOW(com.netflix.conductor.util.Constants.ENTITY_TYPE_WORKFLOW) Statements(com.netflix.conductor.util.Statements) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ENTITY_TYPE_TASK(com.netflix.conductor.util.Constants.ENTITY_TYPE_TASK) Comparator(java.util.Comparator) Task(com.netflix.conductor.common.metadata.tasks.Task) ApplicationException(com.netflix.conductor.core.execution.ApplicationException) ResultSet(com.datastax.driver.core.ResultSet) ApplicationException(com.netflix.conductor.core.execution.ApplicationException)

Aggregations

BatchStatement (com.datastax.driver.core.BatchStatement)1 PreparedStatement (com.datastax.driver.core.PreparedStatement)1 ResultSet (com.datastax.driver.core.ResultSet)1 Row (com.datastax.driver.core.Row)1 Session (com.datastax.driver.core.Session)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 Trace (com.netflix.conductor.annotations.Trace)1 CassandraConfiguration (com.netflix.conductor.cassandra.CassandraConfiguration)1 EventExecution (com.netflix.conductor.common.metadata.events.EventExecution)1 PollData (com.netflix.conductor.common.metadata.tasks.PollData)1 Task (com.netflix.conductor.common.metadata.tasks.Task)1 IN_PROGRESS (com.netflix.conductor.common.metadata.tasks.Task.Status.IN_PROGRESS)1 TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)1 Workflow (com.netflix.conductor.common.run.Workflow)1 RetryUtil (com.netflix.conductor.common.utils.RetryUtil)1 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)1 Code (com.netflix.conductor.core.execution.ApplicationException.Code)1 ExecutionDAO (com.netflix.conductor.dao.ExecutionDAO)1