aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2015-08-12 10:43:23 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2015-08-24 14:00:30 +0200
commit8d785cec0a5394bbd79be3beaf5ee54497ad30a7 (patch)
treeba7542918d0fe12651da1cdf55d4f5d4a67c838a /server
parent9f7fdba441cf8912661a2eae26ac5572a76285c0 (diff)
downloadsonarqube-8d785cec0a5394bbd79be3beaf5ee54497ad30a7.tar.gz
sonarqube-8d785cec0a5394bbd79be3beaf5ee54497ad30a7.zip
ReportProcessor must not have the responsability of populating CEQueueStatus
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/ComputationStepExecutor.java10
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/ReportProcessor.java10
2 files changed, 10 insertions, 10 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationStepExecutor.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationStepExecutor.java
index 780b2dd3df2..c90f2a75f7f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationStepExecutor.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationStepExecutor.java
@@ -21,6 +21,7 @@ package org.sonar.server.computation;
import org.sonar.api.utils.log.Logger;
import org.sonar.core.util.logs.Profiler;
+import org.sonar.server.computation.monitoring.CEQueueStatus;
import org.sonar.server.computation.step.ComputationStep;
import static java.lang.String.format;
@@ -30,14 +31,17 @@ public final class ComputationStepExecutor {
private final Logger logger;
private final Listener listener;
private final String description;
+ private final CEQueueStatus queueStatus;
- public ComputationStepExecutor(Logger logger, Listener listener, String description) {
+ public ComputationStepExecutor(Logger logger, Listener listener, String description, CEQueueStatus queueStatus) {
this.logger = requireNonNull(logger);
this.listener = requireNonNull(listener);
this.description = requireNonNull(description);
+ this.queueStatus = queueStatus;
}
public void execute(Iterable<ComputationStep> steps) {
+ queueStatus.addInProgress();
listener.onStart();
Profiler profiler = Profiler.create(logger).startDebug(description);
long timingSum = 0L;
@@ -49,9 +53,11 @@ public final class ComputationStepExecutor {
timingSum += stepProfiler.stopInfo(step.getDescription());
}
long timing = logProcessingEnd(description, profiler, timingSum);
+ queueStatus.addSuccess(timing);
listener.onSuccess(timing);
} catch (Throwable e) {
long timing = logProcessingEnd(description, profiler, timingSum);
+ queueStatus.addError(timing);
listener.onError(e, timing);
} finally {
listener.onEnd();
@@ -85,7 +91,7 @@ public final class ComputationStepExecutor {
void onError(Throwable e, long timing);
/**
- * Called when all ComputationSteps have been executed, after either {@link #onSuccess(long)} or {@link #onError(Throwable, long)}.
+ * Called when all ComputationSteps have been executed, after either {@link #onSuccess(long)} or {@link #onError(Throwable, long)}
*/
void onEnd();
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ReportProcessor.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ReportProcessor.java
index f78c1b099ff..7ae3b3a267d 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/ReportProcessor.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/ReportProcessor.java
@@ -20,7 +20,6 @@
package org.sonar.server.computation;
import com.google.common.base.Throwables;
-import org.sonar.api.server.ServerSide;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.log.Loggers;
import org.sonar.server.computation.activity.ActivityManager;
@@ -31,7 +30,6 @@ import static java.lang.String.format;
import static org.sonar.db.compute.AnalysisReportDto.Status.FAILED;
import static org.sonar.db.compute.AnalysisReportDto.Status.SUCCESS;
-@ServerSide
public class ReportProcessor {
private final ComputationStepExecutor executor;
@@ -42,7 +40,7 @@ public class ReportProcessor {
this.executor = new ComputationStepExecutor(
Loggers.get(ReportProcessor.class),
new BatchReportStepsExecutorListener(item, system, activityManager, queueStatus),
- createDescription(item));
+ createDescription(item), queueStatus);
this.steps = steps;
}
@@ -59,29 +57,25 @@ public class ReportProcessor {
private final ReportQueue.Item item;
private final System2 system;
private final ActivityManager activityManager;
- private final CEQueueStatus queueStatus;
private BatchReportStepsExecutorListener(ReportQueue.Item item, System2 system, ActivityManager activityManager, CEQueueStatus queueStatus) {
this.item = item;
this.system = system;
this.activityManager = activityManager;
- this.queueStatus = queueStatus;
}
@Override
public void onStart() {
- queueStatus.addInProgress();
+ // nothing to do on start
}
@Override
public void onSuccess(long timing) {
- queueStatus.addSuccess(timing);
item.dto.setStatus(SUCCESS);
}
@Override
public void onError(Throwable e, long timing) {
- queueStatus.addError(timing);
item.dto.setStatus(FAILED);
throw Throwables.propagate(e);
}