Search in sources :

Example 6 with Profiler

use of org.sonar.core.util.logs.Profiler in project sonarqube by SonarSource.

the class DatabaseMigrationImpl method doDatabaseMigration.

private void doDatabaseMigration() {
    migrationState.setStatus(Status.RUNNING);
    migrationState.setStartedAt(new Date());
    migrationState.setError(null);
    Profiler profiler = Profiler.create(LOGGER);
    try {
        profiler.startInfo("Starting DB Migration and container restart");
        doUpgradeDb();
        doRestartContainer();
        migrationState.setStatus(Status.SUCCEEDED);
        profiler.stopInfo("DB Migration and container restart: success");
    } catch (MigrationStepExecutionException e) {
        profiler.stopError("DB migration failed");
        LOGGER.error("DB migration ended with an exception", e);
        saveStatus(e);
    } catch (Throwable t) {
        profiler.stopError("Container restart failed");
        LOGGER.error("Container restart failed", t);
        saveStatus(t);
    } finally {
        running.getAndSet(false);
    }
}
Also used : Profiler(org.sonar.core.util.logs.Profiler) MigrationStepExecutionException(org.sonar.server.platform.db.migration.step.MigrationStepExecutionException) Date(java.util.Date)

Example 7 with Profiler

use of org.sonar.core.util.logs.Profiler 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 8 with Profiler

use of org.sonar.core.util.logs.Profiler in project sonarqube by SonarSource.

the class CeWorkerCallableImpl method startActivityProfiler.

private static Profiler startActivityProfiler(CeTask task) {
    Profiler profiler = Profiler.create(LOG);
    addContext(profiler, task);
    return profiler.startInfo("Execute task");
}
Also used : Profiler(org.sonar.core.util.logs.Profiler)

Example 9 with Profiler

use of org.sonar.core.util.logs.Profiler in project sonarqube by SonarSource.

the class DatabaseMigrationImpl method doRestartContainer.

private void doRestartContainer() {
    Profiler profiler = Profiler.createIfTrace(LOGGER);
    profiler.startTrace("Restarting container");
    platform.doStart();
    profiler.stopTrace("Container restarted successfully");
}
Also used : Profiler(org.sonar.core.util.logs.Profiler)

Aggregations

Profiler (org.sonar.core.util.logs.Profiler)9 Date (java.util.Date)1 CeTaskResult (org.sonar.ce.queue.CeTaskResult)1 CeTaskProcessor (org.sonar.ce.taskprocessor.CeTaskProcessor)1 CeActivityDto (org.sonar.db.ce.CeActivityDto)1 MigrationStepExecutionException (org.sonar.server.platform.db.migration.step.MigrationStepExecutionException)1