MediaWiki
1.23.2
|
Class to handle enqueueing and running of background jobs. More...
Public Member Functions | |
ack (Job $job) | |
Acknowledge that a job was completed. More... | |
batchPush (array $jobs, $flags=0) | |
Push a batch of jobs into the queue. More... | |
deduplicateRootJob (Job $job) | |
Register the "root job" of a given job into the queue for de-duplication. More... | |
delayedJobsEnabled () | |
delete () | |
Deleted all unclaimed and delayed jobs from the queue. More... | |
flushCaches () | |
Clear any process and persistent caches. More... | |
getAbandonedCount () | |
Get the number of acquired jobs that can no longer be attempted. More... | |
getAcquiredCount () | |
Get the number of acquired jobs (these are temporarily out of the queue). More... | |
getAllDelayedJobs () | |
Get an iterator to traverse over all delayed jobs in this queue. More... | |
getAllQueuedJobs () | |
Get an iterator to traverse over all available jobs in this queue. More... | |
getCoalesceLocationInternal () | |
Do not use this function outside of JobQueue/JobQueueGroup. More... | |
getDelayedCount () | |
Get the number of delayed jobs (these are temporarily out of the queue). More... | |
getOrder () | |
getPeriodicTasks () | |
Return a map of task names to task definition maps. More... | |
getSiblingQueueSizes (array $types) | |
Check the size of each of the given queues. More... | |
getSiblingQueuesWithJobs (array $types) | |
Check whether each of the given queues are empty. More... | |
getSize () | |
Get the number of available (unacquired, non-delayed) jobs in the queue. More... | |
getType () | |
getWiki () | |
isEmpty () | |
Quickly check if the queue has no available (unacquired, non-delayed) jobs. More... | |
pop () | |
Pop a job off of the queue. More... | |
push ( $jobs, $flags=0) | |
Push one or more jobs into the queue. More... | |
setTestingPrefix ( $key) | |
Namespace the queue with a key to isolate it for testing. More... | |
waitForBackups () | |
Wait for any slaves or backup servers to catch up. More... | |
Static Public Member Functions | |
static | factory (array $params) |
Get a job queue object of the specified type. More... | |
static | incrStats ( $key, $type, $delta=1, $wiki=null) |
Call wfIncrStats() for the queue overall and for the queue type. More... | |
Public Attributes | |
const | QOS_ATOMIC = 1 |
const | ROOTJOB_TTL = 2419200 |
Protected Member Functions | |
__construct (array $params) | |
doAck (Job $job) | |
doBatchPush (array $jobs, $flags) | |
doDeduplicateRootJob (Job $job) | |
doDelete () | |
doFlushCaches () | |
doGetAbandonedCount () | |
doGetAcquiredCount () | |
doGetDelayedCount () | |
doGetPeriodicTasks () | |
doGetSiblingQueueSizes (array $types) | |
doGetSiblingQueuesWithJobs (array $types) | |
doGetSize () | |
doIsEmpty () | |
doIsRootJobOldDuplicate (Job $job) | |
doPop () | |
doWaitForBackups () | |
getRootJobCacheKey ( $signature) | |
isRootJobOldDuplicate (Job $job) | |
Check if the "root" job of a given job has been superseded by a newer one. More... | |
optimalOrder () | |
Get the default queue order to use if configuration does not specify one. More... | |
supportedOrders () | |
Get the allowed queue orders for configuration validation. More... | |
supportsDelayedJobs () | |
Find out if delayed jobs are supported for configuration validation. More... | |
Protected Attributes | |
bool | $checkDelay |
Allow delayed jobs *. More... | |
int | $claimTTL |
Time to live in seconds *. More... | |
BagOStuff | $dupCache |
int | $maxTries |
Maximum number of times to try a job *. More... | |
string | $order |
Job priority for pop() *. More... | |
string | $type |
Job type *. More... | |
string | $wiki |
Wiki ID *. More... | |
Class to handle enqueueing and running of background jobs.
Definition at line 31 of file JobQueue.php.
|
protected |
array | $params |
MWException |
Reimplemented in JobQueueRedis, JobQueueFederated, and JobQueueDB.
Definition at line 54 of file JobQueue.php.
References $params, CACHE_ANYTHING, optimalOrder(), order, supportedOrders(), supportsDelayedJobs(), type, wfGetCache(), and wiki.
|
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.
Job | $job |
MWException |
Definition at line 398 of file JobQueue.php.
References $job, $ok, $type, doAck(), wfProfileIn(), and wfProfileOut().
|
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.
array | $jobs | List of Jobs |
int | $flags | Bitfield (supports JobQueue::QOS_ATOMIC) |
MWException |
Definition at line 317 of file JobQueue.php.
References $checkDelay, $flags, $job, $ok, $type, as, doBatchPush(), wfProfileIn(), and wfProfileOut().
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.
Job | $job |
MWException |
Definition at line 447 of file JobQueue.php.
References $job, $ok, $type, doDeduplicateRootJob(), wfProfileIn(), and wfProfileOut().
|
final |
Definition at line 143 of file JobQueue.php.
References $checkDelay.
|
final |
Deleted all unclaimed and delayed jobs from the queue.
JobQueueError |
Definition at line 539 of file JobQueue.php.
References $res, doDelete(), wfProfileIn(), and wfProfileOut().
|
abstractprotected |
Job | $job |
Reimplemented in JobQueueDB, JobQueueRedis, and JobQueueFederated.
Referenced by ack().
|
abstractprotected |
array | $jobs | |
$flags |
Reimplemented in JobQueueFederated, JobQueueRedis, and JobQueueDB.
Referenced by batchPush().
|
protected |
Job | $job |
MWException |
Reimplemented in JobQueueDB, JobQueueRedis, and JobQueueFederated.
Definition at line 464 of file JobQueue.php.
References $job, $params, $timestamp, getRootJobCacheKey(), and ROOTJOB_TTL.
Referenced by deduplicateRootJob().
|
protected |
MWException |
Reimplemented in JobQueueDB, JobQueueRedis, and JobQueueFederated.
Definition at line 552 of file JobQueue.php.
Referenced by delete().
|
protected |
Reimplemented in JobQueueDB, and JobQueueFederated.
Definition at line 621 of file JobQueue.php.
Referenced by flushCaches().
|
protected |
Reimplemented in JobQueueRedis, JobQueueFederated, and JobQueueDB.
Definition at line 289 of file JobQueue.php.
Referenced by getAbandonedCount().
|
abstractprotected |
Reimplemented in JobQueueFederated, JobQueueRedis, and JobQueueDB.
Referenced by getAcquiredCount().
|
protected |
Reimplemented in JobQueueFederated, and JobQueueRedis.
Definition at line 264 of file JobQueue.php.
Referenced by getDelayedCount().
|
protected |
Reimplemented in JobQueueRedis, JobQueueDB, and JobQueueFederated.
Definition at line 602 of file JobQueue.php.
References array().
Referenced by getPeriodicTasks().
|
protected |
array | $types | List of queues types |
Reimplemented in JobQueueDB, JobQueueRedis, and JobQueueFederated.
Definition at line 701 of file JobQueue.php.
Referenced by getSiblingQueueSizes().
|
protected |
array | $types | List of queues types |
Reimplemented in JobQueueDB, JobQueueRedis, and JobQueueFederated.
Definition at line 676 of file JobQueue.php.
Referenced by getSiblingQueuesWithJobs().
|
abstractprotected |
Reimplemented in JobQueueFederated, JobQueueRedis, and JobQueueDB.
Referenced by getSize().
|
abstractprotected |
Reimplemented in JobQueueFederated, JobQueueRedis, and JobQueueDB.
Referenced by isEmpty().
|
protected |
Job | $job |
Reimplemented in JobQueueRedis, and JobQueueFederated.
Definition at line 508 of file JobQueue.php.
References $job, $params, $timestamp, and getRootJobCacheKey().
Referenced by isRootJobOldDuplicate().
|
abstractprotected |
Reimplemented in JobQueueFederated, JobQueueRedis, and JobQueueDB.
Referenced by pop().
|
protected |
Reimplemented in JobQueueDB, and JobQueueFederated.
Definition at line 574 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 |
MWException |
Definition at line 105 of file JobQueue.php.
References $params.
Referenced by JobQueueFederated\__construct(), CopyJobQueue\execute(), JobQueueGroup\get(), JobQueueGroup\getCoalescedQueues(), and JobQueueTest\setUp().
|
final |
Clear any process and persistent caches.
Definition at line 611 of file JobQueue.php.
References doFlushCaches(), wfProfileIn(), and wfProfileOut().
|
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 277 of file JobQueue.php.
References $res, doGetAbandonedCount(), wfProfileIn(), and wfProfileOut().
|
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 228 of file JobQueue.php.
References $res, doGetAcquiredCount(), wfProfileIn(), and wfProfileOut().
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 JobQueueRedis, and JobQueueFederated.
Definition at line 642 of file JobQueue.php.
References array().
|
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, JobQueueRedis, and JobQueueFederated.
JobQueue::getCoalesceLocationInternal | ( | ) |
Do not use this function outside of JobQueue/JobQueueGroup.
Reimplemented in JobQueueDB, JobQueueRedis, and JobQueueFederated.
Definition at line 652 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 252 of file JobQueue.php.
References $res, doGetDelayedCount(), wfProfileIn(), and wfProfileOut().
|
final |
Definition at line 135 of file JobQueue.php.
References $order.
|
final |
Return a map of task names to task definition maps.
A "task" is a fast periodic queue maintenance action. Mutually exclusive tasks must implement their own locking in the callback.
Each task value is an associative array with:
Definition at line 589 of file JobQueue.php.
References $name, as, and doGetPeriodicTasks().
|
protected |
string | $signature | Hash identifier of the root job |
Definition at line 526 of file JobQueue.php.
References list, type, wfForeignMemcKey(), wfSplitWikiID(), and wiki.
Referenced by doDeduplicateRootJob(), JobQueueRedis\doDeduplicateRootJob(), JobQueueDB\doDeduplicateRootJob(), JobQueueRedis\doIsRootJobOldDuplicate(), and 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 |
MWException |
Definition at line 690 of file JobQueue.php.
References $section, and 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 |
MWException |
Definition at line 665 of file JobQueue.php.
References $section, and 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 205 of file JobQueue.php.
References $res, doGetSize(), wfProfileIn(), and wfProfileOut().
|
final |
Definition at line 128 of file JobQueue.php.
References $type.
Referenced by JobQueueDB\getAllQueuedJobs().
|
final |
|
static |
Call wfIncrStats() for the queue overall and for the queue type.
string | $key | Event type |
string | $type | Job type |
int | $delta | |
string | $wiki | Wiki ID (added in 1.23) |
Definition at line 714 of file JobQueue.php.
References $wiki, and wfIncrStats().
Referenced by JobQueueRedis\doBatchPush(), JobQueueDB\doBatchPushInternal(), JobQueueDB\doPop(), JobQueueRedis\doPop(), pop(), JobQueueDB\recycleAndDeleteStaleJobs(), and JobQueueRedis\recyclePruneAndUndelayJobs().
|
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 182 of file JobQueue.php.
References $res, doIsEmpty(), wfProfileIn(), and wfProfileOut().
|
finalprotected |
Check if the "root" job of a given job has been superseded by a newer one.
Job | $job |
MWException |
Definition at line 492 of file JobQueue.php.
References $job, $type, doIsRootJobOldDuplicate(), wfProfileIn(), and wfProfileOut().
Referenced by pop().
|
abstractprotected |
Get the default queue order to use if configuration does not specify one.
Reimplemented in JobQueueFederated, JobQueueRedis, and JobQueueDB.
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.
MWException |
Definition at line 355 of file JobQueue.php.
References $e, $job, doPop(), global, incrStats(), isRootJobOldDuplicate(), DuplicateJob\newFromJob(), type, wfProfileIn(), wfProfileOut(), wfWikiID(), and wiki.
|
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.
Job | array | $jobs | A single job or an array of Jobs |
int | $flags | Bitfield (supports JobQueue::QOS_ATOMIC) |
JobQueueError |
Definition at line 303 of file JobQueue.php.
References $flags, array(), and batchPush().
Referenced by CopyJobQueue\copyJobs().
JobQueue::setTestingPrefix | ( | $key | ) |
Namespace the queue with a key to isolate it for testing.
string | $key |
MWException |
Reimplemented in JobQueueRedis, and JobQueueFederated.
Definition at line 729 of file JobQueue.php.
|
abstractprotected |
Get the allowed queue orders for configuration validation.
Reimplemented in JobQueueFederated, JobQueueRedis, and JobQueueDB.
Referenced by __construct().
|
protected |
Find out if delayed jobs are supported for configuration validation.
Reimplemented in JobQueueFederated, and JobQueueRedis.
Definition at line 166 of file JobQueue.php.
Referenced by __construct().
|
final |
Wait for any slaves or backup servers to catch up.
This does nothing for certain queue classes.
JobQueueError |
Definition at line 564 of file JobQueue.php.
References doWaitForBackups(), wfProfileIn(), and wfProfileOut().
Referenced by CopyJobQueue\copyJobs().
|
protected |
Allow delayed jobs *.
Definition at line 42 of file JobQueue.php.
Referenced by batchPush(), and delayedJobsEnabled().
|
protected |
Time to live in seconds *.
Definition at line 38 of file JobQueue.php.
|
protected |
|
protected |
Maximum number of times to try a job *.
Definition at line 40 of file JobQueue.php.
|
protected |
|
protected |
Job type *.
Definition at line 34 of file JobQueue.php.
Referenced by ack(), batchPush(), deduplicateRootJob(), JobQueueFederated\doFlushCaches(), JobQueueDB\doFlushCaches(), JobQueueFederated\doGetSiblingQueueSizes(), JobQueueRedis\doGetSiblingQueueSizes(), JobQueueFederated\getCrossPartitionSum(), JobQueueRedis\getQueueKey(), getType(), and isRootJobOldDuplicate().
|
protected |
Wiki ID *.
Definition at line 32 of file JobQueue.php.
Referenced by JobQueueFederated\__construct(), getWiki(), and incrStats().
const JobQueue::QOS_ATOMIC = 1 |
Definition at line 46 of file JobQueue.php.
Referenced by Job\safeBatchInsert().
const JobQueue::ROOTJOB_TTL = 2419200 |
Definition at line 48 of file JobQueue.php.
Referenced by doDeduplicateRootJob(), and JobQueueDB\doDeduplicateRootJob().