[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/jobqueue/ -> JobQueue.php (summary)

Job queue base code. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Author: Aaron Schulz
File Size: 740 lines (22 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

JobQueueError:: (0 methods):

JobQueueConnectionError:: (0 methods):

Defines 0 functions

  __construct()
  factory()
  getWiki()
  getType()
  getOrder()
  delayedJobsEnabled()
  supportsDelayedJobs()
  isEmpty()
  getSize()
  getAcquiredCount()
  getDelayedCount()
  doGetDelayedCount()
  getAbandonedCount()
  doGetAbandonedCount()
  push()
  batchPush()
  pop()
  ack()
  deduplicateRootJob()
  doDeduplicateRootJob()
  isRootJobOldDuplicate()
  doIsRootJobOldDuplicate()
  getRootJobCacheKey()
  delete()
  doDelete()
  waitForBackups()
  doWaitForBackups()
  getPeriodicTasks()
  doGetPeriodicTasks()
  flushCaches()
  doFlushCaches()
  getAllDelayedJobs()
  getCoalesceLocationInternal()
  getSiblingQueuesWithJobs()
  doGetSiblingQueuesWithJobs()
  getSiblingQueueSizes()
  doGetSiblingQueueSizes()
  incrStats()
  setTestingPrefix()

Class: JobQueueError  - X-Ref


Class: JobQueueConnectionError  - X-Ref

Functions
Functions that are not part of a class:

__construct( array $params )   X-Ref

param: array $params

factory( array $params )   X-Ref
Get a job queue object of the specified type.
$params includes:
- class      : What job class to use (determines job type)
- wiki       : wiki ID of the wiki the jobs are for (defaults to current wiki)
- type       : The name of the job types this queue handles
- order      : Order that pop() selects jobs, one of "fifo", "timestamp" or "random".
If "fifo" is used, the queue will effectively be FIFO. Note that job
completion will not appear to be exactly FIFO if there are multiple
job runners since jobs can take different times to finish once popped.
If "timestamp" is used, the queue will at least be loosely ordered
by timestamp, allowing for some jobs to be popped off out of order.
If "random" is used, pop() will pick jobs in random order.
Note that it may only be weakly random (e.g. a lottery of the oldest X).
If "any" is choosen, the queue will use whatever order is the fastest.
This might be useful for improving concurrency for job acquisition.
- claimTTL   : If supported, the queue will recycle jobs that have been popped
but not acknowledged as completed after this many seconds. Recycling
of jobs simple means re-inserting them into the queue. Jobs can be
attempted up to three times before being discarded.
- checkDelay : If supported, respect Job::getReleaseTimestamp() in the push functions.
This lets delayed jobs wait in a staging area until a given timestamp is
reached, at which point they will enter the queue. If this is not enabled
or not supported, an exception will be thrown on delayed job insertion.

Queue classes should throw an exception if they do not support the options given.

param: array $params
return: JobQueue

getWiki()   X-Ref

return: string Wiki ID

getType()   X-Ref

return: string Job type that this queue handles

getOrder()   X-Ref

return: string One of (random, timestamp, fifo, undefined)

delayedJobsEnabled()   X-Ref

return: bool Whether delayed jobs are enabled

supportsDelayedJobs()   X-Ref
Find out if delayed jobs are supported for configuration validation

return: bool Whether delayed jobs are supported

isEmpty()   X-Ref
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().

return: bool

getSize()   X-Ref
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.

return: int

getAcquiredCount()   X-Ref
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.

return: int

getDelayedCount()   X-Ref
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.

return: int

doGetDelayedCount()   X-Ref

return: int

getAbandonedCount()   X-Ref
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.

return: int

doGetAbandonedCount()   X-Ref

return: int

push( $jobs, $flags = 0 )   X-Ref
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.

param: Job|array $jobs A single job or an array of Jobs
param: int $flags Bitfield (supports JobQueue::QOS_ATOMIC)
return: void

batchPush( array $jobs, $flags = 0 )   X-Ref
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.

param: array $jobs List of Jobs
param: int $flags Bitfield (supports JobQueue::QOS_ATOMIC)
return: void

pop()   X-Ref
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.

return: Job|bool Returns false if there are no jobs

ack( Job $job )   X-Ref
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.

param: Job $job
return: void

deduplicateRootJob( Job $job )   X-Ref
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:
- rootJobSignature : hash (e.g. SHA1) that identifies the task
- rootJobTimestamp : TS_MW timestamp of this instance of the task

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.

param: Job $job
return: bool

doDeduplicateRootJob( Job $job )   X-Ref

param: Job $job
return: bool

isRootJobOldDuplicate( Job $job )   X-Ref
Check if the "root" job of a given job has been superseded by a newer one

param: Job $job
return: bool

doIsRootJobOldDuplicate( Job $job )   X-Ref

param: Job $job
return: bool

getRootJobCacheKey( $signature )   X-Ref

param: string $signature Hash identifier of the root job
return: string

delete()   X-Ref
Deleted all unclaimed and delayed jobs from the queue

return: void

doDelete()   X-Ref


waitForBackups()   X-Ref
Wait for any slaves or backup servers to catch up.

This does nothing for certain queue classes.

return: void

doWaitForBackups()   X-Ref

return: void

getPeriodicTasks()   X-Ref
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:
- name     : the name of the task
- callback : a PHP callable that performs the task
- period   : the period in seconds corresponding to the task frequency

return: array

doGetPeriodicTasks()   X-Ref

return: array

flushCaches()   X-Ref
Clear any process and persistent caches

return: void

doFlushCaches()   X-Ref

return: void

getAllDelayedJobs()   X-Ref
Get an iterator to traverse over all delayed jobs in this queue.
Note: results may be stale if the queue is concurrently modified.

return: Iterator

getCoalesceLocationInternal()   X-Ref
Do not use this function outside of JobQueue/JobQueueGroup

return: string

getSiblingQueuesWithJobs( array $types )   X-Ref
Check whether each of the given queues are empty.
This is used for batching checks for queues stored at the same place.

param: array $types List of queues types
return: array|null (list of non-empty queue types) or null if unsupported

doGetSiblingQueuesWithJobs( array $types )   X-Ref

param: array $types List of queues types
return: array|null (list of queue types) or null if unsupported

getSiblingQueueSizes( array $types )   X-Ref
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.

param: array $types List of queues types
return: array|null (job type => whether queue is empty) or null if unsupported

doGetSiblingQueueSizes( array $types )   X-Ref

param: array $types List of queues types
return: array|null (list of queue types) or null if unsupported

incrStats( $key, $type, $delta = 1, $wiki = null )   X-Ref
Call wfIncrStats() for the queue overall and for the queue type

param: string $key Event type
param: string $type Job type
param: int $delta
param: string $wiki Wiki ID (added in 1.23)

setTestingPrefix( $key )   X-Ref
Namespace the queue with a key to isolate it for testing

param: string $key
return: void



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1