diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2020-03-18 13:54:33 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-03-30 20:03:42 +0000 |
commit | 50d6bfbc6596c3987e0e2cf26f7a466f3cfdda90 (patch) | |
tree | be215d09a366f2181bbe76ff0e9fabfe2a8f3e0d /server | |
parent | c5d09b55c28cd2e590f379166d84f35c0026474b (diff) | |
download | sonarqube-50d6bfbc6596c3987e0e2cf26f7a466f3cfdda90.tar.gz sonarqube-50d6bfbc6596c3987e0e2cf26f7a466f3cfdda90.zip |
SONAR-12691 Minor cleanup
Diffstat (limited to 'server')
3 files changed, 2 insertions, 55 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/purge/ProjectCleaner.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/purge/ProjectCleaner.java index 34262103492..4ba6e4242bf 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/purge/ProjectCleaner.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/purge/ProjectCleaner.java @@ -39,8 +39,6 @@ import static org.sonar.db.purge.PurgeConfiguration.newDefaultPurgeConfiguration @ServerSide @ComputeEngineSide public class ProjectCleaner { - private static final Logger LOG = Loggers.get(ProjectCleaner.class); - private final PurgeProfiler profiler; private final PurgeListener purgeListener; private final PurgeDao purgeDao; @@ -54,7 +52,6 @@ public class ProjectCleaner { } public ProjectCleaner purge(DbSession session, String rootUuid, String projectUuid, Configuration projectConfig, Set<String> disabledComponentUuids) { - long start = System.currentTimeMillis(); profiler.reset(); periodCleaner.clean(session, rootUuid, projectConfig); @@ -63,16 +60,6 @@ public class ProjectCleaner { purgeDao.purge(session, configuration, purgeListener, profiler); session.commit(); - logProfiling(start, projectConfig); return this; } - - private void logProfiling(long start, Configuration config) { - if (config.getBoolean(CoreProperties.PROFILING_LOG_PROPERTY).orElse(false)) { - long duration = System.currentTimeMillis() - start; - LOG.info("\n -------- Profiling for purge: " + TimeUtils.formatDuration(duration) + " --------\n"); - profiler.dump(duration, LOG); - LOG.info("\n -------- End of profiling for purge --------\n"); - } - } } diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/purge/PurgeDatastoresStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/purge/PurgeDatastoresStep.java index 02817b4f33e..8bc2674cc0c 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/purge/PurgeDatastoresStep.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/purge/PurgeDatastoresStep.java @@ -20,21 +20,13 @@ package org.sonar.ce.task.projectanalysis.purge; import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder; -import org.sonar.ce.task.projectanalysis.component.Component; import org.sonar.ce.task.projectanalysis.component.ConfigurationRepository; -import org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler; import org.sonar.ce.task.projectanalysis.component.DisabledComponentsHolder; import org.sonar.ce.task.projectanalysis.component.TreeRootHolder; -import org.sonar.ce.task.projectanalysis.component.TypeAwareVisitorAdapter; import org.sonar.ce.task.step.ComputationStep; import org.sonar.db.DbClient; import org.sonar.db.DbSession; -import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT; -import static org.sonar.ce.task.projectanalysis.component.Component.Type.VIEW; -import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER; -import static org.sonar.ce.task.projectanalysis.component.CrawlerDepthLimit.reportMaxDepth; - public class PurgeDatastoresStep implements ComputationStep { private final ProjectCleaner projectCleaner; @@ -56,24 +48,10 @@ public class PurgeDatastoresStep implements ComputationStep { @Override public void execute(ComputationStep.Context context) { - new DepthTraversalTypeAwareCrawler( - new TypeAwareVisitorAdapter(reportMaxDepth(PROJECT).withViewsMaxDepth(VIEW), PRE_ORDER) { - @Override - public void visitProject(Component project) { - execute(project); - } - - @Override - public void visitView(Component view) { - execute(view); - } - }).visit(treeRootHolder.getRoot()); - } - - private void execute(Component root) { try (DbSession dbSession = dbClient.openSession(true)) { + // applies to views and projects String projectUuid = analysisMetadataHolder.getProject().getUuid(); - projectCleaner.purge(dbSession, root.getUuid(), projectUuid, configRepository.getConfiguration(), disabledComponentsHolder.getUuids()); + projectCleaner.purge(dbSession, treeRootHolder.getRoot().getUuid(), projectUuid, configRepository.getConfiguration(), disabledComponentsHolder.getUuids()); dbSession.commit(); } } diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/purge/ProjectCleanerTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/purge/ProjectCleanerTest.java index 4d0e113bd34..d79e1e39739 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/purge/ProjectCleanerTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/purge/ProjectCleanerTest.java @@ -54,24 +54,6 @@ public class ProjectCleanerTest { } @Test - public void no_profiling_when_property_is_false() { - settings.setProperty(CoreProperties.PROFILING_LOG_PROPERTY, false); - - underTest.purge(mock(DbSession.class), "root", "project", settings.asConfig(), emptySet()); - - verify(profiler, never()).dump(anyLong(), any()); - } - - @Test - public void profiling_when_property_is_true() { - settings.setProperty(CoreProperties.PROFILING_LOG_PROPERTY, true); - - underTest.purge(mock(DbSession.class), "root", "project", settings.asConfig(), emptySet()); - - verify(profiler).dump(anyLong(), any()); - } - - @Test public void call_period_cleaner_index_client_and_purge_dao() { settings.setProperty(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES, 5); |