4 * A wrapper for the JobQueue that delegates all the method calls to a single,
5 * main queue, and also pushes all the jobs to a second job queue that's being
8 * This class was temporary added to test transitioning to the JobQueueEventBus
9 * and will removed after the transition is completed. This code is only needed
10 * while we are testing the new infrastructure to be able to compare the results
11 * between the queue implementations and make sure that they process the same jobs,
12 * deduplicate correctly, compare the delays, backlogs and make sure no jobs are lost.
13 * When the new infrastructure is well tested this will not be needed any more.
15 * @deprecated since 1.30
18 class JobQueueSecondTestQueue
extends JobQueue
{
30 protected function __construct( array $params ) {
31 if ( !isset( $params['mainqueue'] ) ) {
32 throw new MWException( "mainqueue parameter must be provided to the debug queue" );
35 if ( !isset( $params['debugqueue'] ) ) {
36 throw new MWException( "debugqueue parameter must be provided to the debug queue" );
39 $conf = [ 'wiki' => $params['wiki'], 'type' => $params['type'] ];
40 $this->mainQueue
= JobQueue
::factory( $params['mainqueue'] +
$conf );
41 $this->debugQueue
= JobQueue
::factory( $params['debugqueue'] +
$conf );
43 // We need to construct parent after creating the main and debug queue
44 // because super constructor calls some methods we delegate to the main queue.
45 parent
::__construct( $params );
49 * Get the allowed queue orders for configuration validation
51 * @return array Subset of (random, timestamp, fifo, undefined)
53 protected function supportedOrders() {
54 return $this->mainQueue
->supportedOrders();
58 * Get the default queue order to use if configuration does not specify one
60 * @return string One of (random, timestamp, fifo, undefined)
62 protected function optimalOrder() {
63 return $this->mainQueue
->optimalOrder();
67 * Find out if delayed jobs are supported for configuration validation
69 * @return bool Whether delayed jobs are supported
71 protected function supportsDelayedJobs() {
72 return $this->mainQueue
->supportsDelayedJobs();
76 * @see JobQueue::isEmpty()
79 protected function doIsEmpty() {
80 return $this->mainQueue
->doIsEmpty();
84 * @see JobQueue::getSize()
87 protected function doGetSize() {
88 return $this->mainQueue
->doGetSize();
92 * @see JobQueue::getAcquiredCount()
95 protected function doGetAcquiredCount() {
96 return $this->mainQueue
->doGetAcquiredCount();
100 * @see JobQueue::getDelayedCount()
103 protected function doGetDelayedCount() {
104 return $this->mainQueue
->doGetDelayedCount();
108 * @see JobQueue::getAbandonedCount()
111 protected function doGetAbandonedCount() {
112 return $this->mainQueue
->doGetAbandonedCount();
116 * @see JobQueue::batchPush()
117 * @param IJobSpecification[] $jobs
120 protected function doBatchPush( array $jobs, $flags ) {
121 $this->mainQueue
->doBatchPush( $jobs, $flags );
124 $this->debugQueue
->doBatchPush( $jobs, $flags );
125 } catch ( Exception
$exception ) {
126 MWExceptionHandler
::logException( $exception );
131 * @see JobQueue::pop()
134 protected function doPop() {
135 return $this->mainQueue
->doPop();
139 * @see JobQueue::ack()
142 protected function doAck( Job
$job ) {
143 return $this->mainQueue
->doAck( $job );
147 * @see JobQueue::deduplicateRootJob()
148 * @param IJobSpecification $job
149 * @throws MWException
152 protected function doDeduplicateRootJob( IJobSpecification
$job ) {
153 return $this->mainQueue
->doDeduplicateRootJob( $job );
157 * @see JobQueue::isRootJobOldDuplicate()
161 protected function doIsRootJobOldDuplicate( Job
$job ) {
162 return $this->mainQueue
->doIsRootJobOldDuplicate( $job );
166 * @param string $signature Hash identifier of the root job
169 protected function getRootJobCacheKey( $signature ) {
170 return $this->mainQueue
->getRootJobCacheKey( $signature );
174 * @see JobQueue::delete()
175 * @throws MWException
177 protected function doDelete() {
178 return $this->mainQueue
->doDelete();
182 * @see JobQueue::waitForBackups()
185 protected function doWaitForBackups() {
186 $this->mainQueue
->doWaitForBackups();
190 * @see JobQueue::flushCaches()
193 protected function doFlushCaches() {
194 $this->mainQueue
->doFlushCaches();
198 * Get an iterator to traverse over all available jobs in this queue.
199 * This does not include jobs that are currently acquired or delayed.
200 * Note: results may be stale if the queue is concurrently modified.
203 * @throws JobQueueError
205 public function getAllQueuedJobs() {
206 return $this->mainQueue
->getAllQueuedJobs();
210 * Get an iterator to traverse over all delayed jobs in this queue.
211 * Note: results may be stale if the queue is concurrently modified.
214 * @throws JobQueueError
217 public function getAllDelayedJobs() {
218 return $this->mainQueue
->getAllDelayedJobs();
222 * Get an iterator to traverse over all claimed jobs in this queue
224 * Callers should be quick to iterator over it or few results
225 * will be returned due to jobs being acknowledged and deleted
228 * @throws JobQueueError
231 public function getAllAcquiredJobs() {
232 return $this->mainQueue
->getAllAcquiredJobs();
236 * Get an iterator to traverse over all abandoned jobs in this queue
239 * @throws JobQueueError
242 public function getAllAbandonedJobs() {
243 return $this->mainQueue
->getAllAbandonedJobs();
247 * Do not use this function outside of JobQueue/JobQueueGroup
252 public function getCoalesceLocationInternal() {
253 return $this->mainQueue
->getCoalesceLocationInternal();
257 * @see JobQueue::getSiblingQueuesWithJobs()
258 * @param array $types List of queues types
259 * @return array|null (list of queue types) or null if unsupported
261 protected function doGetSiblingQueuesWithJobs( array $types ) {
262 return $this->mainQueue
->doGetSiblingQueuesWithJobs( $types );
266 * @see JobQueue::getSiblingQueuesSize()
267 * @param array $types List of queues types
268 * @return array|null (list of queue types) or null if unsupported
270 protected function doGetSiblingQueueSizes( array $types ) {
271 return $this->mainQueue
->doGetSiblingQueueSizes( $types );
275 * @throws JobQueueReadOnlyError
277 protected function assertNotReadOnly() {
278 $this->mainQueue
->assertNotReadOnly();