]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12691 Minor cleanup
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Wed, 18 Mar 2020 18:54:33 +0000 (13:54 -0500)
committersonartech <sonartech@sonarsource.com>
Mon, 30 Mar 2020 20:03:42 +0000 (20:03 +0000)
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/purge/ProjectCleaner.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/purge/PurgeDatastoresStep.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/purge/ProjectCleanerTest.java
sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java

index 342621034920345de758e5d4ee5dd25ce082acf5..4ba6e4242bfe53f61471c6893c2ab491d22aa040 100644 (file)
@@ -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");
-    }
-  }
 }
index 02817b4f33e02d0d1aa5915c8e253f5dabac13c8..8bc2674cc0c64d18cfc5d6f2bd12bc8bfeefc9f3 100644 (file)
 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();
     }
   }
index 4d0e113bd3413a22ea49fbef26848fb47d45dfd4..d79e1e397395a578fb9040759f24b2f1aa8daf5a 100644 (file)
@@ -53,24 +53,6 @@ public class ProjectCleanerTest {
     this.underTest = new ProjectCleaner(dao, periodCleaner, profiler, purgeListener);
   }
 
-  @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);
index a5b3f5fadb08535f065698ef9a4992adda1798bc..d09cc16053188ed213e2499b2a3dcbd625ad8c80 100644 (file)
@@ -308,12 +308,6 @@ public interface CoreProperties {
   @Deprecated
   String SCAN_TASK = "scan";
 
-  /**
-   * @since 3.6
-   */
-  // TODO remove?
-  String PROFILING_LOG_PROPERTY = "sonar.showProfiling";
-
   /**
    * @since 4.0
    */