MediaWiki master
JobQueueGroup Class Reference

Handle enqueueing of background jobs. More...

Collaboration diagram for JobQueueGroup:

Public Member Functions

 __construct ( $domain, ReadOnlyMode $readOnlyMode, ?array $localJobClasses, array $jobTypeConfiguration, array $jobTypesExcludedFromDefaultQueue, IBufferingStatsdDataFactory $statsdDataFactory, WANObjectCache $wanCache, GlobalIdGenerator $globalIdGenerator)
 
 ack (RunnableJob $job)
 Acknowledge that a job was completed.
 
 deduplicateRootJob (RunnableJob $job)
 Register the "root job" of a given job into the queue for de-duplication.
 
 get ( $type)
 Get the job queue object for a given queue type.
 
 getDefaultQueueTypes ()
 Get the list of default queue types.
 
 getQueueSizes ()
 Get the size of the queues for a list of job types.
 
 getQueuesWithJobs ()
 Get the list of job types that have non-empty queues.
 
 getQueueTypes ()
 Get the list of queue types.
 
 lazyPush ( $jobs)
 Buffer jobs for insertion via push() or call it now if in CLI mode.
 
 pop ( $qtype=self::TYPE_DEFAULT, $flags=0, array $ignored=[])
 Pop one job off a job queue.
 
 push ( $jobs)
 Insert jobs into the respective queues of which they belong.
 
 queuesHaveJobs ( $type=self::TYPE_ANY)
 Check if there are any queues with jobs (this is cached)
 
 waitForBackups ()
 Wait for any replica DBs or backup queue servers to catch up.
 

Public Attributes

const TYPE_DEFAULT = 1
 
const USE_CACHE = 1
 

Protected Member Functions

 getCoalescedQueues ()
 

Protected Attributes

MapCacheLRU $cache
 
array $coalescedQueues
 Map of (bucket => (queue => JobQueue, types => list of types)
 
string $domain
 Wiki domain ID.
 
ReadOnlyMode $readOnlyMode
 Read only mode.
 

Detailed Description

Handle enqueueing of background jobs.

Warning
This service class supports queuing jobs to foreign wikis via JobQueueGroupFactory, but other operations may be called for the local wiki only. Exceptions may be thrown if you attempt to inspect, pop, or execute a foreign wiki's job queue.
Since
1.21

Definition at line 36 of file JobQueueGroup.php.

Constructor & Destructor Documentation

◆ __construct()

JobQueueGroup::__construct (   $domain,
ReadOnlyMode  $readOnlyMode,
?array  $localJobClasses,
array  $jobTypeConfiguration,
array  $jobTypesExcludedFromDefaultQueue,
IBufferingStatsdDataFactory  $statsdDataFactory,
WANObjectCache  $wanCache,
GlobalIdGenerator  $globalIdGenerator 
)
Access: internal
Use MediaWikiServices::getJobQueueGroupFactory
Parameters
string$domainWiki domain ID
ReadOnlyMode$readOnlyModeRead-only mode
array | null$localJobClasses
array$jobTypeConfiguration
array$jobTypesExcludedFromDefaultQueue
IBufferingStatsdDataFactory$statsdDataFactory
WANObjectCache$wanCache
GlobalIdGenerator$globalIdGenerator

Definition at line 79 of file JobQueueGroup.php.

Member Function Documentation

◆ ack()

JobQueueGroup::ack ( RunnableJob  $job)

Acknowledge that a job was completed.

Parameters
RunnableJob$job
Returns
void

Definition at line 267 of file JobQueueGroup.php.

References $job, ack(), and IJobSpecification\getType().

Referenced by ack().

◆ deduplicateRootJob()

JobQueueGroup::deduplicateRootJob ( RunnableJob  $job)

Register the "root job" of a given job into the queue for de-duplication.

This should only be called right after all the new jobs have been inserted.

Deprecated:
since 1.40
Parameters
RunnableJob$job
Returns
bool

Definition at line 279 of file JobQueueGroup.php.

References wfDeprecated().

◆ get()

JobQueueGroup::get (   $type)

Get the job queue object for a given queue type.

Parameters
string$type
Returns
JobQueue

Definition at line 106 of file JobQueueGroup.php.

References JobQueue\factory().

Referenced by ApiUpload\__construct().

◆ getCoalescedQueues()

JobQueueGroup::getCoalescedQueues ( )
protected
Returns
array[]

Definition at line 408 of file JobQueueGroup.php.

References JobQueue\factory(), and getQueueTypes().

Referenced by getQueueSizes(), and getQueuesWithJobs().

◆ getDefaultQueueTypes()

JobQueueGroup::getDefaultQueueTypes ( )

Get the list of default queue types.

Warning
May not be called on foreign wikis!
Returns
string[]

Definition at line 322 of file JobQueueGroup.php.

References getQueueTypes().

Referenced by pop(), and queuesHaveJobs().

◆ getQueueSizes()

JobQueueGroup::getQueueSizes ( )

Get the size of the queues for a list of job types.

Warning
May not be called on foreign wikis!
Returns
int[] Map of (job type => size)

Definition at line 386 of file JobQueueGroup.php.

References getCoalescedQueues(), and getQueueTypes().

◆ getQueuesWithJobs()

JobQueueGroup::getQueuesWithJobs ( )

Get the list of job types that have non-empty queues.

Warning
May not be called on foreign wikis!
Returns
string[] List of job types that have non-empty queues

Definition at line 359 of file JobQueueGroup.php.

References getCoalescedQueues(), and getQueueTypes().

Referenced by pop(), and queuesHaveJobs().

◆ getQueueTypes()

JobQueueGroup::getQueueTypes ( )

Get the list of queue types.

Warning
May not be called on foreign wikis!
Returns
string[]

Definition at line 308 of file JobQueueGroup.php.

Referenced by getCoalescedQueues(), getDefaultQueueTypes(), getQueueSizes(), and getQueuesWithJobs().

◆ lazyPush()

JobQueueGroup::lazyPush (   $jobs)

Buffer jobs for insertion via push() or call it now if in CLI mode.

Parameters
IJobSpecification | IJobSpecification[]$jobsA single Job or a list of Jobs
Returns
void
Since
1.26

Definition at line 187 of file JobQueueGroup.php.

References push().

◆ pop()

JobQueueGroup::pop (   $qtype = self::TYPE_DEFAULT,
  $flags = 0,
array  $ignored = [] 
)

Pop one job off a job queue.

Warning
May not be called on foreign wikis!

This pops a job off a queue as specified by $wgJobTypeConf and updates the aggregate job queue information cache as needed.

Parameters
int | string$qtypeJobQueueGroup::TYPE_* constant or job type string
int$flagsBitfield of JobQueueGroup::USE_* constants
array$ignoredList of job types to ignore
Returns
RunnableJob|false Returns false on failure
Exceptions
JobQueueError

Definition at line 215 of file JobQueueGroup.php.

References $job, getDefaultQueueTypes(), getQueuesWithJobs(), and pop().

Referenced by pop().

◆ push()

JobQueueGroup::push (   $jobs)

Insert jobs into the respective queues of which they belong.

This inserts the jobs into the queue specified by $wgJobTypeConf and updates the aggregate job queue information cache as needed.

Parameters
IJobSpecification | IJobSpecification[]$jobsA single Job or a list of Jobs
Returns
void

Definition at line 129 of file JobQueueGroup.php.

References $job, push(), and MapCacheLRU\set().

Referenced by lazyPush(), and push().

◆ queuesHaveJobs()

JobQueueGroup::queuesHaveJobs (   $type = self::TYPE_ANY)

Check if there are any queues with jobs (this is cached)

Warning
May not be called on foreign wikis!
Since
1.23
Parameters
int$typeJobQueueGroup::TYPE_* constant
Returns
bool

Definition at line 335 of file JobQueueGroup.php.

References MapCacheLRU\get(), getDefaultQueueTypes(), and getQueuesWithJobs().

◆ waitForBackups()

JobQueueGroup::waitForBackups ( )

Wait for any replica DBs or backup queue servers to catch up.

This does nothing for certain queue classes.

Deprecated:
since 1.41, use JobQueue::waitForBackups() instead.
Returns
void

Definition at line 293 of file JobQueueGroup.php.

References waitForBackups(), and wfDeprecated().

Referenced by waitForBackups().

Member Data Documentation

◆ $cache

MapCacheLRU JobQueueGroup::$cache
protected

Definition at line 38 of file JobQueueGroup.php.

◆ $coalescedQueues

array JobQueueGroup::$coalescedQueues
protected

Map of (bucket => (queue => JobQueue, types => list of types)

Definition at line 58 of file JobQueueGroup.php.

◆ $domain

string JobQueueGroup::$domain
protected

Wiki domain ID.

Definition at line 41 of file JobQueueGroup.php.

◆ $readOnlyMode

ReadOnlyMode JobQueueGroup::$readOnlyMode
protected

Read only mode.

Definition at line 43 of file JobQueueGroup.php.

◆ TYPE_DEFAULT

const JobQueueGroup::TYPE_DEFAULT = 1

Definition at line 60 of file JobQueueGroup.php.

◆ USE_CACHE

const JobQueueGroup::USE_CACHE = 1

Definition at line 63 of file JobQueueGroup.php.


The documentation for this class was generated from the following file: