|
|
@@ -20,9 +20,13 @@ |
|
|
|
package org.sonar.ce.task.projectanalysis.purge; |
|
|
|
|
|
|
|
import java.util.Set; |
|
|
|
import org.sonar.api.CoreProperties; |
|
|
|
import org.sonar.api.ce.ComputeEngineSide; |
|
|
|
import org.sonar.api.config.Configuration; |
|
|
|
import org.sonar.api.server.ServerSide; |
|
|
|
import org.sonar.api.utils.TimeUtils; |
|
|
|
import org.sonar.api.utils.log.Logger; |
|
|
|
import org.sonar.api.utils.log.Loggers; |
|
|
|
import org.sonar.db.DbSession; |
|
|
|
import org.sonar.db.purge.PurgeConfiguration; |
|
|
|
import org.sonar.db.purge.PurgeDao; |
|
|
@@ -35,6 +39,8 @@ 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; |
|
|
@@ -48,6 +54,7 @@ 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); |
|
|
@@ -56,6 +63,20 @@ 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(""); |
|
|
|
LOG.info(" -------- Profiling for purge: " + TimeUtils.formatDuration(duration) + " --------"); |
|
|
|
LOG.info(""); |
|
|
|
profiler.dump(duration, LOG); |
|
|
|
LOG.info(""); |
|
|
|
LOG.info(" -------- End of profiling for purge --------"); |
|
|
|
LOG.info(""); |
|
|
|
} |
|
|
|
} |
|
|
|
} |