MediaWiki REL1_34
|
Class to handle enqueueing and running of background jobs. More...
Public Member Functions | |
ack (RunnableJob $job) | |
Acknowledge that a job was completed. | |
batchPush (array $jobs, $flags=0) | |
Push a batch of jobs into the queue. | |
deduplicateRootJob (IJobSpecification $job) | |
Register the "root job" of a given job into the queue for de-duplication. | |
delayedJobsEnabled () | |
delete () | |
Deleted all unclaimed and delayed jobs from the queue. | |
flushCaches () | |
Clear any process and persistent caches. | |
getAbandonedCount () | |
Get the number of acquired jobs that can no longer be attempted. | |
getAcquiredCount () | |
Get the number of acquired jobs (these are temporarily out of the queue). | |
getAllAbandonedJobs () | |
Get an iterator to traverse over all abandoned jobs in this queue. | |
getAllAcquiredJobs () | |
Get an iterator to traverse over all claimed jobs in this queue. | |
getAllDelayedJobs () | |
Get an iterator to traverse over all delayed jobs in this queue. | |
getAllQueuedJobs () | |
Get an iterator to traverse over all available jobs in this queue. | |
getCoalesceLocationInternal () | |
Do not use this function outside of JobQueue/JobQueueGroup. | |
getDelayedCount () | |
Get the number of delayed jobs (these are temporarily out of the queue). | |
getDomain () | |
getOrder () | |
getReadOnlyReason () | |
getSiblingQueueSizes (array $types) | |
Check the size of each of the given queues. | |
getSiblingQueuesWithJobs (array $types) | |
Check whether each of the given queues are empty. | |
getSize () | |
Get the number of available (unacquired, non-delayed) jobs in the queue. | |
getType () | |
getWiki () | |
isEmpty () | |
Quickly check if the queue has no available (unacquired, non-delayed) jobs. | |
pop () | |
Pop a job off of the queue. | |
push ( $jobs, $flags=0) | |
Push one or more jobs into the queue. | |
waitForBackups () | |
Wait for any replica DBs or backup servers to catch up. | |
Static Public Member Functions | |
static | factory (array $params) |
Get a job queue object of the specified type. | |
Public Attributes | |
const | QOS_ATOMIC = 1 |
const | ROOTJOB_TTL = 2419200 |
Protected Member Functions | |
__construct (array $params) | |
assertNotReadOnly () | |
doAck (RunnableJob $job) | |
doBatchPush (array $jobs, $flags) | |
doDeduplicateRootJob (IJobSpecification $job) | |
doDelete () | |
doFlushCaches () | |
doGetAbandonedCount () | |
doGetAcquiredCount () | |
doGetDelayedCount () | |
doGetSiblingQueueSizes (array $types) | |
doGetSiblingQueuesWithJobs (array $types) | |
doGetSize () | |
doIsEmpty () | |
doIsRootJobOldDuplicate (IJobSpecification $job) | |
doPop () | |
doWaitForBackups () | |
factoryJob ( $command, $params) | |
getRootJobCacheKey ( $signature) | |
incrStats ( $key, $type, $delta=1) | |
Call wfIncrStats() for the queue overall and for the queue type. | |
isRootJobOldDuplicate (IJobSpecification $job) | |
Check if the "root" job of a given job has been superseded by a newer one. | |
optimalOrder () | |
Get the default queue order to use if configuration does not specify one. | |
supportedOrders () | |
Get the allowed queue orders for configuration validation. | |
supportsDelayedJobs () | |
Find out if delayed jobs are supported for configuration validation. | |
Protected Attributes | |
int | $claimTTL |
Time to live in seconds. | |
string | $domain |
DB domain ID. | |
int | $maxTries |
Maximum number of times to try a job. | |
string | $order |
Job priority for pop() | |
string bool | $readOnlyReason |
Read only rationale (or false if r/w) | |
StatsdDataFactoryInterface | $stats |
string | $type |
Job type. | |
WANObjectCache | $wanCache |
Class to handle enqueueing and running of background jobs.
Definition at line 31 of file JobQueue.php.
|
protected |
array | $params |
|
JobQueueError |
Reimplemented in JobQueueDB, JobQueueFederated, JobQueueMemory, and JobQueueRedis.
Definition at line 66 of file JobQueue.php.
References optimalOrder(), and supportedOrders().
|
final |
Acknowledge that a job was completed.
This does nothing for certain queue classes or if "claimTTL" is not set. Outside callers should use JobQueueGroup::ack() instead of this function.
RunnableJob | $job |
JobQueueError |
Definition at line 408 of file JobQueue.php.
References assertNotReadOnly(), doAck(), and IJobSpecification\getType().
|
protected |
JobQueueReadOnlyError |
Definition at line 712 of file JobQueue.php.
Referenced by ack(), batchPush(), deduplicateRootJob(), delete(), and pop().
|
final |
Push a batch of jobs into the queue.
This does not require $wgJobClasses to be set for the given job type. Outside callers should use JobQueueGroup::push() instead of this function.
IJobSpecification[] | $jobs | |
int | $flags | Bitfield (supports JobQueue::QOS_ATOMIC) |
JobQueueError |
Definition at line 333 of file JobQueue.php.
References $job, assertNotReadOnly(), deduplicateRootJob(), and doBatchPush().
Referenced by push().
|
final |
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. This is used to turn older, duplicate, job entries into no-ops. The root job information will remain in the registry until it simply falls out of cache.
This requires that $job has two special fields in the "params" array:
A "root job" is a conceptual job that consist of potentially many smaller jobs that are actually inserted into the queue. For example, "refreshLinks" jobs are spawned when a template is edited. One can think of the task as "update links of pages that use template X" and an instance of that task as a "root job". However, what actually goes into the queue are range and leaf job subtypes. Since these jobs include things like page ID ranges and DB master positions, and can morph into smaller jobs recursively, simple duplicate detection for individual jobs being identical (like that of job_sha1) is not useful.
In the case of "refreshLinks", if these jobs are still in the queue when the template is edited again, we want all of these old refreshLinks jobs for that template to become no-ops. This can greatly reduce server load, since refreshLinks jobs involves parsing. Essentially, the new batch of jobs belong to a new "root job" and the older ones to a previous "root job" for the same task of "update links of pages that use template X".
This does nothing for certain queue classes.
IJobSpecification | $job |
JobQueueError |
Definition at line 454 of file JobQueue.php.
References assertNotReadOnly(), doDeduplicateRootJob(), and IJobSpecification\getType().
Referenced by batchPush().
|
final |
Definition at line 183 of file JobQueue.php.
References supportsDelayedJobs().
|
final |
Deleted all unclaimed and delayed jobs from the queue.
JobQueueError |
Definition at line 548 of file JobQueue.php.
References assertNotReadOnly(), and doDelete().
|
abstractprotected |
RunnableJob | $job |
Reimplemented in JobQueueDB, JobQueueFederated, JobQueueMemory, and JobQueueRedis.
Referenced by ack().
|
abstractprotected |
IJobSpecification[] | $jobs | |
int | $flags |
Reimplemented in JobQueueDB, JobQueueFederated, JobQueueMemory, and JobQueueRedis.
Referenced by batchPush().
|
protected |
IJobSpecification | $job |
JobQueueError |
Reimplemented in JobQueueDB, JobQueueFederated, and JobQueueRedis.
Definition at line 469 of file JobQueue.php.
References $job, and getRootJobCacheKey().
Referenced by deduplicateRootJob().
|
protected |
JobQueueError |
Reimplemented in JobQueueDB, JobQueueFederated, JobQueueMemory, and JobQueueRedis.
Definition at line 558 of file JobQueue.php.
Referenced by delete().
|
protected |
Reimplemented in JobQueueDB, and JobQueueFederated.
Definition at line 594 of file JobQueue.php.
Referenced by flushCaches().
|
protected |
Reimplemented in JobQueueDB, JobQueueFederated, and JobQueueRedis.
Definition at line 304 of file JobQueue.php.
Referenced by getAbandonedCount().
|
abstractprotected |
Reimplemented in JobQueueDB, JobQueueFederated, JobQueueMemory, and JobQueueRedis.
Referenced by getAcquiredCount().
|
protected |
Reimplemented in JobQueueFederated, and JobQueueRedis.
Definition at line 281 of file JobQueue.php.
Referenced by getDelayedCount().
|
protected |
array | $types | List of queues types |
Reimplemented in JobQueueDB, JobQueueFederated, and JobQueueRedis.
Definition at line 695 of file JobQueue.php.
Referenced by getSiblingQueueSizes().
|
protected |
array | $types | List of queues types |
Reimplemented in JobQueueDB, JobQueueFederated, and JobQueueRedis.
Definition at line 672 of file JobQueue.php.
Referenced by getSiblingQueuesWithJobs().
|
abstractprotected |
Reimplemented in JobQueueDB, JobQueueFederated, JobQueueMemory, and JobQueueRedis.
Referenced by getSize().
|
abstractprotected |
Reimplemented in JobQueueDB, JobQueueFederated, JobQueueMemory, and JobQueueRedis.
Referenced by isEmpty().
|
protected |
IJobSpecification | $job |
Reimplemented in JobQueueFederated, and JobQueueRedis.
Definition at line 509 of file JobQueue.php.
References $job, and getRootJobCacheKey().
Referenced by isRootJobOldDuplicate().
|
abstractprotected |
Reimplemented in JobQueueDB, JobQueueFederated, JobQueueMemory, and JobQueueRedis.
Referenced by pop().
|
protected |
Reimplemented in JobQueueDB, and JobQueueFederated.
Definition at line 578 of file JobQueue.php.
Referenced by waitForBackups().
|
staticfinal |
Get a job queue object of the specified type.
$params includes:
Queue classes should throw an exception if they do not support the options given.
array | $params |
JobQueueError |
Definition at line 114 of file JobQueue.php.
Referenced by JobQueueFederated\__construct(), CopyJobQueue\execute(), JobQueueGroup\get(), and JobQueueGroup\getCoalescedQueues().
|
protected |
string | $command | |
array | $params |
Definition at line 704 of file JobQueue.php.
References $command, and Job\factory().
Referenced by JobQueueRedis\getJobFromFields(), JobQueueRedis\getJobFromUidInternal(), JobQueueDB\jobFromRow(), and JobQueueMemory\jobFromSpecInternal().
|
final |
Clear any process and persistent caches.
Definition at line 586 of file JobQueue.php.
References doFlushCaches().
|
final |
Get the number of acquired jobs that can no longer be attempted.
Queue classes should use caching if they are any slower without memcached.
If caching is used, this number might be out of date for a minute.
JobQueueError |
Definition at line 294 of file JobQueue.php.
References $res, and doGetAbandonedCount().
|
final |
Get the number of acquired jobs (these are temporarily out of the queue).
Queue classes should use caching if they are any slower without memcached.
If caching is used, this number might be out of date for a minute.
JobQueueError |
Definition at line 249 of file JobQueue.php.
References $res, and doGetAcquiredCount().
Referenced by JobQueueMemory\doAck().
JobQueue::getAllAbandonedJobs | ( | ) |
Get an iterator to traverse over all abandoned jobs in this queue.
JobQueueError |
Reimplemented in JobQueueFederated, and JobQueueRedis.
Definition at line 640 of file JobQueue.php.
JobQueue::getAllAcquiredJobs | ( | ) |
Get an iterator to traverse over all claimed jobs in this queue.
Callers should be quick to iterator over it or few results will be returned due to jobs being acknowledged and deleted
JobQueueError |
Reimplemented in JobQueueDB, JobQueueFederated, JobQueueMemory, and JobQueueRedis.
Definition at line 629 of file JobQueue.php.
JobQueue::getAllDelayedJobs | ( | ) |
Get an iterator to traverse over all delayed jobs in this queue.
Note: results may be stale if the queue is concurrently modified.
JobQueueError |
Reimplemented in JobQueueFederated, and JobQueueRedis.
Definition at line 615 of file JobQueue.php.
|
abstract |
Get an iterator to traverse over all available jobs in this queue.
This does not include jobs that are currently acquired or delayed. Note: results may be stale if the queue is concurrently modified.
JobQueueError |
Reimplemented in JobQueueDB, JobQueueFederated, JobQueueMemory, and JobQueueRedis.
JobQueue::getCoalesceLocationInternal | ( | ) |
Do not use this function outside of JobQueue/JobQueueGroup.
Reimplemented in JobQueueDB, JobQueueFederated, and JobQueueRedis.
Definition at line 650 of file JobQueue.php.
|
final |
Get the number of delayed jobs (these are temporarily out of the queue).
Queue classes should use caching if they are any slower without memcached.
If caching is used, this number might be out of date for a minute.
JobQueueError |
Definition at line 271 of file JobQueue.php.
References $res, and doGetDelayedCount().
|
final |
|
final |
Definition at line 152 of file JobQueue.php.
References $order.
JobQueue::getReadOnlyReason | ( | ) |
Definition at line 191 of file JobQueue.php.
References $readOnlyReason.
|
protected |
string | $signature | Hash identifier of the root job |
Definition at line 531 of file JobQueue.php.
Referenced by doDeduplicateRootJob(), JobQueueRedis\doDeduplicateRootJob(), doIsRootJobOldDuplicate(), and JobQueueRedis\doIsRootJobOldDuplicate().
|
final |
Check the size of each of the given queues.
For queues not served by the same store as this one, 0 is returned. This is used for batching checks for queues stored at the same place.
array | $types | List of queues types |
JobQueueError |
Definition at line 686 of file JobQueue.php.
References doGetSiblingQueueSizes().
|
final |
Check whether each of the given queues are empty.
This is used for batching checks for queues stored at the same place.
array | $types | List of queues types |
JobQueueError |
Definition at line 663 of file JobQueue.php.
References doGetSiblingQueuesWithJobs().
|
final |
Get the number of available (unacquired, non-delayed) jobs in the queue.
Queue classes should use caching if they are any slower without memcached.
If caching is used, this number might be out of date for a minute.
JobQueueError |
Definition at line 228 of file JobQueue.php.
References $res, and doGetSize().
|
final |
Definition at line 145 of file JobQueue.php.
References $type.
Referenced by JobQueueDB\getAllAcquiredJobs(), and JobQueueDB\getAllQueuedJobs().
|
final |
|
protected |
Call wfIncrStats() for the queue overall and for the queue type.
string | $key | Event type |
string | $type | Job type |
int | $delta |
Definition at line 726 of file JobQueue.php.
Referenced by JobQueueDB\doAck(), JobQueueRedis\doAck(), JobQueueRedis\doBatchPush(), JobQueueDB\doBatchPushInternal(), JobQueueDB\doPop(), JobQueueRedis\doPop(), pop(), and JobQueueDB\recycleAndDeleteStaleJobs().
|
final |
Quickly check if the queue has no available (unacquired, non-delayed) jobs.
Queue classes should use caching if they are any slower without memcached.
If caching is used, this might return false when there are actually no jobs. If pop() is called and returns false then it should correct the cache. Also, calling flushCaches() first prevents this. However, this affect is typically not distinguishable from the race condition between isEmpty() and pop().
JobQueueError |
Definition at line 207 of file JobQueue.php.
References $res, and doIsEmpty().
|
finalprotected |
Check if the "root" job of a given job has been superseded by a newer one.
IJobSpecification | $job |
JobQueueError |
Definition at line 496 of file JobQueue.php.
References $job, and doIsRootJobOldDuplicate().
Referenced by pop().
|
abstractprotected |
Get the default queue order to use if configuration does not specify one.
Reimplemented in JobQueueDB, JobQueueFederated, JobQueueMemory, and JobQueueRedis.
Referenced by __construct().
|
final |
Pop a job off of the queue.
This requires $wgJobClasses to be set for the given job type. Outside callers should use JobQueueGroup::pop() instead of this function.
JobQueueError |
Definition at line 374 of file JobQueue.php.
References $job, assertNotReadOnly(), doPop(), incrStats(), isRootJobOldDuplicate(), and DuplicateJob\newFromJob().
|
final |
Push one or more jobs into the queue.
This does not require $wgJobClasses to be set for the given job type. Outside callers should use JobQueueGroup::push() instead of this function.
IJobSpecification | IJobSpecification[] | $jobs | |
int | $flags | Bitfield (supports JobQueue::QOS_ATOMIC) |
JobQueueError |
Definition at line 318 of file JobQueue.php.
References batchPush().
Referenced by CopyJobQueue\copyJobs().
|
abstractprotected |
Get the allowed queue orders for configuration validation.
Reimplemented in JobQueueDB, JobQueueFederated, JobQueueMemory, and JobQueueRedis.
Referenced by __construct().
|
protected |
Find out if delayed jobs are supported for configuration validation.
Reimplemented in JobQueueFederated, and JobQueueRedis.
Definition at line 175 of file JobQueue.php.
Referenced by delayedJobsEnabled().
|
final |
Wait for any replica DBs or backup servers to catch up.
This does nothing for certain queue classes.
JobQueueError |
Definition at line 570 of file JobQueue.php.
References doWaitForBackups().
Referenced by CopyJobQueue\copyJobs(), and ManageJobs\repushAbandoned().
|
protected |
Time to live in seconds.
Definition at line 39 of file JobQueue.php.
|
protected |
DB domain ID.
Definition at line 33 of file JobQueue.php.
Referenced by JobQueueFederated\__construct(), getDomain(), and JobQueueMemory\getQueueData().
|
protected |
Maximum number of times to try a job.
Definition at line 41 of file JobQueue.php.
|
protected |
|
protected |
Read only rationale (or false if r/w)
Definition at line 43 of file JobQueue.php.
Referenced by getReadOnlyReason().
|
protected |
Definition at line 45 of file JobQueue.php.
|
protected |
Job type.
Definition at line 35 of file JobQueue.php.
Referenced by JobQueueDB\doFlushCaches(), JobQueueFederated\doGetSiblingQueueSizes(), JobQueueRedis\doGetSiblingQueueSizes(), JobQueueMemory\getQueueData(), JobQueueRedis\getQueueKey(), getType(), and JobQueueDB\recycleAndDeleteStaleJobs().
|
protected |
Definition at line 48 of file JobQueue.php.
const JobQueue::QOS_ATOMIC = 1 |
Definition at line 50 of file JobQueue.php.
const JobQueue::ROOTJOB_TTL = 2419200 |
Definition at line 52 of file JobQueue.php.