MediaWiki
REL1_22
|
Class to handle enqueueing and running of background jobs. More...
Public Member Functions | |
ack (Job $job) | |
Acknowledge that a job was completed. | |
batchPush (array $jobs, $flags=0) | |
Push a batch of jobs into the queue. | |
deduplicateRootJob (Job $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). | |
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). | |
getOrder () | |
getPeriodicTasks () | |
Return a map of task names to task definition maps. | |
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 a single jobs into the queue. | |
setTestingPrefix ($key) | |
Namespace the queue with a key to isolate it for testing. | |
waitForBackups () | |
Wait for any slaves or backup servers to catch up. | |
Static Public Member Functions | |
static | factory (array $params) |
Get a job queue object of the specified type. | |
static | incrStats ($key, $type, $delta=1) |
Call wfIncrStats() for the queue overall and for the queue type. | |
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. | |
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 | |
$checkDelay | |
$claimTTL | |
BagOStuff | $dupCache |
* | |
$maxTries | |
$order | |
$type | |
$wiki |
Class to handle enqueueing and running of background jobs.
Definition at line 31 of file JobQueue.php.
JobQueue::__construct | ( | array $ | params | ) | [protected] |
$params | array |
Reimplemented in JobQueueRedis, JobQueueFederated, and JobQueueDB.
Definition at line 48 of file JobQueue.php.
JobQueue::ack | ( | Job $ | job | ) | [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 |
JobQueueError |
Definition at line 381 of file JobQueue.php.
JobQueue::batchPush | ( | array $ | jobs, |
$ | flags = 0 |
||
) | [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 |
$flags | integer Bitfield (supports JobQueue::QOS_ATOMIC) |
JobQueueError |
Definition at line 305 of file JobQueue.php.
JobQueue::deduplicateRootJob | ( | Job $ | job | ) | [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 potentially many refreshLinks2 jobs. Since these jobs include things like page ID ranges and DB master positions, and morph into smaller refreshLinks2 jobs recursively, simple duplicate detection (like job_sha1) for individual jobs being identical 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 |
JobQueueError |
Definition at line 428 of file JobQueue.php.
JobQueue::delayedJobsEnabled | ( | ) | [final] |
Definition at line 136 of file JobQueue.php.
JobQueue::delete | ( | ) | [final] |
Deleted all unclaimed and delayed jobs from the queue.
JobQueueError |
Definition at line 516 of file JobQueue.php.
JobQueue::doAck | ( | Job $ | job | ) | [abstract, protected] |
Reimplemented in JobQueueDB, JobQueueRedis, and JobQueueFederated.
JobQueue::doBatchPush | ( | array $ | jobs, |
$ | flags | ||
) | [abstract, protected] |
Reimplemented in JobQueueDB, JobQueueFederated, and JobQueueRedis.
JobQueue::doDeduplicateRootJob | ( | Job $ | job | ) | [protected] |
$job | Job |
Reimplemented in JobQueueDB, JobQueueRedis, and JobQueueFederated.
Definition at line 443 of file JobQueue.php.
JobQueue::doDelete | ( | ) | [protected] |
Reimplemented in JobQueueDB, JobQueueRedis, and JobQueueFederated.
Definition at line 527 of file JobQueue.php.
JobQueue::doFlushCaches | ( | ) | [protected] |
Reimplemented in JobQueueDB, and JobQueueFederated.
Definition at line 594 of file JobQueue.php.
JobQueue::doGetAbandonedCount | ( | ) | [protected] |
Reimplemented in JobQueueRedis, JobQueueFederated, and JobQueueDB.
Definition at line 277 of file JobQueue.php.
JobQueue::doGetAcquiredCount | ( | ) | [abstract, protected] |
Reimplemented in JobQueueFederated, JobQueueRedis, and JobQueueDB.
JobQueue::doGetDelayedCount | ( | ) | [protected] |
Reimplemented in JobQueueFederated, and JobQueueRedis.
Definition at line 253 of file JobQueue.php.
JobQueue::doGetPeriodicTasks | ( | ) | [protected] |
Reimplemented in JobQueueRedis, JobQueueDB, and JobQueueFederated.
Definition at line 575 of file JobQueue.php.
JobQueue::doGetSiblingQueueSizes | ( | array $ | types | ) | [protected] |
array | $types | List of queues types |
Reimplemented in JobQueueDB, JobQueueRedis, and JobQueueFederated.
Definition at line 671 of file JobQueue.php.
JobQueue::doGetSiblingQueuesWithJobs | ( | array $ | types | ) | [protected] |
array | $types | List of queues types |
Reimplemented in JobQueueDB, JobQueueRedis, and JobQueueFederated.
Definition at line 647 of file JobQueue.php.
JobQueue::doGetSize | ( | ) | [abstract, protected] |
Reimplemented in JobQueueFederated, JobQueueRedis, and JobQueueDB.
JobQueue::doIsEmpty | ( | ) | [abstract, protected] |
Reimplemented in JobQueueFederated, JobQueueRedis, and JobQueueDB.
JobQueue::doIsRootJobOldDuplicate | ( | Job $ | job | ) | [protected] |
Job | $job |
Reimplemented in JobQueueRedis, and JobQueueFederated.
Definition at line 486 of file JobQueue.php.
JobQueue::doPop | ( | ) | [abstract, protected] |
Reimplemented in JobQueueRedis, JobQueueFederated, and JobQueueDB.
JobQueue::doWaitForBackups | ( | ) | [protected] |
Reimplemented in JobQueueDB, and JobQueueFederated.
Definition at line 549 of file JobQueue.php.
static JobQueue::factory | ( | array $ | params | ) | [static, final] |
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.
$params | array |
MWException |
Definition at line 99 of file JobQueue.php.
Referenced by CopyJobQueue\execute(), and JobQueueTest\setUp().
JobQueue::flushCaches | ( | ) | [final] |
JobQueue::getAbandonedCount | ( | ) | [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 266 of file JobQueue.php.
JobQueue::getAcquiredCount | ( | ) | [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 219 of file JobQueue.php.
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 614 of file JobQueue.php.
JobQueue::getAllQueuedJobs | ( | ) | [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.
Do not use this function outside of JobQueue/JobQueueGroup.
Reimplemented in JobQueueDB, JobQueueRedis, and JobQueueFederated.
Definition at line 624 of file JobQueue.php.
JobQueue::getDelayedCount | ( | ) | [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 242 of file JobQueue.php.
JobQueue::getOrder | ( | ) | [final] |
Definition at line 128 of file JobQueue.php.
JobQueue::getPeriodicTasks | ( | ) | [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 563 of file JobQueue.php.
JobQueue::getRootJobCacheKey | ( | $ | signature | ) | [protected] |
string | $signature | Hash identifier of the root job |
Definition at line 504 of file JobQueue.php.
JobQueue::getSiblingQueueSizes | ( | array $ | types | ) | [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 661 of file JobQueue.php.
JobQueue::getSiblingQueuesWithJobs | ( | array $ | types | ) | [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 637 of file JobQueue.php.
JobQueue::getSize | ( | ) | [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 197 of file JobQueue.php.
JobQueue::getType | ( | ) | [final] |
Definition at line 121 of file JobQueue.php.
JobQueue::getWiki | ( | ) | [final] |
Definition at line 114 of file JobQueue.php.
static JobQueue::incrStats | ( | $ | key, |
$ | type, | ||
$ | delta = 1 |
||
) | [static] |
Call wfIncrStats() for the queue overall and for the queue type.
string | $key | Event type |
string | $type | Job type |
integer | $delta |
Definition at line 683 of file JobQueue.php.
JobQueue::isEmpty | ( | ) | [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 175 of file JobQueue.php.
JobQueue::isRootJobOldDuplicate | ( | Job $ | job | ) | [final, protected] |
Check if the "root" job of a given job has been superseded by a newer one.
$job | Job |
JobQueueError |
Definition at line 471 of file JobQueue.php.
JobQueue::optimalOrder | ( | ) | [abstract, protected] |
Get the default queue order to use if configuration does not specify one.
Reimplemented in JobQueueFederated, JobQueueRedis, and JobQueueDB.
JobQueue::pop | ( | ) | [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 340 of file JobQueue.php.
JobQueue::push | ( | $ | jobs, |
$ | flags = 0 |
||
) | [final] |
Push a single 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.
$jobs | Job|Array |
$flags | integer Bitfield (supports JobQueue::QOS_ATOMIC) |
JobQueueError |
Definition at line 291 of file JobQueue.php.
Referenced by CopyJobQueue\copyJobs().
JobQueue::setTestingPrefix | ( | $ | key | ) |
Namespace the queue with a key to isolate it for testing.
$key | string |
MWException |
Reimplemented in JobQueueRedis, and JobQueueFederated.
Definition at line 695 of file JobQueue.php.
JobQueue::supportedOrders | ( | ) | [abstract, protected] |
Get the allowed queue orders for configuration validation.
Reimplemented in JobQueueFederated, JobQueueRedis, and JobQueueDB.
JobQueue::supportsDelayedJobs | ( | ) | [protected] |
Find out if delayed jobs are supported for configuration validation.
Reimplemented in JobQueueFederated, and JobQueueRedis.
Definition at line 159 of file JobQueue.php.
JobQueue::waitForBackups | ( | ) | [final] |
Wait for any slaves or backup servers to catch up.
This does nothing for certain queue classes.
JobQueueError |
Definition at line 539 of file JobQueue.php.
Referenced by CopyJobQueue\copyJobs().
JobQueue::$checkDelay [protected] |
Definition at line 37 of file JobQueue.php.
JobQueue::$claimTTL [protected] |
Definition at line 35 of file JobQueue.php.
BagOStuff JobQueue::$dupCache [protected] |
*
Definition at line 39 of file JobQueue.php.
JobQueue::$maxTries [protected] |
Definition at line 36 of file JobQueue.php.
JobQueue::$order [protected] |
Definition at line 34 of file JobQueue.php.
JobQueue::$type [protected] |
Definition at line 33 of file JobQueue.php.
Referenced by JobQueueRedis\doGetSiblingQueueSizes().
JobQueue::$wiki [protected] |
Definition at line 32 of file JobQueue.php.
const JobQueue::QOS_ATOMIC = 1 |
Definition at line 41 of file JobQueue.php.
const JobQueue::ROOTJOB_TTL = 2419200 |
Definition at line 43 of file JobQueue.php.