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;
}
Aggregations