--- /dev/null
+/*
+ * 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();
+}
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
* @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);
}
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;
}
@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();
}
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;
}
@Override
- public void process(CeTask task) {
+ public CeTaskResult process(CeTask task) {
throw new UnsupportedOperationException("Process is not implemented");
}
}
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;
}
@Override
- public void process(CeTask task) {
+ public CeTaskResult process(CeTask task) {
throw new UnsupportedOperationException(UOE_MESSAGE);
}
}