From bc16409852db4c2f8db68d3db07d2c9cc612ea6b Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 10 Jul 2013 10:15:26 +1000 Subject: [PATCH] Add --list parameter to showJobs.php For listing all of the jobs in the queue. Post-processing will enable most sorts of analysis that you would want to do. When we used SQL, this wasn't reallly necessary, but getting jobs out of Redis is a bit more tedious. The format is similar to the log made by runJobs.php. Change-Id: Idfa3f52ba89638892fc7a64d6566955d66de5958 --- includes/job/JobQueue.php | 4 ++-- maintenance/showJobs.php | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/includes/job/JobQueue.php b/includes/job/JobQueue.php index 3295c24917..aa47432ff3 100644 --- a/includes/job/JobQueue.php +++ b/includes/job/JobQueue.php @@ -597,7 +597,7 @@ abstract class JobQueue { /** * Get an iterator to traverse over all available jobs in this queue. * This does not include jobs that are currently acquired or delayed. - * This should only be called on a queue that is no longer being popped. + * Note: results may be stale if the queue is concurrently modified. * * @return Iterator * @throws MWException @@ -606,7 +606,7 @@ abstract class JobQueue { /** * Get an iterator to traverse over all delayed jobs in this queue. - * This should only be called on a queue that is no longer being popped. + * Note: results may be stale if the queue is concurrently modified. * * @return Iterator * @throws MWException diff --git a/maintenance/showJobs.php b/maintenance/showJobs.php index 322a849763..e054a364da 100644 --- a/maintenance/showJobs.php +++ b/maintenance/showJobs.php @@ -38,11 +38,22 @@ class ShowJobs extends Maintenance { parent::__construct(); $this->mDescription = "Show number of jobs waiting in master database"; $this->addOption( 'group', 'Show number of jobs per job type' ); + $this->addOption( 'list', 'Show a complete list of all jobs in a machine-readable format, instead of statistics' ); } public function execute() { $group = JobQueueGroup::singleton(); - if ( $this->hasOption( 'group' ) ) { + if ( $this->hasOption( 'list' ) ) { + foreach ( $group->getQueueTypes() as $type ) { + $queue = $group->get( $type ); + foreach ( $queue->getAllQueuedJobs() as $job ) { + $this->output( $job->toString() . " status=unclaimed\n" ); + } + foreach ( $queue->getAllDelayedJobs() as $job ) { + $this->output( $job->toString() . " status=delayed\n" ); + } + } + } elseif ( $this->hasOption( 'group' ) ) { foreach ( $group->getQueueTypes() as $type ) { $queue = $group->get( $type ); $pending = $queue->getSize(); -- 2.20.1