Search in sources :

Example 1 with CeQueueDto

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) {
    checkState(!submitPaused.get(), "Compute Engine does not currently accept new tasks");
    if (submissions.isEmpty()) {
        return Collections.emptyList();
    }
    try (DbSession dbSession = dbClient.openSession(true)) {
        List<CeQueueDto> ceQueueDtos = from(submissions).transform(new CeTaskSubmitToInsertedCeQueueDto(dbSession, dbClient)).toList();
        List<CeTask> tasks = loadTasks(dbSession, ceQueueDtos);
        dbSession.commit();
        return tasks;
    }
}
Also used : DbSession(org.sonar.db.DbSession) CeQueueDto(org.sonar.db.ce.CeQueueDto)

Example 2 with CeQueueDto

use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.

the class InternalCeQueueImpl method remove.

@Override
public void remove(CeTask task, CeActivityDto.Status status, @Nullable CeTaskResult taskResult, @Nullable Throwable error) {
    checkArgument(error == null || status == CeActivityDto.Status.FAILED, "Error can be provided only when status is FAILED");
    try (DbSession dbSession = dbClient.openSession(false)) {
        Optional<CeQueueDto> queueDto = dbClient.ceQueueDao().selectByUuid(dbSession, task.getUuid());
        checkState(queueDto.isPresent(), "Task does not exist anymore: %s", task);
        CeActivityDto activityDto = new CeActivityDto(queueDto.get());
        activityDto.setStatus(status);
        updateQueueStatus(status, activityDto);
        updateTaskResult(activityDto, taskResult);
        updateError(activityDto, error);
        remove(dbSession, queueDto.get(), activityDto);
    }
}
Also used : DbSession(org.sonar.db.DbSession) CeActivityDto(org.sonar.db.ce.CeActivityDto) CeQueueDto(org.sonar.db.ce.CeQueueDto)

Example 3 with CeQueueDto

use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.

the class InternalCeQueueImpl method peek.

@Override
public Optional<CeTask> peek() {
    if (peekPaused.get()) {
        return Optional.absent();
    }
    try (DbSession dbSession = dbClient.openSession(false)) {
        Optional<CeQueueDto> dto = dbClient.ceQueueDao().peek(dbSession);
        CeTask task = null;
        if (dto.isPresent()) {
            task = loadTask(dbSession, dto.get());
            queueStatus.addInProgress();
        }
        return Optional.fromNullable(task);
    }
}
Also used : DbSession(org.sonar.db.DbSession) CeQueueDto(org.sonar.db.ce.CeQueueDto) CeTask(org.sonar.ce.queue.CeTask)

Example 4 with CeQueueDto

use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.

the class ComponentActionTest method insertQueue.

private CeQueueDto insertQueue(String taskUuid, String componentUuid, CeQueueDto.Status status) {
    CeQueueDto queueDto = new CeQueueDto();
    queueDto.setTaskType(CeTaskTypes.REPORT);
    queueDto.setComponentUuid(componentUuid);
    queueDto.setUuid(taskUuid);
    queueDto.setStatus(status);
    dbTester.getDbClient().ceQueueDao().insert(dbTester.getSession(), queueDto);
    dbTester.getSession().commit();
    return queueDto;
}
Also used : CeQueueDto(org.sonar.db.ce.CeQueueDto)

Example 5 with CeQueueDto

use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.

the class TaskActionTest method get_project_queue_task_with_scan_permission_on_organization_but_not_on_project.

@Test
public void get_project_queue_task_with_scan_permission_on_organization_but_not_on_project() {
    userSession.logIn().addPermission(SCAN, project.getOrganizationUuid());
    CeQueueDto task = createAndPersistQueueTask(project);
    call(task.getUuid());
}
Also used : CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Aggregations

CeQueueDto (org.sonar.db.ce.CeQueueDto)120 Test (org.junit.Test)58 CeActivityDto (org.sonar.db.ce.CeActivityDto)36 ComponentDto (org.sonar.db.component.ComponentDto)20 DbSession (org.sonar.db.DbSession)18 CeTask (org.sonar.ce.task.CeTask)17 UserDto (org.sonar.db.user.UserDto)17 Ce (org.sonarqube.ws.Ce)11 CeTaskCharacteristicDto (org.sonar.db.ce.CeTaskCharacteristicDto)6 List (java.util.List)5 Optional (java.util.Optional)5 Random (java.util.Random)5 Collectors (java.util.stream.Collectors)5 System2 (org.sonar.api.utils.System2)5 Arrays (java.util.Arrays)4 Arrays.asList (java.util.Arrays.asList)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4 Date (java.util.Date)4 IntStream (java.util.stream.IntStream)4