MediaWiki
master
|
Class to handle job queues stored in Redis. More...
Public Member Functions | |
__construct (array $params) | |
getAllAbandonedJobs () | |
getAllAcquiredJobs () | |
getAllDelayedJobs () | |
getAllQueuedJobs () | |
getCoalesceLocationInternal () | |
getJobFromUidInternal ($uid, RedisConnRef $conn) | |
This function should not be called outside JobQueueRedis. More... | |
getServerQueuesWithJobs () | |
Public Member Functions inherited from JobQueue | |
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 (IJobSpecification $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... | |
getAllAbandonedJobs () | |
Get an iterator to traverse over all abandoned jobs in this queue. More... | |
getAllAcquiredJobs () | |
Get an iterator to traverse over all claimed jobs in this 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 () | |
getReadOnlyReason () | |
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... | |
waitForBackups () | |
Wait for any slaves or backup servers to catch up. More... | |
Protected Attributes | |
string | $compression |
Compression method to use. More... | |
RedisConnectionPool | $redisPool |
string | $server |
Server address. More... | |
Protected Attributes inherited from JobQueue | |
JobQueueAggregator | $aggr |
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 bool | $readOnlyReason |
Read only rationale (or false if r/w) More... | |
string | $type |
Job type. More... | |
string | $wiki |
Wiki ID. More... | |
Private Member Functions | |
decodeQueueName ($name) | |
encodeQueueName () | |
getGlobalKey ($name) | |
getQueueKey ($prop, $type=null) | |
Additional Inherited Members | |
Static Public Member Functions inherited from JobQueue | |
static | factory (array $params) |
Get a job queue object of the specified type. More... | |
static | incrStats ($key, $type, $delta=1) |
Call wfIncrStats() for the queue overall and for the queue type. More... | |
Public Attributes inherited from JobQueue | |
const | QOS_ATOMIC = 1 |
const | ROOTJOB_TTL = 2419200 |
Class to handle job queues stored in Redis.
This is a faster and less resource-intensive job queue than JobQueueDB. All data for a queue using this class is placed into one redis server. The mediawiki/services/jobrunner background service must be set up and running.
There are eight main redis keys (per queue) used to track jobs:
The following keys are used to track queue states:
The background service takes care of undelaying, recycling, and pruning jobs as well as removing s-queuesWithJobs entries as queues empty.
Additionally, "rootjob:* keys track "root jobs" used for additional de-duplication. Aside from root job keys, all keys have no expiry, and are only removed when jobs are run. All the keys are prefixed with the relevant wiki ID information.
This class requires Redis 2.6 as it makes use Lua scripts for fast atomic operations. Additionally, it should be noted that redis has different persistence modes, such as rdb snapshots, journaling, and no persistence. Appropriate configuration should be made on the servers based on what queues are using it and what tolerance they have.
Definition at line 66 of file JobQueueRedis.php.
JobQueueRedis::__construct | ( | array | $params | ) |
array | $params | Possible keys:
|
InvalidArgumentException |
Definition at line 88 of file JobQueueRedis.php.
References server, and RedisConnectionPool\singleton().
|
private |
string | $name | JSON |
Definition at line 778 of file JobQueueRedis.php.
References $name.
Referenced by getServerQueuesWithJobs().
|
protected |
Job | $job |
UnexpectedValueException | |
JobQueueError |
Definition at line 380 of file JobQueueRedis.php.
References $e, $res, are, as, data, getConnection(), getQueueKey(), JobQueue\incrStats(), of, that, the, then, throwRedisException(), type, and wfDebugLog().
|
protected |
IJobSpecification[] | $jobs | |
int | $flags |
JobQueueError |
Definition at line 189 of file JobQueueRedis.php.
References $e, $flags, $job, as, getConnection(), getNewJobFields(), JobQueue\incrStats(), pushBlobs(), throwRedisException(), type, and wfDebugLog().
|
protected |
IJobSpecification | $job |
JobQueueError | |
LogicException |
Definition at line 434 of file JobQueueRedis.php.
References $e, $params, $timestamp, getConnection(), JobQueue\getRootJobCacheKey(), IJobSpecification\getRootJobParams(), IJobSpecification\hasRootJobParams(), and throwRedisException().
|
protected |
JobQueueError |
Definition at line 486 of file JobQueueRedis.php.
References $e, $keys, as, encodeQueueName(), false, getConnection(), getGlobalKey(), getQueueKey(), and throwRedisException().
|
protected |
JobQueueError |
Definition at line 173 of file JobQueueRedis.php.
References $e, getConnection(), getQueueKey(), and throwRedisException().
|
protected |
JobQueueError |
Definition at line 141 of file JobQueueRedis.php.
References $e, getConnection(), getQueueKey(), and throwRedisException().
|
protected |
JobQueueError |
Definition at line 159 of file JobQueueRedis.php.
References $e, getConnection(), getQueueKey(), and throwRedisException().
|
protected |
Definition at line 595 of file JobQueueRedis.php.
References $e, $res, JobQueue\$type, as, getConnection(), getQueueKey(), and throwRedisException().
Referenced by doGetSiblingQueuesWithJobs().
|
protected |
Definition at line 591 of file JobQueueRedis.php.
References doGetSiblingQueueSizes().
|
protected |
JobQueueError |
Definition at line 127 of file JobQueueRedis.php.
References $e, getConnection(), getQueueKey(), and throwRedisException().
Referenced by doIsEmpty().
|
protected |
JobQueueError |
Definition at line 118 of file JobQueueRedis.php.
References doGetSize().
|
protected |
Job | $job |
JobQueueError |
Definition at line 462 of file JobQueueRedis.php.
References $e, $params, $timestamp, getConnection(), JobQueue\getRootJobCacheKey(), Job\getRootJobParams(), Job\hasRootJobParams(), and throwRedisException().
|
protected |
JobQueueError |
Definition at line 307 of file JobQueueRedis.php.
References $blob, $e, $job, getConnection(), getJobFromFields(), JobQueue\incrStats(), popAndAcquireBlob(), throwRedisException(), type, unserialize(), and wfDebugLog().
|
private |
Definition at line 770 of file JobQueueRedis.php.
Referenced by doDelete(), and pushBlobs().
JobQueueRedis::getAllAbandonedJobs | ( | ) |
JobQueueError |
Definition at line 559 of file JobQueueRedis.php.
References $e, getConnection(), getJobIterator(), getQueueKey(), and throwRedisException().
JobQueueRedis::getAllAcquiredJobs | ( | ) |
JobQueueError |
Definition at line 543 of file JobQueueRedis.php.
References $e, getConnection(), getJobIterator(), getQueueKey(), and throwRedisException().
JobQueueRedis::getAllDelayedJobs | ( | ) |
JobQueueError |
Definition at line 527 of file JobQueueRedis.php.
References $e, getConnection(), getJobIterator(), getQueueKey(), and throwRedisException().
JobQueueRedis::getAllQueuedJobs | ( | ) |
JobQueueError |
Definition at line 511 of file JobQueueRedis.php.
References $e, getConnection(), getJobIterator(), getQueueKey(), and throwRedisException().
JobQueueRedis::getCoalesceLocationInternal | ( | ) |
Definition at line 587 of file JobQueueRedis.php.
References $server.
|
protected |
Get a connection to the server that handles all sub-queues for this queue.
JobQueueConnectionError |
Definition at line 747 of file JobQueueRedis.php.
References server.
Referenced by doAck(), doBatchPush(), doDeduplicateRootJob(), doDelete(), doGetAbandonedCount(), doGetAcquiredCount(), doGetDelayedCount(), doGetSiblingQueueSizes(), doGetSize(), doIsRootJobOldDuplicate(), doPop(), getAllAbandonedJobs(), getAllAcquiredJobs(), getAllDelayedJobs(), getAllQueuedJobs(), and getServerQueuesWithJobs().
|
private |
string | $name |
Definition at line 786 of file JobQueueRedis.php.
Referenced by doDelete(), getServerQueuesWithJobs(), and pushBlobs().
|
protected |
array | $fields |
Definition at line 696 of file JobQueueRedis.php.
References $job, $title, Job\factory(), and Title\makeTitle().
Referenced by doPop().
JobQueueRedis::getJobFromUidInternal | ( | $uid, | |
RedisConnRef | $conn | ||
) |
This function should not be called outside JobQueueRedis.
string | $uid | |
RedisConnRef | $conn |
JobQueueError | |
UnexpectedValueException |
Definition at line 626 of file JobQueueRedis.php.
References $e, $job, $title, Job\factory(), getQueueKey(), Title\makeTitle(), throwRedisException(), and unserialize().
Referenced by getJobIterator().
|
protected |
RedisConnRef | $conn | |
array | $uids | List of job UUIDs |
Definition at line 575 of file JobQueueRedis.php.
References $job, getJobFromUidInternal(), and use.
Referenced by getAllAbandonedJobs(), getAllAcquiredJobs(), getAllDelayedJobs(), and getAllQueuedJobs().
|
protected |
IJobSpecification | $job |
Definition at line 674 of file JobQueueRedis.php.
References IJobSpecification\getDeduplicationInfo(), IJobSpecification\getParams(), IJobSpecification\getReleaseTimestamp(), IJobSpecification\getTitle(), IJobSpecification\getType(), IJobSpecification\ignoreDuplicates(), UIDGenerator\newRawUUIDv4(), UIDGenerator\QUICK_RAND, and serialize().
Referenced by doBatchPush().
|
private |
string | $prop | |
string | null | $type | Override this for sibling queues |
Definition at line 802 of file JobQueueRedis.php.
References JobQueue\$type, list, wfSplitWikiID(), and wiki.
Referenced by doAck(), doDelete(), doGetAbandonedCount(), doGetAcquiredCount(), doGetDelayedCount(), doGetSiblingQueueSizes(), doGetSize(), getAllAbandonedJobs(), getAllAcquiredJobs(), getAllDelayedJobs(), getAllQueuedJobs(), getJobFromUidInternal(), popAndAcquireBlob(), and pushBlobs().
JobQueueRedis::getServerQueuesWithJobs | ( | ) |
JobQueueConnectionError | |
JobQueueError |
Definition at line 654 of file JobQueueRedis.php.
References $e, $queue, as, decodeQueueName(), getConnection(), getGlobalKey(), and throwRedisException().
|
protected |
Definition at line 105 of file JobQueueRedis.php.
|
protected |
RedisConnRef | $conn |
RedisException |
Definition at line 340 of file JobQueueRedis.php.
References and(), are, as, getQueueKey(), RedisConnRef\luaEval(), of, that, the, and then.
Referenced by doPop().
|
protected |
RedisConnRef | $conn | |
array | $items | List of results from JobQueueRedis::getNewJobFields() |
RedisException |
Definition at line 243 of file JobQueueRedis.php.
References $args, are, as, encodeQueueName(), First, getGlobalKey(), getQueueKey(), id(), in, is, RedisConnRef\luaEval(), needed, of, or, release, serialize(), string, that, the, and then.
Referenced by doBatchPush().
|
protected |
array | $fields |
Definition at line 709 of file JobQueueRedis.php.
Referenced by getNewJobFields(), and pushBlobs().
|
protected |
Definition at line 101 of file JobQueueRedis.php.
|
protected |
Definition at line 109 of file JobQueueRedis.php.
|
protected |
RedisConnRef | $conn | |
RedisException | $e |
JobQueueError |
Definition at line 762 of file JobQueueRedis.php.
References $e.
Referenced by doAck(), doBatchPush(), doDeduplicateRootJob(), doDelete(), doGetAbandonedCount(), doGetAcquiredCount(), doGetDelayedCount(), doGetSiblingQueueSizes(), doGetSize(), doIsRootJobOldDuplicate(), doPop(), getAllAbandonedJobs(), getAllAcquiredJobs(), getAllDelayedJobs(), getAllQueuedJobs(), getJobFromUidInternal(), and getServerQueuesWithJobs().
|
protected |
string | $blob |
Definition at line 728 of file JobQueueRedis.php.
References $blob.
Referenced by doPop(), and getJobFromUidInternal().
|
protected |
Compression method to use.
Definition at line 73 of file JobQueueRedis.php.
|
protected |
Definition at line 68 of file JobQueueRedis.php.
|
protected |
Server address.
Definition at line 71 of file JobQueueRedis.php.
Referenced by getCoalesceLocationInternal().