All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.ce.queue.CeQueue Maven / Gradle / Ivy

There is a newer version: 7.2.1
Show newest version
/*
 * 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.queue;

import java.util.Collection;
import java.util.List;

import org.sonar.db.DbSession;
import org.sonar.db.ce.CeQueueDto;

/**
 * Queue of pending Compute Engine tasks. Both producer and consumer actions
 * are implemented.
 * 

* This class is decoupled from the regular task type {@link org.sonar.db.ce.CeTaskTypes#REPORT}. *

*/ public interface CeQueue { /** * Build an instance of {@link CeTaskSubmit} required for {@link #submit(CeTaskSubmit)}. It allows * to enforce that task ids are generated by the queue. It's used also for having access * to the id before submitting the task to the queue. */ CeTaskSubmit.Builder prepareSubmit(); /** * Submits a task to the queue. The task is processed asynchronously. *

* This method is equivalent to calling {@code massSubmit(Collections.singletonList(submission))}. *

* * @throws IllegalStateException If submits are paused (see {@link #isSubmitPaused()}) */ CeTask submit(CeTaskSubmit submission); /** * Submits multiple tasks to the queue at once. All tasks are processed asynchronously. *

* This method will perform significantly better that calling {@link #submit(CeTaskSubmit)} in a loop. *

* * @throws IllegalStateException If submits are paused (see {@link #isSubmitPaused()}) */ List massSubmit(Collection submissions); /** * Cancels a task in status {@link org.sonar.db.ce.CeQueueDto.Status#PENDING}. An unchecked * exception is thrown if the status is not {@link org.sonar.db.ce.CeQueueDto.Status#PENDING}. */ void cancel(DbSession dbSession, CeQueueDto ceQueueDto); /** * Removes all the tasks from the queue, except the tasks with status * {@link org.sonar.db.ce.CeQueueDto.Status#IN_PROGRESS} are ignored. They are marked * as {@link org.sonar.db.ce.CeActivityDto.Status#CANCELED} in past activity. * This method can be called at runtime, even if workers are being executed. * * @return the number of canceled tasks */ int cancelAll(); void pauseSubmit(); void resumeSubmit(); boolean isSubmitPaused(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy