aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce-task/src
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2018-06-22 16:08:21 +0200
committersonartech <sonartech@sonarsource.com>2018-06-29 09:10:14 +0200
commit525ed917b32bfd43f2517c03d500d7a557240ce0 (patch)
tree2ad9f85224ee8ac1563d7338f2856c28551acf23 /server/sonar-ce-task/src
parentc002746f61bfb24188e505887a18f5b8214f3464 (diff)
downloadsonarqube-525ed917b32bfd43f2517c03d500d7a557240ce0.tar.gz
sonarqube-525ed917b32bfd43f2517c03d500d7a557240ce0.zip
move some classes in preparation of creation of sonar-ce-common
Diffstat (limited to 'server/sonar-ce-task/src')
-rw-r--r--server/sonar-ce-task/src/main/java/org/sonar/ce/task/taskprocessor/CeTaskProcessor.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/server/sonar-ce-task/src/main/java/org/sonar/ce/task/taskprocessor/CeTaskProcessor.java b/server/sonar-ce-task/src/main/java/org/sonar/ce/task/taskprocessor/CeTaskProcessor.java
new file mode 100644
index 00000000000..88140137d37
--- /dev/null
+++ b/server/sonar-ce-task/src/main/java/org/sonar/ce/task/taskprocessor/CeTaskProcessor.java
@@ -0,0 +1,63 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.ce.task.taskprocessor;
+
+import java.util.Set;
+import javax.annotation.CheckForNull;
+import org.sonar.api.ce.ComputeEngineSide;
+import org.sonar.api.server.ServerSide;
+import org.sonar.ce.task.CeTask;
+import org.sonar.ce.task.CeTaskResult;
+
+/**
+ * This interface is used to provide the processing code for {@link CeTask}s of one or more type to be called by the
+ * Compute Engine.
+ */
+@ComputeEngineSide
+@ServerSide
+public interface CeTaskProcessor {
+
+ /**
+ * The {@link CeTask#getType()} for which this {@link CeTaskProcessor} provides the processing code.
+ * <p>
+ * The match of type is done using {@link String#equals(Object)} and if more than one {@link CeTaskProcessor} declares
+ * itself had handler for the same {@link CeTask#getType()}, an error will be raised at startup and startup will
+ * fail.
+ * </p>
+ * <p>
+ * If an empty {@link Set} is returned, the {@link CeTaskProcessor} will be ignored.
+ * </p>
+ */
+ Set<String> getHandledCeTaskTypes();
+
+ /**
+ * Calls the processing code for a specific {@link CeTask} which will optionally return a {@link CeTaskResult}
+ * holding information to be persisted in the processing history of the Compute Engine (currently the {@code CE_ACTIVITY} table).
+ * <p>
+ * The specified is guaranteed to be non {@code null} and its {@link CeTask#getType()} to be one of the values
+ * of {@link #getHandledCeTaskTypes()}.
+ * </p>
+ *
+ * @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.
+ */
+ @CheckForNull
+ CeTaskResult process(CeTask task);
+}