MediaWiki  REL1_24
JobRunner Class Reference

Job queue runner utility methods. More...

List of all members.

Public Member Functions

 run (array $options)
 Run jobs of the specified number/type for the specified time.
 setDebugHandler ($debug)

Protected Attributes

callable null $debug
 Debug output handler *.

Private Member Functions

 assertMemoryOK ()
 Make sure that this script is not too close to the memory usage limit.
 getBackoffTimeToWait (Job $job)
 loadBackoffs (array $backoffs, $mode= 'wait')
 Get the previous backoff expiries from persistent storage On I/O or lock acquisition failure this returns the original $backoffs.
 runJobsLog ($msg)
 Log the job message.
 syncBackoffDeltas (array $backoffs, array &$deltas, $mode= 'wait')
 Merge the current backoff expiries from persistent storage.

Detailed Description

Job queue runner utility methods.

Since:
1.24

Definition at line 30 of file JobRunner.php.


Member Function Documentation

Make sure that this script is not too close to the memory usage limit.

It is better to die in between jobs than OOM right in the middle of one.

Exceptions:
MWException

Definition at line 321 of file JobRunner.php.

JobRunner::getBackoffTimeToWait ( Job job) [private]
Parameters:
Job$job
Returns:
int Seconds for this runner to avoid doing more jobs of this type
See also:
$wgJobBackoffThrottling

Definition at line 206 of file JobRunner.php.

JobRunner::loadBackoffs ( array backoffs,
mode = 'wait' 
) [private]

Get the previous backoff expiries from persistent storage On I/O or lock acquisition failure this returns the original $backoffs.

Parameters:
array$backoffsMap of (job type => UNIX timestamp)
string$modeLock wait mode - "wait" or "nowait"
Returns:
array Map of (job type => backoff expiry timestamp)

Definition at line 240 of file JobRunner.php.

JobRunner::run ( array options)

Run jobs of the specified number/type for the specified time.

The response map has a 'job' field that lists status of each job, including:

  • type : the job type
  • status : ok/failed
  • error : any error message string
  • time : the job run time in ms The response map also has:
  • backoffs : the (job type => seconds) map of backoff times
  • elapsed : the total time spent running tasks in ms
  • reached : the reason the script finished, one of (none-ready, job-limit, time-limit)

This method outputs status information only if a debug handler was set. Any exceptions are caught and logged, but are not reported as output.

Parameters:
array$optionsMap of parameters:
  • type : the job type (or false for the default types)
  • maxJobs : maximum number of jobs to run
  • maxTime : maximum time in seconds before stopping
  • throttle : whether to respect job backoff configuration
Returns:
array Summary response that can easily be JSON serialized

Definition at line 63 of file JobRunner.php.

JobRunner::runJobsLog ( msg) [private]

Log the job message.

Parameters:
string$msgThe message to log

Definition at line 343 of file JobRunner.php.

Parameters:
callable$debugOptional debug output handler

Definition at line 36 of file JobRunner.php.

JobRunner::syncBackoffDeltas ( array backoffs,
array &$  deltas,
mode = 'wait' 
) [private]

Merge the current backoff expiries from persistent storage.

The $deltas map is set to an empty array on success. On I/O or lock acquisition failure this returns the original $backoffs.

Parameters:
array$backoffsMap of (job type => UNIX timestamp)
array$deltasMap of (job type => seconds)
string$modeLock wait mode - "wait" or "nowait"
Returns:
array The new backoffs account for $backoffs and the latest file data

Definition at line 279 of file JobRunner.php.


Member Data Documentation

callable null JobRunner::$debug [protected]

Debug output handler *.

Definition at line 31 of file JobRunner.php.


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