MediaWiki REL1_31
JobQueueAggregator.php
Go to the documentation of this file.
1<?php
29abstract 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() {
148 global $wgLocalDatabases;
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}
$wgLocalDatabases
Other wikis on this site, can be administered from a single developer account.
$wgJobQueueAggregator
Which aggregator to use for tracking which queues have jobs.
doNotifyQueueNonEmpty( $wiki, $type)
Class to handle tracking information about all queues.
__construct(array $params)
getAllReadyWikiQueues()
Get the list of all of the queues with jobs.
findPendingWikiQueues()
Get all databases that have a pending job.
notifyQueueNonEmpty( $wiki, $type)
Mark a queue as being non-empty.
static destroySingleton()
Destroy the singleton instance.
doNotifyQueueEmpty( $wiki, $type)
doNotifyQueueNonEmpty( $wiki, $type)
static JobQueueAggregator $instance
purge()
Purge all of the aggregator information.
notifyQueueEmpty( $wiki, $type)
Mark a queue as being empty.
static singleton( $domain=false)
MediaWiki exception.
$res
Definition database.txt:21
$params