use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class TaskActionTest method get_project_queue_task_with_scan_permission_on_project.
@Test
public void get_project_queue_task_with_scan_permission_on_project() {
userSession.logIn().addProjectUuidPermissions(GlobalPermissions.SCAN_EXECUTION, project.uuid());
CeQueueDto task = createAndPersistQueueTask(project);
call(task.getUuid());
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class TaskFormatterTest method newActivity.
private CeActivityDto newActivity(String taskUuid, String componentUuid, CeActivityDto.Status status) {
CeQueueDto queueDto = new CeQueueDto();
queueDto.setCreatedAt(1_450_000_000_000L);
queueDto.setTaskType(CeTaskTypes.REPORT);
queueDto.setComponentUuid(componentUuid);
queueDto.setUuid(taskUuid);
CeActivityDto activityDto = new CeActivityDto(queueDto);
activityDto.setStatus(status);
activityDto.setExecutionTimeMs(500L);
activityDto.setAnalysisUuid("U1");
return activityDto;
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class CeQueueImpl method cancelAll.
protected int cancelAll(boolean includeInProgress) {
int count = 0;
try (DbSession dbSession = dbClient.openSession(false)) {
for (CeQueueDto queueDto : dbClient.ceQueueDao().selectAllInAscOrder(dbSession)) {
if (includeInProgress || !queueDto.getStatus().equals(CeQueueDto.Status.IN_PROGRESS)) {
cancelImpl(dbSession, queueDto);
count++;
}
}
return count;
}
}
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;
}
}
Aggregations