MediaWiki  REL1_31
JobQueueAggregator.php
Go to the documentation of this file.
1 <?php
29 abstract class JobQueueAggregator {
31  protected static $instance = null;
32 
36  public function __construct( array $params ) {
37  }
38 
43  final public static function singleton() {
45 
46  if ( !isset( self::$instance ) ) {
47  $class = $wgJobQueueAggregator['class'];
48  $obj = new $class( $wgJobQueueAggregator );
49  if ( !( $obj instanceof JobQueueAggregator ) ) {
50  throw new MWException( "Class '$class' is not a JobQueueAggregator class." );
51  }
52  self::$instance = $obj;
53  }
54 
55  return self::$instance;
56  }
57 
63  final public static function destroySingleton() {
64  self::$instance = null;
65  }
66 
74  final public function notifyQueueEmpty( $wiki, $type ) {
75  $ok = $this->doNotifyQueueEmpty( $wiki, $type );
76 
77  return $ok;
78  }
79 
86  abstract protected function doNotifyQueueEmpty( $wiki, $type );
87 
95  final public function notifyQueueNonEmpty( $wiki, $type ) {
96  $ok = $this->doNotifyQueueNonEmpty( $wiki, $type );
97 
98  return $ok;
99  }
100 
107  abstract protected function doNotifyQueueNonEmpty( $wiki, $type );
108 
114  final public function getAllReadyWikiQueues() {
115  $res = $this->doGetAllReadyWikiQueues();
116 
117  return $res;
118  }
119 
123  abstract protected function doGetAllReadyWikiQueues();
124 
130  final public function purge() {
131  $res = $this->doPurge();
132 
133  return $res;
134  }
135 
139  abstract protected function doPurge();
140 
147  protected function findPendingWikiQueues() {
149 
150  $pendingDBs = []; // (job type => (db list))
151  foreach ( $wgLocalDatabases as $db ) {
152  foreach ( JobQueueGroup::singleton( $db )->getQueuesWithJobs() as $type ) {
153  $pendingDBs[$type][] = $db;
154  }
155  }
156 
157  return $pendingDBs;
158  }
159 }
160 
165  protected function doNotifyQueueEmpty( $wiki, $type ) {
166  return true;
167  }
168 
169  protected function doNotifyQueueNonEmpty( $wiki, $type ) {
170  return true;
171  }
172 
173  protected function doGetAllReadyWikiQueues() {
174  return [];
175  }
176 
177  protected function doPurge() {
178  return true;
179  }
180 }
JobQueueAggregator\doNotifyQueueNonEmpty
doNotifyQueueNonEmpty( $wiki, $type)
JobQueueAggregatorNull\doNotifyQueueEmpty
doNotifyQueueEmpty( $wiki, $type)
Definition: JobQueueAggregator.php:165
JobQueueAggregator\purge
purge()
Purge all of the aggregator information.
Definition: JobQueueAggregator.php:130
JobQueueAggregator\__construct
__construct(array $params)
Definition: JobQueueAggregator.php:36
array
the array() calling protocol came about after MediaWiki 1.4rc1.
$wgJobQueueAggregator
$wgJobQueueAggregator
Which aggregator to use for tracking which queues have jobs.
Definition: DefaultSettings.php:7553
JobQueueAggregator\notifyQueueNonEmpty
notifyQueueNonEmpty( $wiki, $type)
Mark a queue as being non-empty.
Definition: JobQueueAggregator.php:95
JobQueueAggregatorNull\doPurge
doPurge()
Definition: JobQueueAggregator.php:177
$params
$params
Definition: styleTest.css.php:40
JobQueueAggregatorNull\doNotifyQueueNonEmpty
doNotifyQueueNonEmpty( $wiki, $type)
Definition: JobQueueAggregator.php:169
$res
$res
Definition: database.txt:21
JobQueueAggregatorNull
Definition: JobQueueAggregator.php:164
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:37
JobQueueAggregator\destroySingleton
static destroySingleton()
Destroy the singleton instance.
Definition: JobQueueAggregator.php:63
JobQueueAggregator
Class to handle tracking information about all queues.
Definition: JobQueueAggregator.php:29
JobQueueAggregator\$instance
static JobQueueAggregator $instance
Definition: JobQueueAggregator.php:31
MWException
MediaWiki exception.
Definition: MWException.php:26
JobQueueAggregatorNull\doGetAllReadyWikiQueues
doGetAllReadyWikiQueues()
Definition: JobQueueAggregator.php:173
JobQueueAggregator\getAllReadyWikiQueues
getAllReadyWikiQueues()
Get the list of all of the queues with jobs.
Definition: JobQueueAggregator.php:114
JobQueueAggregator\doGetAllReadyWikiQueues
doGetAllReadyWikiQueues()
JobQueueAggregator\notifyQueueEmpty
notifyQueueEmpty( $wiki, $type)
Mark a queue as being empty.
Definition: JobQueueAggregator.php:74
JobQueueAggregator\doNotifyQueueEmpty
doNotifyQueueEmpty( $wiki, $type)
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:95
$wgLocalDatabases
$wgLocalDatabases
Other wikis on this site, can be administered from a single developer account.
Definition: DefaultSettings.php:2094
JobQueueAggregator\doPurge
doPurge()
JobQueueAggregator\findPendingWikiQueues
findPendingWikiQueues()
Get all databases that have a pending job.
Definition: JobQueueAggregator.php:147
JobQueueGroup\singleton
static singleton( $domain=false)
Definition: JobQueueGroup.php:72
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:22
JobQueueAggregator\singleton
static singleton()
Definition: JobQueueAggregator.php:43
$type
$type
Definition: testCompression.php:48