diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-09-21 00:34:21 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-09-21 00:34:21 +0200 |
commit | f8b016eaef578571f2b9d2f346a9949b779fc829 (patch) | |
tree | 1a26f88b68c14307f4907e3c2fe6632647a54d43 | |
parent | 9d157c921ce0b088264d1b4e1c7a6dbcbac3768c (diff) | |
download | sonarqube-f8b016eaef578571f2b9d2f346a9949b779fc829.tar.gz sonarqube-f8b016eaef578571f2b9d2f346a9949b779fc829.zip |
SONAR-4690 add some javadoc
5 files changed, 21 insertions, 7 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Progress.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Progress.java index 0e6f0f51d66..d74f6182b65 100644 --- a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Progress.java +++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Progress.java @@ -25,6 +25,10 @@ import org.slf4j.LoggerFactory; import java.util.TimerTask; import java.util.concurrent.atomic.AtomicInteger; +/** + * This task logs every minute the status of migration. It is destroyed + * when migration is finished. + */ class Progress extends TimerTask { static final String THREAD_NAME = "Violation Migration Progress"; @@ -41,12 +45,8 @@ class Progress extends TimerTask { this.start = startDate; } - Progress(int totalViolations, Logger logger) { - this(totalViolations, logger, System.currentTimeMillis()); - } - Progress(int totalViolations) { - this(totalViolations, LoggerFactory.getLogger(Progress.class)); + this(totalViolations, LoggerFactory.getLogger(Progress.class), System.currentTimeMillis()); } void increment(int delta) { diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Referentials.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Referentials.java index 35ac7c60c81..c7accede562 100644 --- a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Referentials.java +++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Referentials.java @@ -35,6 +35,10 @@ import java.util.Map; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; +/** + * Data loaded from database before migrating violations. It is + * shared amongst converter parallel tasks. + */ class Referentials { static final int VIOLATION_GROUP_SIZE = 1000; diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/SqlUtil.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/SqlUtil.java index e6b6ffbb3a8..df1a9d867ae 100644 --- a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/SqlUtil.java +++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/SqlUtil.java @@ -31,6 +31,10 @@ class SqlUtil { // only static methods } + /** + * Logback does not log exceptions associated to {@link java.sql.SQLException#getNextException()}. + * See http://jira.qos.ch/browse/LOGBACK-775 + */ static void log(Logger logger, SQLException e) { SQLException next = e.getNextException(); while (next != null) { diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverter.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverter.java index 6c819e69913..e0d39f1c7fc 100644 --- a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverter.java +++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverter.java @@ -130,6 +130,13 @@ class ViolationConverter implements Callable<Object> { @Override public Object call() throws Exception { + // For each group of 1000 violation ids: + // - load related violations, reviews and action plans + // - in a transaction + // -- insert issues + // -- insert issue_changes if there are review comments + // -- delete violations + Long[] violationIds = referentials.pollGroupOfViolationIds(); while (violationIds != null) { List<Map<String, Object>> rows = selectRows(violationIds); @@ -224,7 +231,6 @@ class ViolationConverter implements Callable<Object> { runner.batch(writeConnection, SQL_INSERT_ISSUE, allParams.toArray(new Object[allParams.size()][])); insertComments(writeConnection, allComments); runner.update(writeConnection, SQL_DELETE_RULE_FAILURES, violationIds); - writeConnection.commit(); progress.increment(rows.size()); diff --git a/sonar-server/src/test/java/org/sonar/server/db/migrations/violation/ProgressTest.java b/sonar-server/src/test/java/org/sonar/server/db/migrations/violation/ProgressTest.java index 12f8007d7b3..87c0e2fadb1 100644 --- a/sonar-server/src/test/java/org/sonar/server/db/migrations/violation/ProgressTest.java +++ b/sonar-server/src/test/java/org/sonar/server/db/migrations/violation/ProgressTest.java @@ -34,7 +34,7 @@ public class ProgressTest { Logger logger = mock(Logger.class); ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class); - Progress progress = new Progress(5000, logger); + Progress progress = new Progress(5000, logger, System.currentTimeMillis()); progress.run(); progress.increment(200); progress.increment(130); |