You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InternalCeQueue.java 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.ce.queue;
  21. import java.util.Optional;
  22. import java.util.Set;
  23. import javax.annotation.Nullable;
  24. import org.sonar.ce.task.CeTask;
  25. import org.sonar.ce.task.CeTaskResult;
  26. import org.sonar.db.ce.CeActivityDto.Status;
  27. /**
  28. * Queue of pending Compute Engine tasks. Both producer and consumer actions
  29. * are implemented.
  30. * <p>
  31. * This class is decoupled from the regular task type {@link org.sonar.db.ce.CeTaskTypes#REPORT}.
  32. * </p>
  33. */
  34. public interface InternalCeQueue extends CeQueue {
  35. /**
  36. * Peek the oldest task in status {@link org.sonar.db.ce.CeQueueDto.Status#PENDING}.
  37. * The task status is changed to {@link org.sonar.db.ce.CeQueueDto.Status#IN_PROGRESS}.
  38. * Does not return anything if workers are paused or being paused (see {@link #getWorkersPauseStatus()}.
  39. *
  40. * @param excludeIndexationJob change the underlying request to exclude indexing tasks.
  41. *
  42. * <p>Only a single task can be peeked by project.</p>
  43. *
  44. * <p>An unchecked exception may be thrown on technical errors (db connection, ...).</p>
  45. *
  46. * <p>Tasks which have been executed twice already but are still {@link org.sonar.db.ce.CeQueueDto.Status#PENDING}
  47. * are ignored</p>
  48. */
  49. Optional<CeTask> peek(String workerUuid, boolean excludeIndexationJob);
  50. /**
  51. * Removes a task from the queue and registers it to past activities. This method
  52. * is called by Compute Engine workers when task is processed and can include an option {@link CeTaskResult} object.
  53. *
  54. * @throws IllegalStateException if the task does not exist in the queue
  55. * @throws IllegalArgumentException if {@code error} is non {@code null} but {@code status} is not {@link Status#FAILED}
  56. */
  57. void remove(CeTask task, Status status, @Nullable CeTaskResult taskResult, @Nullable Throwable error);
  58. void cancelWornOuts();
  59. void resetTasksWithUnknownWorkerUUIDs(Set<String> knownWorkerUUIDs);
  60. }