MediaWiki REL1_37
JobQueueGroup Class Reference

Class to handle enqueueing of background jobs. More...

Collaboration diagram for JobQueueGroup:

Public Member Functions

 __construct ( $domain, ConfiguredReadOnlyMode $readOnlyMode, bool $invalidDomain, array $jobClasses, 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 a job off one of the job queues.
 
 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.
 

Static Public Member Functions

static destroySingletons ()
 Destroy the singleton instances.
 
static singleton ( $domain=false)
 

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.
 
bool $invalidDomain = false
 Whether the wiki is not recognized in configuration.
 
ConfiguredReadOnlyMode $readOnlyMode
 Read only mode.
 

Static Protected Attributes

static JobQueueGroup[] $instances = []
 

Private Member Functions

 assertValidJobs (array $jobs)
 
 getCachedConfigVar ( $name)
 

Private Attributes

GlobalIdGenerator $globalIdGenerator
 
array $jobClasses
 
array $jobTypeConfiguration
 
array $jobTypesExcludedFromDefaultQueue
 
IBufferingStatsdDataFactory $statsdDataFactory
 
WANObjectCache $wanCache
 
const CACHE_VERSION = 1
 
const PROC_CACHE_TTL = 15
 
const TYPE_ANY = 2
 

Detailed Description

Class to handle enqueueing of background jobs.

Since
1.21

Definition at line 32 of file JobQueueGroup.php.

Constructor & Destructor Documentation

◆ __construct()

JobQueueGroup::__construct (   $domain,
ConfiguredReadOnlyMode  $readOnlyMode,
bool  $invalidDomain,
array  $jobClasses,
array  $jobTypeConfiguration,
array  $jobTypesExcludedFromDefaultQueue,
IBufferingStatsdDataFactory  $statsdDataFactory,
WANObjectCache  $wanCache,
GlobalIdGenerator  $globalIdGenerator 
)
Access: internal
Use MediaWikiServices::getJobQueueGroupFactory
Parameters
string$domainWiki domain ID
ConfiguredReadOnlyMode$readOnlyModeRead-only mode
bool$invalidDomainWhether the wiki is not recognized in configuration
array$jobClasses
array$jobTypeConfiguration
array$jobTypesExcludedFromDefaultQueue
IBufferingStatsdDataFactory$statsdDataFactory
WANObjectCache$wanCache
GlobalIdGenerator$globalIdGenerator

Definition at line 86 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 295 of file JobQueueGroup.php.

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

Referenced by ack().

◆ assertValidJobs()

JobQueueGroup::assertValidJobs ( array  $jobs)
private
Parameters
array$jobs
Exceptions
InvalidArgumentException

Definition at line 478 of file JobQueueGroup.php.

References $job, and $type.

Referenced by lazyPush(), and push().

◆ 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.

Parameters
RunnableJob$job
Returns
bool

Definition at line 306 of file JobQueueGroup.php.

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

Referenced by deduplicateRootJob().

◆ destroySingletons()

static JobQueueGroup::destroySingletons ( )
static

Destroy the singleton instances.

Deprecated:
1.37
Returns
void

Definition at line 124 of file JobQueueGroup.php.

◆ get()

JobQueueGroup::get (   $type)

Get the job queue object for a given queue type.

Parameters
string$type
Returns
JobQueue

Definition at line 133 of file JobQueueGroup.php.

References $type, and JobQueue\factory().

Referenced by ApiUpload\__construct().

◆ getCachedConfigVar()

JobQueueGroup::getCachedConfigVar (   $name)
private
Parameters
string$name
Returns
mixed

Definition at line 452 of file JobQueueGroup.php.

References $cache, and $wgConf.

Referenced by getQueueTypes().

◆ getCoalescedQueues()

JobQueueGroup::getCoalescedQueues ( )
protected
Returns
array[]

Definition at line 418 of file JobQueueGroup.php.

References $queue, $type, JobQueue\factory(), and getQueueTypes().

Referenced by getQueueSizes(), and getQueuesWithJobs().

◆ getDefaultQueueTypes()

JobQueueGroup::getDefaultQueueTypes ( )

Get the list of default queue types.

Returns
string[]

Definition at line 338 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.

Returns
int[] Map of (job type => size)

Definition at line 396 of file JobQueueGroup.php.

References $queue, $type, getCoalescedQueues(), and getQueueTypes().

◆ getQueuesWithJobs()

JobQueueGroup::getQueuesWithJobs ( )

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

Returns
string[] List of job types that have non-empty queues

Definition at line 371 of file JobQueueGroup.php.

References $queue, $type, getCoalescedQueues(), and getQueueTypes().

Referenced by pop(), and queuesHaveJobs().

◆ getQueueTypes()

JobQueueGroup::getQueueTypes ( )

Get the list of queue types.

Returns
string[]

Definition at line 329 of file JobQueueGroup.php.

References getCachedConfigVar().

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 214 of file JobQueueGroup.php.

References assertValidJobs(), and push().

◆ pop()

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

Pop a job off one of the job queues.

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|bool Returns false on failure

Definition at line 244 of file JobQueueGroup.php.

References $job, $type, 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
Exceptions
InvalidArgumentException
Returns
void

Definition at line 161 of file JobQueueGroup.php.

References $cache, $job, $type, assertValidJobs(), and push().

Referenced by lazyPush(), and push().

◆ queuesHaveJobs()

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

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

Parameters
int$typeJobQueueGroup::TYPE_* constant
Returns
bool
Since
1.23

Definition at line 349 of file JobQueueGroup.php.

References $cache, $type, getDefaultQueueTypes(), and getQueuesWithJobs().

◆ singleton()

static JobQueueGroup::singleton (   $domain = false)
static
Deprecated:
1.37 Use JobQueueGroupFactory::makeJobQueueGroup
Parameters
bool | string$domainWiki domain ID
Returns
JobQueueGroup

Definition at line 114 of file JobQueueGroup.php.

◆ waitForBackups()

JobQueueGroup::waitForBackups ( )

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

This does nothing for certain queue classes.

Returns
void

Definition at line 317 of file JobQueueGroup.php.

References $type, and waitForBackups().

Referenced by waitForBackups().

Member Data Documentation

◆ $cache

MapCacheLRU JobQueueGroup::$cache
protected

Definition at line 40 of file JobQueueGroup.php.

◆ $coalescedQueues

array JobQueueGroup::$coalescedQueues
protected

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

Definition at line 62 of file JobQueueGroup.php.

◆ $domain

string JobQueueGroup::$domain
protected

Wiki domain ID.

Definition at line 43 of file JobQueueGroup.php.

◆ $globalIdGenerator

GlobalIdGenerator JobQueueGroup::$globalIdGenerator
private

Definition at line 59 of file JobQueueGroup.php.

◆ $instances

JobQueueGroup [] JobQueueGroup::$instances = []
staticprotected
Deprecated:
1.37

Definition at line 37 of file JobQueueGroup.php.

◆ $invalidDomain

bool JobQueueGroup::$invalidDomain = false
protected

Whether the wiki is not recognized in configuration.

Definition at line 47 of file JobQueueGroup.php.

◆ $jobClasses

array JobQueueGroup::$jobClasses
private

Definition at line 49 of file JobQueueGroup.php.

◆ $jobTypeConfiguration

array JobQueueGroup::$jobTypeConfiguration
private

Definition at line 51 of file JobQueueGroup.php.

◆ $jobTypesExcludedFromDefaultQueue

array JobQueueGroup::$jobTypesExcludedFromDefaultQueue
private

Definition at line 53 of file JobQueueGroup.php.

◆ $readOnlyMode

ConfiguredReadOnlyMode JobQueueGroup::$readOnlyMode
protected

Read only mode.

Definition at line 45 of file JobQueueGroup.php.

◆ $statsdDataFactory

IBufferingStatsdDataFactory JobQueueGroup::$statsdDataFactory
private

Definition at line 55 of file JobQueueGroup.php.

◆ $wanCache

WANObjectCache JobQueueGroup::$wanCache
private

Definition at line 57 of file JobQueueGroup.php.

◆ CACHE_VERSION

const JobQueueGroup::CACHE_VERSION = 1
private

Definition at line 71 of file JobQueueGroup.php.

◆ PROC_CACHE_TTL

const JobQueueGroup::PROC_CACHE_TTL = 15
private

Definition at line 69 of file JobQueueGroup.php.

◆ TYPE_ANY

const JobQueueGroup::TYPE_ANY = 2
private

Definition at line 65 of file JobQueueGroup.php.

◆ TYPE_DEFAULT

const JobQueueGroup::TYPE_DEFAULT = 1

Definition at line 64 of file JobQueueGroup.php.

◆ USE_CACHE

const JobQueueGroup::USE_CACHE = 1

Definition at line 67 of file JobQueueGroup.php.


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