Search in sources :

Example 1 with TASK_ID_KEY

use of com.netflix.conductor.util.Constants.TASK_ID_KEY 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;
}
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) ApplicationException(com.netflix.conductor.core.execution.ApplicationException) TaskDef(com.netflix.conductor.common.metadata.tasks.TaskDef) 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