org.sonar.ce.taskprocessor.CeTaskProcessor Maven / Gradle / Ivy
/*
* 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.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.queue.CeTask;
import org.sonar.ce.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
* Compute Engine.
*/
@ComputeEngineSide
@ServerSide
public interface CeTaskProcessor {
/**
* The {@link CeTask#getType()} for which this {@link CeTaskProcessor} provides the processing code.
*
* 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.
*
*
* If an empty {@link Set} is returned, the {@link CeTaskProcessor} will be ignored.
*
*/
Set 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).
*
* The specified is guaranteed to be non {@code null} and its {@link CeTask#getType()} to be one of the values
* of {@link #getHandledCeTaskTypes()}.
*
*
* @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);
}