@@ -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"); | |||
} | |||
} | |||
} |
@@ -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(); | |||
} | |||
} |
@@ -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); |
@@ -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 | |||
*/ |