MediaWiki
REL1_22
|
00001 <?php 00028 require_once __DIR__ . '/Maintenance.php'; 00029 00036 class ShowJobs extends Maintenance { 00037 public function __construct() { 00038 parent::__construct(); 00039 $this->mDescription = "Show number of jobs waiting in master database"; 00040 $this->addOption( 'group', 'Show number of jobs per job type' ); 00041 $this->addOption( 'list', 'Show a complete list of all jobs in a machine-readable format, instead of statistics' ); 00042 } 00043 00044 public function execute() { 00045 $group = JobQueueGroup::singleton(); 00046 if ( $this->hasOption( 'list' ) ) { 00047 foreach ( $group->getQueueTypes() as $type ) { 00048 $queue = $group->get( $type ); 00049 foreach ( $queue->getAllQueuedJobs() as $job ) { 00050 $this->output( $job->toString() . " status=unclaimed\n" ); 00051 } 00052 foreach ( $queue->getAllDelayedJobs() as $job ) { 00053 $this->output( $job->toString() . " status=delayed\n" ); 00054 } 00055 } 00056 } elseif ( $this->hasOption( 'group' ) ) { 00057 foreach ( $group->getQueueTypes() as $type ) { 00058 $queue = $group->get( $type ); 00059 $pending = $queue->getSize(); 00060 $claimed = $queue->getAcquiredCount(); 00061 $abandoned = $queue->getAbandonedCount(); 00062 $active = max( 0, $claimed - $abandoned ); 00063 if ( ( $pending + $claimed ) > 0 ) { 00064 $this->output( 00065 "{$type}: $pending queued; " . 00066 "$claimed claimed ($active active, $abandoned abandoned)\n" 00067 ); 00068 } 00069 } 00070 } else { 00071 $count = 0; 00072 foreach ( $group->getQueueTypes() as $type ) { 00073 $count += $group->get( $type )->getSize(); 00074 } 00075 $this->output( "$count\n" ); 00076 } 00077 } 00078 } 00079 00080 $maintClass = "ShowJobs"; 00081 require_once RUN_MAINTENANCE_IF_MAIN;