]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11077 log nb of triggered portfolio refreshes in CE
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 30 Jul 2018 20:11:15 +0000 (22:11 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 2 Aug 2018 18:21:36 +0000 (20:21 +0200)
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/TriggerViewRefreshStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/view/TriggerViewRefreshDelegate.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/TriggerViewRefreshStepTest.java

index b8f22b27a18fc61c8742cc59ea813824bc28727b..de155ff5a439e7cd63f868c8b1cfb53107e70182 100644 (file)
@@ -20,6 +20,7 @@
 
 package org.sonar.ce.task.projectanalysis.step;
 
+import java.util.OptionalInt;
 import javax.annotation.Nullable;
 import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder;
 import org.sonar.ce.task.projectanalysis.view.TriggerViewRefreshDelegate;
@@ -58,7 +59,8 @@ public class TriggerViewRefreshStep implements ComputationStep {
   @Override
   public void execute(ComputationStep.Context context) {
     if (triggerViewRefreshDelegate != null) {
-      triggerViewRefreshDelegate.accept(analysisMetadata.getProject());
+      OptionalInt count = triggerViewRefreshDelegate.triggerFrom(analysisMetadata.getProject());
+      count.ifPresent(i -> context.getStatistics().add("refreshes", i));
     }
   }
 }
index 0775e84242d1adfa977b6cc7a7df47177a7eace4..5b3410a9c71628f6f19c64ce93ff804cd4020d95 100644 (file)
 
 package org.sonar.ce.task.projectanalysis.view;
 
-import java.util.function.Consumer;
+import java.util.OptionalInt;
 import org.sonar.server.project.Project;
 
-public interface TriggerViewRefreshDelegate extends Consumer<Project> {
+public interface TriggerViewRefreshDelegate {
+
+  /**
+   * Triggers the refresh of portfolios and applications
+   * associated to the project.
+   *
+   * @return the number of portfolios and applications being refreshed,
+   * or {@link OptionalInt#empty()} if not applicable.
+   */
+  OptionalInt triggerFrom(Project project);
+
 }
index 3229eaae4fe73dd96e90de3e76d07137862211a8..12a766edbd3a1f583f2b46ec47e057d57427d986 100644 (file)
@@ -61,6 +61,6 @@ public class TriggerViewRefreshStepTest {
     underTest.execute(new TestComputationStepContext());
 
     verify(analysisMetadataHolder).getProject();
-    verify(delegate).accept(project);
+    verify(delegate).triggerFrom(project);
   }
 }