use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class CeQueueCleanerTest method insertInQueue.
private CeQueueDto insertInQueue(String taskUuid, CeQueueDto.Status status) throws IOException {
CeQueueDto dto = new CeQueueDto();
dto.setTaskType(CeTaskTypes.REPORT);
dto.setComponentUuid("PROJECT_1");
dto.setUuid(taskUuid);
dto.setStatus(status);
dbTester.getDbClient().ceQueueDao().insert(dbTester.getSession(), dto);
dbTester.getSession().commit();
return dto;
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class CeQueueImpl method submit.
@Override
public CeTask submit(CeTaskSubmit submission) {
checkState(!submitPaused.get(), "Compute Engine does not currently accept new tasks");
try (DbSession dbSession = dbClient.openSession(false)) {
CeQueueDto dto = new CeTaskSubmitToInsertedCeQueueDto(dbSession, dbClient).apply(submission);
CeTask task = loadTask(dbSession, dto);
dbSession.commit();
return task;
}
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class CeQueueImpl method cancel.
@Override
public boolean cancel(String taskUuid) {
try (DbSession dbSession = dbClient.openSession(false)) {
Optional<CeQueueDto> queueDto = dbClient.ceQueueDao().selectByUuid(dbSession, taskUuid);
if (queueDto.isPresent()) {
checkState(CeQueueDto.Status.PENDING.equals(queueDto.get().getStatus()), "Task is in progress and can't be canceled [uuid=%s]", taskUuid);
cancelImpl(dbSession, queueDto.get());
return true;
}
return false;
}
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class ActivityAction method searchTaskByUuid.
private Optional<WsCe.Task> searchTaskByUuid(DbSession dbSession, ActivityWsRequest request) {
String textQuery = request.getQuery();
if (textQuery == null) {
return Optional.absent();
}
Optional<CeQueueDto> queue = dbClient.ceQueueDao().selectByUuid(dbSession, textQuery);
if (queue.isPresent()) {
return Optional.of(formatter.formatQueue(dbSession, queue.get()));
}
Optional<CeActivityDto> activity = dbClient.ceActivityDao().selectByUuid(dbSession, textQuery);
if (activity.isPresent()) {
return Optional.of(formatter.formatActivity(dbSession, activity.get()));
}
return Optional.absent();
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class CeQueueImpl method massSubmit.
@Override
public List<CeTask> massSubmit(Collection<CeTaskSubmit> submissions, SubmitOption... options) {
if (submissions.isEmpty()) {
return Collections.emptyList();
}
try (DbSession dbSession = dbClient.openSession(false)) {
List<CeQueueDto> taskDtos = submissions.stream().filter(filterBySubmitOptions(options, submissions, dbSession)).map(submission -> addToQueueInDb(dbSession, submission)).collect(Collectors.toList());
List<CeTask> tasks = loadTasks(dbSession, taskDtos);
dbSession.commit();
return tasks;
}
}
Aggregations