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);
}
}
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);
}
}
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");
}
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");
}
Aggregations