]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7104 CeTaskProcessor#process now returns a CeTaskResult
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 3 Dec 2015 09:41:44 +0000 (10:41 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Mon, 7 Dec 2015 23:26:55 +0000 (00:26 +0100)
server/sonar-server/src/main/java/org/sonar/server/computation/queue/CeTaskResult.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/computation/taskprocessor/CeTaskProcessor.java
server/sonar-server/src/main/java/org/sonar/server/computation/taskprocessor/report/ReportTaskProcessor.java
server/sonar-server/src/test/java/org/sonar/server/computation/taskprocessor/CeTaskProcessorRepositoryImplTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/taskprocessor/CeTaskProcessorRepositoryRule.java

diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/queue/CeTaskResult.java b/server/sonar-server/src/main/java/org/sonar/server/computation/queue/CeTaskResult.java
new file mode 100644 (file)
index 0000000..e84780f
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.queue;
+
+import javax.annotation.CheckForNull;
+
+/**
+ * Represents the result of the processing of a {@link CeTask}.
+ *
+ * @see {@link org.sonar.server.computation.taskprocessor.CeTaskProcessor#process(CeTask)}
+ */
+public interface CeTaskResult {
+  /**
+   * The id of the snapshot created, if any, for the Component in {@link CeTask}
+   */
+  @CheckForNull
+  Long getSnapshotId();
+}
index 16edeb61f1d0bbf424419815141cb689da24da7f..ea98cae3a8b7adbfeb1554ec7fb06db97dd42db3 100644 (file)
@@ -20,7 +20,9 @@
 package org.sonar.server.computation.taskprocessor;
 
 import java.util.Set;
+import javax.annotation.CheckForNull;
 import org.sonar.server.computation.queue.CeTask;
+import org.sonar.server.computation.queue.CeTaskResult;
 
 /**
  * This interface is used to provide the processing code for {@link CeTask}s of one or more type to be called by the
@@ -51,5 +53,6 @@ public interface CeTaskProcessor {
    * @throws RuntimeException when thrown, it will be caught and logged by the Compute Engine and the processing of the
    *         specified {@link CeTask} will be flagged as failed.
    */
-  void process(CeTask task);
+  @CheckForNull
+  CeTaskResult process(CeTask task);
 }
index 8bb705871085435c98a3c8c43441b8287d66399a..db4fd635f887efcd5cb658d9634de779f3e006ca 100644 (file)
@@ -27,6 +27,7 @@ import org.sonar.db.ce.CeTaskTypes;
 import org.sonar.server.computation.container.ComputeEngineContainer;
 import org.sonar.server.computation.container.ContainerFactory;
 import org.sonar.server.computation.queue.CeTask;
+import org.sonar.server.computation.queue.CeTaskResult;
 import org.sonar.server.computation.step.ComputationStepExecutor;
 import org.sonar.server.computation.taskprocessor.CeTaskProcessor;
 import org.sonar.server.devcockpit.DevCockpitBridge;
@@ -64,10 +65,11 @@ public class ReportTaskProcessor implements CeTaskProcessor {
   }
 
   @Override
-  public void process(CeTask task) {
+  public CeTaskResult process(CeTask task) {
     ComputeEngineContainer ceContainer = containerFactory.create(serverContainer, task, devCockpitBridge);
     try {
       ceContainer.getComponentByType(ComputationStepExecutor.class).execute();
+      return null;
     } finally {
       ceContainer.cleanup();
     }
index 6b865959f8683df57c7ae3d7583829b21eb1df7a..b9fc98ad9f00e84693dc2279260bc5314084c005 100644 (file)
@@ -25,6 +25,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.server.computation.queue.CeTask;
+import org.sonar.server.computation.queue.CeTaskResult;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.guava.api.Assertions.assertThat;
@@ -126,7 +127,7 @@ public class CeTaskProcessorRepositoryImplTest {
     }
 
     @Override
-    public void process(CeTask task) {
+    public CeTaskResult process(CeTask task) {
       throw new UnsupportedOperationException("Process is not implemented");
     }
   }
index 02932ed07b2e4a99fd382eab5f33c85fa5b3c1ec..1c246b013b7c1446afa8d16b9dabaa1c0f8c5066 100644 (file)
@@ -25,6 +25,7 @@ import java.util.Map;
 import java.util.Set;
 import org.junit.rules.ExternalResource;
 import org.sonar.server.computation.queue.CeTask;
+import org.sonar.server.computation.queue.CeTaskResult;
 
 import static com.google.common.base.Preconditions.checkState;
 import static java.util.Objects.requireNonNull;
@@ -70,7 +71,7 @@ public class CeTaskProcessorRepositoryRule extends ExternalResource implements C
     }
 
     @Override
-    public void process(CeTask task) {
+    public CeTaskResult process(CeTask task) {
       throw new UnsupportedOperationException(UOE_MESSAGE);
     }
   }