MediaWiki
REL1_24
|
00001 <?php 00030 abstract class JobQueueAggregator { 00032 protected static $instance = null; 00033 00037 protected function __construct( array $params ) { 00038 } 00039 00044 final public static function singleton() { 00045 global $wgJobQueueAggregator; 00046 00047 if ( !isset( self::$instance ) ) { 00048 $class = $wgJobQueueAggregator['class']; 00049 $obj = new $class( $wgJobQueueAggregator ); 00050 if ( !( $obj instanceof JobQueueAggregator ) ) { 00051 throw new MWException( "Class '$class' is not a JobQueueAggregator class." ); 00052 } 00053 self::$instance = $obj; 00054 } 00055 00056 return self::$instance; 00057 } 00058 00064 final public static function destroySingleton() { 00065 self::$instance = null; 00066 } 00067 00075 final public function notifyQueueEmpty( $wiki, $type ) { 00076 wfProfileIn( __METHOD__ ); 00077 $ok = $this->doNotifyQueueEmpty( $wiki, $type ); 00078 wfProfileOut( __METHOD__ ); 00079 00080 return $ok; 00081 } 00082 00086 abstract protected function doNotifyQueueEmpty( $wiki, $type ); 00087 00095 final public function notifyQueueNonEmpty( $wiki, $type ) { 00096 wfProfileIn( __METHOD__ ); 00097 $ok = $this->doNotifyQueueNonEmpty( $wiki, $type ); 00098 wfProfileOut( __METHOD__ ); 00099 00100 return $ok; 00101 } 00102 00106 abstract protected function doNotifyQueueNonEmpty( $wiki, $type ); 00107 00113 final public function getAllReadyWikiQueues() { 00114 wfProfileIn( __METHOD__ ); 00115 $res = $this->doGetAllReadyWikiQueues(); 00116 wfProfileOut( __METHOD__ ); 00117 00118 return $res; 00119 } 00120 00124 abstract protected function doGetAllReadyWikiQueues(); 00125 00131 final public function purge() { 00132 wfProfileIn( __METHOD__ ); 00133 $res = $this->doPurge(); 00134 wfProfileOut( __METHOD__ ); 00135 00136 return $res; 00137 } 00138 00142 abstract protected function doPurge(); 00143 00150 protected function findPendingWikiQueues() { 00151 global $wgLocalDatabases; 00152 00153 $pendingDBs = array(); // (job type => (db list)) 00154 foreach ( $wgLocalDatabases as $db ) { 00155 foreach ( JobQueueGroup::singleton( $db )->getQueuesWithJobs() as $type ) { 00156 $pendingDBs[$type][] = $db; 00157 } 00158 } 00159 00160 return $pendingDBs; 00161 } 00162 }