MediaWiki  1.27.2
JobQueueAggregatorRedis.php
Go to the documentation of this file.
1 <?php
35  protected $redisPool;
37  protected $servers;
38 
48  public function __construct( array $params ) {
49  parent::__construct( $params );
50  $this->servers = isset( $params['redisServers'] )
51  ? $params['redisServers']
52  : [ $params['redisServer'] ]; // b/c
53  $params['redisConfig']['serializer'] = 'none';
54  $this->redisPool = RedisConnectionPool::singleton( $params['redisConfig'] );
55  }
56 
57  protected function doNotifyQueueEmpty( $wiki, $type ) {
58  return true; // managed by the service
59  }
60 
61  protected function doNotifyQueueNonEmpty( $wiki, $type ) {
62  return true; // managed by the service
63  }
64 
65  protected function doGetAllReadyWikiQueues() {
66  $conn = $this->getConnection();
67  if ( !$conn ) {
68  return [];
69  }
70  try {
71  $map = $conn->hGetAll( $this->getReadyQueueKey() );
72 
73  if ( is_array( $map ) && isset( $map['_epoch'] ) ) {
74  unset( $map['_epoch'] ); // ignore
75  $pendingDBs = []; // (type => list of wikis)
76  foreach ( $map as $key => $time ) {
77  list( $type, $wiki ) = $this->decodeQueueName( $key );
78  $pendingDBs[$type][] = $wiki;
79  }
80  } else {
81  throw new UnexpectedValueException(
82  "No queue listing found; make sure redisJobChronService is running."
83  );
84  }
85 
86  return $pendingDBs;
87  } catch ( RedisException $e ) {
88  $this->redisPool->handleError( $conn, $e );
89 
90  return [];
91  }
92  }
93 
94  protected function doPurge() {
95  return true; // fully and only refreshed by the service
96  }
97 
104  protected function getConnection() {
105  $conn = false;
106  foreach ( $this->servers as $server ) {
107  $conn = $this->redisPool->getConnection( $server );
108  if ( $conn ) {
109  break;
110  }
111  }
112 
113  return $conn;
114  }
115 
119  private function getReadyQueueKey() {
120  return "jobqueue:aggregator:h-ready-queues:v2"; // global
121  }
122 
127  private function decodeQueueName( $name ) {
128  list( $type, $wiki ) = explode( '/', $name, 2 );
129 
130  return [ rawurldecode( $type ), rawurldecode( $wiki ) ];
131  }
132 }
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
the array() calling protocol came about after MediaWiki 1.4rc1.
magic word the default is to use $key to get the and $key value or $key value text $key value html to format the value $key
Definition: hooks.txt:2321
Class to handle tracking information about all queues.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
Definition: hooks.txt:1932
array $servers
List of Redis server addresses.
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1612
static singleton(array $options)
getConnection()
Get a connection to the server that handles all sub-queues for this queue.
$params
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
storage can be distributed across multiple servers
Definition: memcached.txt:33
Class to handle tracking information about all queues using PhpRedis.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2338
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:310