Search in sources :

Example 1 with CeTaskResult

use of org.sonar.ce.queue.CeTaskResult in project sonarqube by SonarSource.

the class CeWorkerCallableImpl method executeTask.

private void executeTask(CeTask task) {
    ceLogging.initForTask(task);
    Profiler ceProfiler = startActivityProfiler(task);
    CeActivityDto.Status status = CeActivityDto.Status.FAILED;
    CeTaskResult taskResult = null;
    Throwable error = null;
    try {
        // TODO delegate the message to the related task processor, according to task type
        Optional<CeTaskProcessor> taskProcessor = taskProcessorRepository.getForCeTask(task);
        if (taskProcessor.isPresent()) {
            taskResult = taskProcessor.get().process(task);
            status = CeActivityDto.Status.SUCCESS;
        } else {
            LOG.error("No CeTaskProcessor is defined for task of type {}. Plugin configuration may have changed", task.getType());
            status = CeActivityDto.Status.FAILED;
        }
    } catch (Throwable e) {
        LOG.error(format("Failed to execute task %s", task.getUuid()), e);
        error = e;
    } finally {
        finalizeTask(task, ceProfiler, status, taskResult, error);
    }
}
Also used : CeTaskResult(org.sonar.ce.queue.CeTaskResult) CeTaskProcessor(org.sonar.ce.taskprocessor.CeTaskProcessor) CeActivityDto(org.sonar.db.ce.CeActivityDto) Profiler(org.sonar.core.util.logs.Profiler)

Example 2 with CeTaskResult

use of org.sonar.ce.queue.CeTaskResult in project sonarqube by SonarSource.

the class InternalCeQueueImplTest method newTaskResult.

private CeTaskResult newTaskResult(@Nullable String analysisUuid) {
    CeTaskResult taskResult = mock(CeTaskResult.class);
    when(taskResult.getAnalysisUuid()).thenReturn(java.util.Optional.ofNullable(analysisUuid));
    return taskResult;
}
Also used : CeTaskResult(org.sonar.ce.queue.CeTaskResult)

Example 3 with CeTaskResult

use of org.sonar.ce.queue.CeTaskResult in project sonarqube by SonarSource.

the class MutableTaskResultHolderImplTest method getResult_returns_object_set_with_setResult.

@Test
public void getResult_returns_object_set_with_setResult() {
    CeTaskResult taskResult = mock(CeTaskResult.class);
    underTest.setResult(taskResult);
    assertThat(underTest.getResult()).isSameAs(taskResult);
}
Also used : CeTaskResult(org.sonar.ce.queue.CeTaskResult) Test(org.junit.Test)

Aggregations

CeTaskResult (org.sonar.ce.queue.CeTaskResult)3 Test (org.junit.Test)1 CeTaskProcessor (org.sonar.ce.taskprocessor.CeTaskProcessor)1 Profiler (org.sonar.core.util.logs.Profiler)1 CeActivityDto (org.sonar.db.ce.CeActivityDto)1