MediaWiki  1.33.0
JobQueueGroup Class Reference

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

Collaboration diagram for JobQueueGroup:

Public Member Functions

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

Static Public Member Functions

static destroySingletons ()
 Destroy the singleton instances. More...
 
static pushLazyJobs ()
 Push all jobs buffered via lazyPush() into their respective queues. More...
 
static singleton ( $domain=false)
 

Public Attributes

const CACHE_VERSION = 1
 
const PROC_CACHE_TTL = 15
 
const TYPE_ANY = 2
 
const TYPE_DEFAULT = 1
 
const USE_CACHE = 1
 

Protected Member Functions

 __construct ( $domain, $readOnlyReason)
 
 getCoalescedQueues ()
 

Protected Attributes

ProcessCacheLRU $cache
 
array $coalescedQueues
 Map of (bucket => (queue => JobQueue, types => list of types) More...
 
string $domain
 Wiki domain ID. More...
 
bool $invalidDomain = false
 Whether the wiki is not recognized in configuration. More...
 
string bool $readOnlyReason
 Read only rationale (or false if r/w) More...
 

Static Protected Attributes

static JobQueueGroup[] $instances = []
 

Private Member Functions

 assertValidJobs (array $jobs)
 
 getCachedConfigVar ( $name)
 

Detailed Description

Class to handle enqueueing of background jobs.

Since
1.21

Definition at line 30 of file JobQueueGroup.php.

Constructor & Destructor Documentation

◆ __construct()

JobQueueGroup::__construct (   $domain,
  $readOnlyReason 
)
protected
Parameters
string$domainWiki domain ID
string | bool$readOnlyReasonRead-only reason or false

Definition at line 60 of file JobQueueGroup.php.

References $domain, $readOnlyReason, and cache.

Member Function Documentation

◆ ack()

JobQueueGroup::ack ( Job  $job)

Acknowledge that a job was completed.

Parameters
Job$job
Returns
void

Definition at line 292 of file JobQueueGroup.php.

References $job, and Job\getType().

◆ assertValidJobs()

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

Definition at line 475 of file JobQueueGroup.php.

References $job, and as.

Referenced by lazyPush(), and push().

◆ deduplicateRootJob()

JobQueueGroup::deduplicateRootJob ( Job  $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
Job$job
Returns
bool

Definition at line 303 of file JobQueueGroup.php.

References $job, and Job\getType().

◆ destroySingletons()

◆ get()

JobQueueGroup::get (   $type)

Get the job queue object for a given queue type.

Parameters
string$type
Returns
JobQueue

Definition at line 108 of file JobQueueGroup.php.

References $domain, $readOnlyReason, $services, $type, $wgJobTypeConf, and JobQueue\factory().

◆ getCachedConfigVar()

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

Definition at line 449 of file JobQueueGroup.php.

References $cache, $GLOBALS, $name, $value, $wgConf, WikiMap\getWikiIdFromDbDomain(), WikiMap\isCurrentWikiDbDomain(), IExpiringStore\TTL_PROC_LONG, and use.

Referenced by getQueueTypes().

◆ getCoalescedQueues()

JobQueueGroup::getCoalescedQueues ( )
protected
Returns
JobQueue[]

Definition at line 418 of file JobQueueGroup.php.

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

Referenced by getQueueSizes(), and getQueuesWithJobs().

◆ getDefaultQueueTypes()

JobQueueGroup::getDefaultQueueTypes ( )

Get the list of default queue types.

Returns
array List of strings

Definition at line 337 of file JobQueueGroup.php.

References $wgJobTypesExcludedFromDefaultQueue, and getQueueTypes().

Referenced by pop(), and queuesHaveJobs().

◆ getQueueSizes()

JobQueueGroup::getQueueSizes ( )

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

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

Definition at line 397 of file JobQueueGroup.php.

References $queue, $type, as, 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 372 of file JobQueueGroup.php.

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

Referenced by pop(), and queuesHaveJobs().

◆ getQueueTypes()

JobQueueGroup::getQueueTypes ( )

Get the list of queue types.

Returns
array List of strings

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

Note that pushLazyJobs() is registered as a deferred update just before DeferredUpdates::doUpdates() in MediaWiki and JobRunner classes in order to be executed as the very last deferred update (T100085, T154425).

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

Definition at line 198 of file JobQueueGroup.php.

References DeferredUpdates\addUpdate(), assertValidJobs(), and push().

◆ pop()

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

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$blacklistList of job types to ignore
Returns
Job|bool Returns false on failure

Definition at line 239 of file JobQueueGroup.php.

References $job, $type, $wgJobClasses, as, cache, getDefaultQueueTypes(), getQueuesWithJobs(), and WikiMap\isCurrentWikiDbDomain().

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

References $cache, $e, $job, $type, $wgJobTypesExcludedFromDefaultQueue, as, assertValidJobs(), cache, captcha-old\count, ObjectCache\getLocalClusterInstance(), MWExceptionHandler\logException(), and ProcessCacheLRU\set().

Referenced by lazyPush().

◆ pushLazyJobs()

static JobQueueGroup::pushLazyJobs ( )
static

Push all jobs buffered via lazyPush() into their respective queues.

Returns
void
Since
1.26
Deprecated:
Since 1.33 Not needed anymore

Definition at line 224 of file JobQueueGroup.php.

References wfDeprecated().

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

References $cache, $type, $value, captcha-old\count, ProcessCacheLRU\get(), getDefaultQueueTypes(), ObjectCache\getLocalClusterInstance(), and getQueuesWithJobs().

◆ singleton()

static JobQueueGroup::singleton (   $domain = false)
static
Parameters
bool | string$domainWiki domain ID
Returns
JobQueueGroup

Definition at line 70 of file JobQueueGroup.php.

References $domain, $wgLocalDatabases, WikiMap\getCurrentWikiDbDomain(), WikiMap\getWikiIdFromDbDomain(), WikiMap\isCurrentWikiDbDomain(), and wfConfiguredReadOnlyReason().

Referenced by MediaWikiTestCase\addCoreDBData(), WikiPage\doDeleteArticleBatched(), SpecialReplaceText\doSpecialReplaceText(), HTMLCacheUpdate\doUpdate(), JobQueueEnqueueUpdate\doUpdate(), CdnCacheUpdate\doUpdate(), DeferredUpdates\enqueueUpdates(), ManageJobs\execute(), CopyJobQueue\execute(), ShowJobs\execute(), DoubleRedirectJob\fixRedirects(), ApiUpload\getChunkResult(), ApiMain\getMaxLag(), UserGroupMembership\insert(), CreatePdfThumbnailsJob\insertJobs(), SiteStats\jobs(), WikiPage\newDerivedDataUpdater(), EmailNotification\notifyOnPageChange(), ApiUpload\performUpload(), LocalFile\prerenderThumbnails(), FixDoubleRedirects\queueJobs(), LinksUpdate\queueRecursiveJobs(), LinksUpdate\queueRecursiveJobsForTable(), RenameuserSQL\rename(), MediaWikiTestCase\resetNonServiceCaches(), ClearUserWatchlistJob\run(), NullJob\run(), HTMLCacheUpdateJob\run(), RefreshLinksJob\run(), EnqueueJob\run(), JobRunner\run(), LinksUpdateTest\runAllRelatedJobs(), DeferredUpdates\runUpdate(), RecentChange\save(), MediaWikiTestCase\teardownTestDB(), UploadFromUrlTest\testClearQueue(), SiteStatsTest\testJobsCountGetCached(), ClearUserWatchlistJobTest\testRun(), UploadFromUrlTest\testSyncDownload(), MediaWiki\triggerAsyncJobs(), and WikiPage\triggerOpportunisticLinksUpdate().

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

References $type, $wgJobTypeConf, and as.

Member Data Documentation

◆ $cache

ProcessCacheLRU JobQueueGroup::$cache
protected

Definition at line 35 of file JobQueueGroup.php.

Referenced by getCachedConfigVar(), push(), and queuesHaveJobs().

◆ $coalescedQueues

array JobQueueGroup::$coalescedQueues
protected

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

Definition at line 45 of file JobQueueGroup.php.

Referenced by getCoalescedQueues().

◆ $domain

string JobQueueGroup::$domain
protected

Wiki domain ID.

Definition at line 38 of file JobQueueGroup.php.

Referenced by __construct(), get(), and singleton().

◆ $instances

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

Definition at line 32 of file JobQueueGroup.php.

◆ $invalidDomain

bool JobQueueGroup::$invalidDomain = false
protected

Whether the wiki is not recognized in configuration.

Definition at line 42 of file JobQueueGroup.php.

◆ $readOnlyReason

string bool JobQueueGroup::$readOnlyReason
protected

Read only rationale (or false if r/w)

Definition at line 40 of file JobQueueGroup.php.

Referenced by __construct(), and get().

◆ CACHE_VERSION

const JobQueueGroup::CACHE_VERSION = 1

Definition at line 54 of file JobQueueGroup.php.

◆ PROC_CACHE_TTL

const JobQueueGroup::PROC_CACHE_TTL = 15

Definition at line 52 of file JobQueueGroup.php.

◆ TYPE_ANY

const JobQueueGroup::TYPE_ANY = 2

Definition at line 48 of file JobQueueGroup.php.

◆ TYPE_DEFAULT

const JobQueueGroup::TYPE_DEFAULT = 1

Definition at line 47 of file JobQueueGroup.php.

Referenced by JobRunner\run(), and MediaWiki\triggerAsyncJobs().

◆ USE_CACHE

const JobQueueGroup::USE_CACHE = 1

Definition at line 50 of file JobQueueGroup.php.

Referenced by JobRunner\run().


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