X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fjobqueue%2FJobQueueFederated.php;h=7fdd617ab361a6591de34a4192ff5f2ba1bc3ab0;hp=07f2c93bdf803998a5bedc54105ce5305be74a99;hb=203cedd029e42bd3c55e50a9cff6f14373d8aa67;hpb=04fdc78370dbc042116488d6826e19bf3910273b diff --git a/includes/jobqueue/JobQueueFederated.php b/includes/jobqueue/JobQueueFederated.php index 07f2c93bdf..7fdd617ab3 100644 --- a/includes/jobqueue/JobQueueFederated.php +++ b/includes/jobqueue/JobQueueFederated.php @@ -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 ) {