MediaWiki  REL1_31
JobQueueSecondTestQueue.php
Go to the documentation of this file.
1 <?php
2 
19 
23  private $mainQueue;
24 
28  private $debugQueue;
29 
34 
35  protected function __construct( array $params ) {
36  if ( !isset( $params['mainqueue'] ) ) {
37  throw new MWException( "mainqueue parameter must be provided to the debug queue" );
38  }
39 
40  if ( !isset( $params['debugqueue'] ) ) {
41  throw new MWException( "debugqueue parameter must be provided to the debug queue" );
42  }
43 
44  $conf = [ 'wiki' => $params['wiki'], 'type' => $params['type'] ];
45  $this->mainQueue = JobQueue::factory( $params['mainqueue'] + $conf );
46  $this->debugQueue = JobQueue::factory( $params['debugqueue'] + $conf );
47  $this->onlyWriteToDebugQueue = isset( $params['readonly'] ) ? $params['readonly'] : false;
48 
49  // We need to construct parent after creating the main and debug queue
50  // because super constructor calls some methods we delegate to the main queue.
51  parent::__construct( $params );
52  }
53 
59  protected function supportedOrders() {
60  return $this->mainQueue->supportedOrders();
61  }
62 
68  protected function optimalOrder() {
69  return $this->mainQueue->optimalOrder();
70  }
71 
77  protected function supportsDelayedJobs() {
78  return $this->mainQueue->supportsDelayedJobs();
79  }
80 
85  protected function doIsEmpty() {
86  return $this->mainQueue->doIsEmpty();
87  }
88 
93  protected function doGetSize() {
94  return $this->mainQueue->doGetSize();
95  }
96 
101  protected function doGetAcquiredCount() {
102  return $this->mainQueue->doGetAcquiredCount();
103  }
104 
109  protected function doGetDelayedCount() {
110  return $this->mainQueue->doGetDelayedCount();
111  }
112 
117  protected function doGetAbandonedCount() {
118  return $this->mainQueue->doGetAbandonedCount();
119  }
120 
126  protected function doBatchPush( array $jobs, $flags ) {
127  if ( !$this->onlyWriteToDebugQueue ) {
128  $this->mainQueue->doBatchPush( $jobs, $flags );
129  }
130 
131  try {
132  $this->debugQueue->doBatchPush( $jobs, $flags );
133  } catch ( Exception $exception ) {
134  MWExceptionHandler::logException( $exception );
135  }
136  }
137 
142  protected function doPop() {
143  return $this->mainQueue->doPop();
144  }
145 
151  protected function doAck( Job $job ) {
152  return $this->mainQueue->doAck( $job );
153  }
154 
162  return $this->mainQueue->doDeduplicateRootJob( $job );
163  }
164 
170  protected function doIsRootJobOldDuplicate( Job $job ) {
171  return $this->mainQueue->doIsRootJobOldDuplicate( $job );
172  }
173 
178  protected function getRootJobCacheKey( $signature ) {
179  return $this->mainQueue->getRootJobCacheKey( $signature );
180  }
181 
187  protected function doDelete() {
188  return $this->mainQueue->doDelete();
189  }
190 
195  protected function doWaitForBackups() {
196  $this->mainQueue->doWaitForBackups();
197  }
198 
203  protected function doFlushCaches() {
204  $this->mainQueue->doFlushCaches();
205  }
206 
215  public function getAllQueuedJobs() {
216  return $this->mainQueue->getAllQueuedJobs();
217  }
218 
227  public function getAllDelayedJobs() {
228  return $this->mainQueue->getAllDelayedJobs();
229  }
230 
241  public function getAllAcquiredJobs() {
242  return $this->mainQueue->getAllAcquiredJobs();
243  }
244 
252  public function getAllAbandonedJobs() {
253  return $this->mainQueue->getAllAbandonedJobs();
254  }
255 
262  public function getCoalesceLocationInternal() {
263  return $this->mainQueue->getCoalesceLocationInternal();
264  }
265 
271  protected function doGetSiblingQueuesWithJobs( array $types ) {
272  return $this->mainQueue->doGetSiblingQueuesWithJobs( $types );
273  }
274 
280  protected function doGetSiblingQueueSizes( array $types ) {
281  return $this->mainQueue->doGetSiblingQueueSizes( $types );
282  }
283 
287  protected function assertNotReadOnly() {
288  $this->mainQueue->assertNotReadOnly();
289  }
290 }
JobQueueSecondTestQueue\__construct
__construct(array $params)
Definition: JobQueueSecondTestQueue.php:35
JobQueueSecondTestQueue\getAllAcquiredJobs
getAllAcquiredJobs()
Get an iterator to traverse over all claimed jobs in this queue.
Definition: JobQueueSecondTestQueue.php:241
JobQueueSecondTestQueue\supportsDelayedJobs
supportsDelayedJobs()
Find out if delayed jobs are supported for configuration validation.
Definition: JobQueueSecondTestQueue.php:77
array
the array() calling protocol came about after MediaWiki 1.4rc1.
JobQueueSecondTestQueue\getAllAbandonedJobs
getAllAbandonedJobs()
Get an iterator to traverse over all abandoned jobs in this queue.
Definition: JobQueueSecondTestQueue.php:252
JobQueueSecondTestQueue\$onlyWriteToDebugQueue
bool $onlyWriteToDebugQueue
Definition: JobQueueSecondTestQueue.php:33
JobQueueSecondTestQueue\doDeduplicateRootJob
doDeduplicateRootJob(IJobSpecification $job)
Definition: JobQueueSecondTestQueue.php:161
$params
$params
Definition: styleTest.css.php:40
JobQueueSecondTestQueue\$debugQueue
JobQueue $debugQueue
Definition: JobQueueSecondTestQueue.php:28
JobQueueSecondTestQueue\doGetSize
doGetSize()
Definition: JobQueueSecondTestQueue.php:93
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:37
Job
Class to both describe a background job and handle jobs.
Definition: Job.php:31
JobQueueSecondTestQueue\doGetAbandonedCount
doGetAbandonedCount()
Definition: JobQueueSecondTestQueue.php:117
JobQueueSecondTestQueue\getRootJobCacheKey
getRootJobCacheKey( $signature)
Definition: JobQueueSecondTestQueue.php:178
MWException
MediaWiki exception.
Definition: MWException.php:26
JobQueueSecondTestQueue\doBatchPush
doBatchPush(array $jobs, $flags)
Definition: JobQueueSecondTestQueue.php:126
JobQueueSecondTestQueue\doGetSiblingQueueSizes
doGetSiblingQueueSizes(array $types)
Definition: JobQueueSecondTestQueue.php:280
JobQueueSecondTestQueue\doGetAcquiredCount
doGetAcquiredCount()
Definition: JobQueueSecondTestQueue.php:101
JobQueueSecondTestQueue\doGetDelayedCount
doGetDelayedCount()
Definition: JobQueueSecondTestQueue.php:109
JobQueueSecondTestQueue\doWaitForBackups
doWaitForBackups()
Definition: JobQueueSecondTestQueue.php:195
JobQueueSecondTestQueue\doPop
doPop()
Definition: JobQueueSecondTestQueue.php:142
JobQueue\factory
static factory(array $params)
Get a job queue object of the specified type.
Definition: JobQueue.php:108
JobQueueSecondTestQueue\doAck
doAck(Job $job)
Definition: JobQueueSecondTestQueue.php:151
JobQueueSecondTestQueue\optimalOrder
optimalOrder()
Get the default queue order to use if configuration does not specify one.
Definition: JobQueueSecondTestQueue.php:68
JobQueueSecondTestQueue
A wrapper for the JobQueue that delegates all the method calls to a single, main queue,...
Definition: JobQueueSecondTestQueue.php:18
$job
if(count( $args)< 1) $job
Definition: recompressTracked.php:47
JobQueueSecondTestQueue\getAllDelayedJobs
getAllDelayedJobs()
Get an iterator to traverse over all delayed jobs in this queue.
Definition: JobQueueSecondTestQueue.php:227
JobQueueSecondTestQueue\doDelete
doDelete()
Definition: JobQueueSecondTestQueue.php:187
JobQueue
Class to handle enqueueing and running of background jobs.
Definition: JobQueue.php:31
JobQueueSecondTestQueue\supportedOrders
supportedOrders()
Get the allowed queue orders for configuration validation.
Definition: JobQueueSecondTestQueue.php:59
JobQueueSecondTestQueue\doIsRootJobOldDuplicate
doIsRootJobOldDuplicate(Job $job)
Definition: JobQueueSecondTestQueue.php:170
JobQueueSecondTestQueue\getCoalesceLocationInternal
getCoalesceLocationInternal()
Do not use this function outside of JobQueue/JobQueueGroup.
Definition: JobQueueSecondTestQueue.php:262
JobQueueSecondTestQueue\assertNotReadOnly
assertNotReadOnly()
Definition: JobQueueSecondTestQueue.php:287
JobQueueSecondTestQueue\doFlushCaches
doFlushCaches()
Definition: JobQueueSecondTestQueue.php:203
JobQueueSecondTestQueue\$mainQueue
JobQueue $mainQueue
Definition: JobQueueSecondTestQueue.php:23
JobQueueSecondTestQueue\getAllQueuedJobs
getAllQueuedJobs()
Get an iterator to traverse over all available jobs in this queue.
Definition: JobQueueSecondTestQueue.php:215
JobQueueSecondTestQueue\doIsEmpty
doIsEmpty()
Definition: JobQueueSecondTestQueue.php:85
IJobSpecification
Job queue task description interface.
Definition: JobSpecification.php:29
MWExceptionHandler\logException
static logException( $e, $catcher=self::CAUGHT_BY_OTHER)
Log an exception to the exception log (if enabled).
Definition: MWExceptionHandler.php:645
JobQueueSecondTestQueue\doGetSiblingQueuesWithJobs
doGetSiblingQueuesWithJobs(array $types)
Definition: JobQueueSecondTestQueue.php:271