BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
Job Class Reference
Inheritance diagram for Job:
Collaboration diagram for Job:

Public Member Functions

 run ()
 
 __construct ($command, $title, $params=false)
 
 getType ()
 
 getTitle ()
 
 getParams ()
 
 getReleaseTimestamp ()
 
 getQueuedTimestamp ()
 
 getRequestId ()
 
 getReadyTimestamp ()
 
 ignoreDuplicates ()
 
 allowRetries ()
 
 workItemCount ()
 
 getDeduplicationInfo ()
 
 getRootJobParams ()
 
 hasRootJobParams ()
 
 isRootJob ()
 
 teardown ()
 
 insert ()
 
 toString ()
 
 getLastError ()
 

Static Public Member Functions

static factory ($command, Title $title, $params=[])
 
static batchInsert ($jobs)
 
static newRootJobParams ($key)
 

Public Attributes

 $command
 
 $params
 
 $metadata = []
 

Protected Member Functions

 addTeardownCallback ($callback)
 
 setLastError ($error)
 

Protected Attributes

 $title
 
 $removeDuplicates
 
 $error
 
 $teardownCallbacks = []
 

Detailed Description

Class to both describe a background job and handle jobs. The queue aspects of this class are now deprecated. Using the class to push jobs onto queues is deprecated (use JobSpecification).

Constructor & Destructor Documentation

Job::__construct (   $command,
  $title,
  $params = false 
)
Parameters
string$command
Title$title
array | bool$paramsCan not be === true

Member Function Documentation

Job::addTeardownCallback (   $callback)
protected
Parameters
callable$callback
Since
1.27
Job::allowRetries ( )
Returns
bool Whether this job can be retried on failure by job runners
Since
1.21
static Job::batchInsert (   $jobs)
static

Batch-insert a group of jobs into the queue. This will be wrapped in a transaction with a forced commit.

This may add duplicate at insert time, but they will be removed later on, when the first one is popped.

Parameters
Job[]$jobs Array of Job objects
Returns
bool
Deprecated:
since 1.21
static Job::factory (   $command,
Title  $title,
  $params = [] 
)
static

Create the appropriate object to handle a specific job

Parameters
string$commandJob command
Title$titleAssociated title
array$paramsJob parameters
Exceptions
MWException
Returns
Job
Job::getDeduplicationInfo ( )

Subclasses may need to override this to make duplication detection work. The resulting map conveys everything that makes the job unique. This is only checked if ignoreDuplicates() returns true, meaning that duplicate jobs are supposed to be ignored.

Returns
array Map of key/values
Since
1.21

Implements IJobSpecification.

Job::getParams ( )
Returns
array

Implements IJobSpecification.

Job::getQueuedTimestamp ( )
Returns
int|null UNIX timestamp of when the job was queued, or null
Since
1.26
Job::getReadyTimestamp ( )
Returns
int|null UNIX timestamp of when the job was runnable, or null
Since
1.26
Job::getReleaseTimestamp ( )
Returns
int|null UNIX timestamp to delay running this job until, otherwise null
Since
1.22

Implements IJobSpecification.

Job::getRequestId ( )
Returns
string|null Id of the request that created this job. Follows jobs recursively, allowing to track the id of the request that started a job when jobs insert jobs which insert other jobs.
Since
1.27
Job::getRootJobParams ( )
See Also
JobQueue::deduplicateRootJob()
Returns
array
Since
1.21

Implements IJobSpecification.

Job::getTitle ( )
Returns
Title

Implements IJobSpecification.

Job::getType ( )
Returns
string

Implements IJobSpecification.

Job::hasRootJobParams ( )
See Also
JobQueue::deduplicateRootJob()
Returns
bool
Since
1.22

Implements IJobSpecification.

Job::ignoreDuplicates ( )

Whether the queue should reject insertion of this job if a duplicate exists

This can be used to avoid duplicated effort or combined with delayed jobs to coalesce updates into larger batches. Claimed jobs are never treated as duplicates of new jobs, and some queues may allow a few duplicates due to network partitions and fail-over. Thus, additional locking is needed to enforce mutual exclusion if this is really needed.

Returns
bool

Implements IJobSpecification.

Job::insert ( )

Insert a single job into the queue.

Returns
bool True on success
Deprecated:
since 1.21
Job::isRootJob ( )
See Also
JobQueue::deduplicateRootJob()
Returns
bool Whether this is job is a root job

Implements IJobSpecification.

static Job::newRootJobParams (   $key)
static

Get "root job" parameters for a task

This is used to no-op redundant jobs, including child jobs of jobs, as long as the children inherit the root job parameters. When a job with root job parameters and "rootJobIsSelf" set is pushed, the deduplicateRootJob() method is automatically called on it. If the root job is only virtual and not actually pushed (e.g. the sub-jobs are inserted directly), then call deduplicateRootJob() directly.

See Also
JobQueue::deduplicateRootJob()
Parameters
string$keyA key that identifies the task
Returns
array Map of:
  • rootJobIsSelf : true
  • rootJobSignature : hash (e.g. SHA1) that identifies the task
  • rootJobTimestamp : TS_MW timestamp of this instance of the task
Since
1.21
Job::run ( )
abstract

Run the job

Returns
bool Success
Job::teardown ( )

Do any final cleanup after run(), deferred updates, and all DB commits happen

Since
1.27
Job::toString ( )
Returns
string
Job::workItemCount ( )
Returns
int Number of actually "work items" handled in this job
See Also
$wgJobBackoffThrottling
Since
1.23

The documentation for this class was generated from the following file: