Merge "Remove "@author Aaron Schulz" annotations"
[lhc/web/wiklou.git] / includes / jobqueue / JobQueueFederated.php
index 07f2c93..7fdd617 100644 (file)
@@ -18,7 +18,6 @@
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
- * @author Aaron Schulz
  */
 
 /**
@@ -49,8 +48,8 @@
 class JobQueueFederated extends JobQueue {
        /** @var HashRing */
        protected $partitionRing;
-       /** @var array (partition name => JobQueue) reverse sorted by weight */
-       protected $partitionQueues = array();
+       /** @var JobQueue[] (partition name => JobQueue) reverse sorted by weight */
+       protected $partitionQueues = [];
 
        /** @var int Maximum number of partitions to try */
        protected $maxPartitionsTry;
@@ -88,8 +87,8 @@ class JobQueueFederated extends JobQueue {
                arsort( $partitionMap, SORT_NUMERIC );
                // Get the config to pass to merge into each partition queue config
                $baseConfig = $params;
-               foreach ( array( 'class', 'sectionsByWiki', 'maxPartitionsTry',
-                       'partitionsBySection', 'configByPartition', ) as $o
+               foreach ( [ 'class', 'sectionsByWiki', 'maxPartitionsTry',
+                       'partitionsBySection', 'configByPartition', ] as $o
                ) {
                        unset( $baseConfig[$o] ); // partition queue doesn't care about this
                }
@@ -109,7 +108,7 @@ class JobQueueFederated extends JobQueue {
 
        protected function supportedOrders() {
                // No FIFO due to partitioning, though "rough timestamp order" is supported
-               return array( 'undefined', 'random', 'timestamp' );
+               return [ 'undefined', 'random', 'timestamp' ];
        }
 
        protected function optimalOrder() {
@@ -209,12 +208,12 @@ class JobQueueFederated extends JobQueue {
         * @return array List of Job object that could not be inserted
         */
        protected function tryJobInsertions( array $jobs, HashRing &$partitionRing, $flags ) {
-               $jobsLeft = array();
+               $jobsLeft = [];
 
                // Because jobs are spread across partitions, per-job de-duplication needs
                // to use a consistent hash to avoid allowing duplicate jobs per partition.
                // When inserting a batch of de-duplicated jobs, QOS_ATOMIC is disregarded.
-               $uJobsByPartition = array(); // (partition name => job list)
+               $uJobsByPartition = []; // (partition name => job list)
                /** @var Job $job */
                foreach ( $jobs as $key => $job ) {
                        if ( $job->ignoreDuplicates() ) {
@@ -225,7 +224,7 @@ class JobQueueFederated extends JobQueue {
                }
                // Get the batches of jobs that are not de-duplicated
                if ( $flags & self::QOS_ATOMIC ) {
-                       $nuJobBatches = array( $jobs ); // all or nothing
+                       $nuJobBatches = [ $jobs ]; // all or nothing
                } else {
                        // Split the jobs into batches and spread them out over servers if there
                        // are many jobs. This helps keep the partitions even. Otherwise, send all
@@ -311,18 +310,17 @@ class JobQueueFederated extends JobQueue {
                        throw new MWException( "The given job has no defined partition name." );
                }
 
-               return $this->partitionQueues[$job->metadata['QueuePartition']]->ack( $job );
+               $this->partitionQueues[$job->metadata['QueuePartition']]->ack( $job );
        }
 
        protected function doIsRootJobOldDuplicate( Job $job ) {
-               $params = $job->getRootJobParams();
-               $sigature = $params['rootJobSignature'];
-               $partition = $this->partitionRing->getLiveLocation( $sigature );
+               $signature = $job->getRootJobParams()['rootJobSignature'];
+               $partition = $this->partitionRing->getLiveLocation( $signature );
                try {
                        return $this->partitionQueues[$partition]->doIsRootJobOldDuplicate( $job );
                } catch ( JobQueueError $e ) {
                        if ( $this->partitionRing->ejectFromLiveRing( $partition, 5 ) ) {
-                               $partition = $this->partitionRing->getLiveLocation( $sigature );
+                               $partition = $this->partitionRing->getLiveLocation( $signature );
                                return $this->partitionQueues[$partition]->doIsRootJobOldDuplicate( $job );
                        }
                }
@@ -331,14 +329,13 @@ class JobQueueFederated extends JobQueue {
        }
 
        protected function doDeduplicateRootJob( IJobSpecification $job ) {
-               $params = $job->getRootJobParams();
-               $sigature = $params['rootJobSignature'];
-               $partition = $this->partitionRing->getLiveLocation( $sigature );
+               $signature = $job->getRootJobParams()['rootJobSignature'];
+               $partition = $this->partitionRing->getLiveLocation( $signature );
                try {
                        return $this->partitionQueues[$partition]->doDeduplicateRootJob( $job );
                } catch ( JobQueueError $e ) {
                        if ( $this->partitionRing->ejectFromLiveRing( $partition, 5 ) ) {
-                               $partition = $this->partitionRing->getLiveLocation( $sigature );
+                               $partition = $this->partitionRing->getLiveLocation( $signature );
                                return $this->partitionQueues[$partition]->doDeduplicateRootJob( $job );
                        }
                }
@@ -432,7 +429,7 @@ class JobQueueFederated extends JobQueue {
        }
 
        protected function doGetSiblingQueuesWithJobs( array $types ) {
-               $result = array();
+               $result = [];
 
                $failed = 0;
                /** @var JobQueue $queue */
@@ -458,7 +455,7 @@ class JobQueueFederated extends JobQueue {
        }
 
        protected function doGetSiblingQueueSizes( array $types ) {
-               $result = array();
+               $result = [];
                $failed = 0;
                /** @var JobQueue $queue */
                foreach ( $this->partitionQueues as $queue ) {