MediaWiki  1.28.0
JobQueueGroup Class Reference

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

Collaboration diagram for JobQueueGroup:

Public Member Functions

 __destruct ()
 
 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 ($wiki=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 ($wiki, $readOnlyReason)
 
 getCoalescedQueues ()
 

Protected Attributes

Job[] $bufferedJobs = []
 
ProcessCacheLRU $cache
 
array $coalescedQueues
 Map of (bucket => (queue => JobQueue, types => list of types) More...
 
string bool $readOnlyReason
 Read only rationale (or false if r/w) More...
 
string $wiki
 Wiki ID. 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

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

Definition at line 61 of file JobQueueGroup.php.

References $readOnlyReason, $wiki, cache, and wiki.

JobQueueGroup::__destruct ( )

Definition at line 445 of file JobQueueGroup.php.

References $type.

Member Function Documentation

JobQueueGroup::ack ( Job  $job)

Acknowledge that a job was completed.

Parameters
Job$job
Returns
void

Definition at line 258 of file JobQueueGroup.php.

References Job\getType().

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

Definition at line 437 of file JobQueueGroup.php.

References $job, and as.

Referenced by lazyPush(), and push().

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

References Job\getType().

JobQueueGroup::get (   $type)

Get the job queue object for a given queue type.

Parameters
string$type
Returns
JobQueue

Definition at line 95 of file JobQueueGroup.php.

References $readOnlyReason, $type, $wiki, JobQueue\factory(), global, and JobQueueAggregator\singleton().

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

Definition at line 411 of file JobQueueGroup.php.

References $GLOBALS, $name, $value, $wgConf, $wiki, ObjectCache\getMainWANInstance(), global, IExpiringStore\TTL_PROC_LONG, use, wfWikiID(), and wiki.

Referenced by getQueueTypes().

JobQueueGroup::getCoalescedQueues ( )
protected
Returns
array

Definition at line 380 of file JobQueueGroup.php.

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

Referenced by getQueueSizes(), and getQueuesWithJobs().

JobQueueGroup::getDefaultQueueTypes ( )

Get the list of default queue types.

Returns
array List of strings

Definition at line 303 of file JobQueueGroup.php.

References getQueueTypes(), and global.

Referenced by pop(), and queuesHaveJobs().

JobQueueGroup::getQueueSizes ( )

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

Returns
array Map of (job type => size)

Definition at line 361 of file JobQueueGroup.php.

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

JobQueueGroup::getQueuesWithJobs ( )

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

Returns
array List of job types that have non-empty queues

Definition at line 338 of file JobQueueGroup.php.

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

Referenced by pop(), and queuesHaveJobs().

JobQueueGroup::getQueueTypes ( )

Get the list of queue types.

Returns
array List of strings

Definition at line 294 of file JobQueueGroup.php.

References getCachedConfigVar().

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

JobQueueGroup::lazyPush (   $jobs)

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

Note that MediaWiki::restInPeace() calls pushLazyJobs()

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

Definition at line 172 of file JobQueueGroup.php.

References assertValidJobs(), and push().

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

References $flags, $job, $type, as, cache, getDefaultQueueTypes(), and getQueuesWithJobs().

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[]$jobs A single Job or a list of Jobs
Exceptions
InvalidArgumentException
Returns
void

Definition at line 122 of file JobQueueGroup.php.

References $job, $type, as, assertValidJobs(), cache, ObjectCache\getLocalClusterInstance(), global, and ProcessCacheLRU\set().

Referenced by lazyPush().

static JobQueueGroup::pushLazyJobs ( )
static

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

Returns
void
Since
1.26

Definition at line 192 of file JobQueueGroup.php.

References $e, as, and MWExceptionHandler\logException().

Referenced by MediaWiki\restInPeace().

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

References $type, $value, ProcessCacheLRU\get(), getDefaultQueueTypes(), ObjectCache\getLocalClusterInstance(), getQueuesWithJobs(), and wiki.

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

References $type, as, and global.

Member Data Documentation

Job [] JobQueueGroup::$bufferedJobs = []
protected

Definition at line 46 of file JobQueueGroup.php.

ProcessCacheLRU JobQueueGroup::$cache
protected

Definition at line 35 of file JobQueueGroup.php.

array JobQueueGroup::$coalescedQueues
protected

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

Definition at line 43 of file JobQueueGroup.php.

Referenced by getCoalescedQueues().

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

Definition at line 32 of file JobQueueGroup.php.

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().

string JobQueueGroup::$wiki
protected

Wiki ID.

Definition at line 38 of file JobQueueGroup.php.

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

const JobQueueGroup::CACHE_VERSION = 1

Definition at line 55 of file JobQueueGroup.php.

const JobQueueGroup::PROC_CACHE_TTL = 15

Definition at line 53 of file JobQueueGroup.php.

const JobQueueGroup::TYPE_ANY = 2

Definition at line 49 of file JobQueueGroup.php.

const JobQueueGroup::TYPE_DEFAULT = 1

Definition at line 48 of file JobQueueGroup.php.

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

const JobQueueGroup::USE_CACHE = 1

Definition at line 51 of file JobQueueGroup.php.

Referenced by JobRunner\run().


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