Ejemplo n.º 1
0
 /**
  * @param array $params Possible keys:
  *  - sectionsByWiki      : A map of wiki IDs to section names.
  *                          Wikis will default to using the section "default".
  *  - partitionsBySection : Map of section names to maps of (partition name => weight).
  *                          A section called 'default' must be defined if not all wikis
  *                          have explicitly defined sections.
  *  - configByPartition   : Map of queue partition names to configuration arrays.
  *                          These configuration arrays are passed to JobQueue::factory().
  *                          The options set here are overridden by those passed to this
  *                          the federated queue itself (e.g. 'order' and 'claimTTL').
  *  - maxPartitionsTry    : Maximum number of times to attempt job insertion using
  *                          different partition queues. This improves availability
  *                          during failure, at the cost of added latency and somewhat
  *                          less reliable job de-duplication mechanisms.
  * @throws MWException
  */
 protected function __construct(array $params)
 {
     parent::__construct($params);
     $section = isset($params['sectionsByWiki'][$this->wiki]) ? $params['sectionsByWiki'][$this->wiki] : 'default';
     if (!isset($params['partitionsBySection'][$section])) {
         throw new MWException("No configuration for section '{$section}'.");
     }
     $this->maxPartitionsTry = isset($params['maxPartitionsTry']) ? $params['maxPartitionsTry'] : 2;
     // Get the full partition map
     $partitionMap = $params['partitionsBySection'][$section];
     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) {
         unset($baseConfig[$o]);
         // partition queue doesn't care about this
     }
     // The class handles all aggregator calls already
     unset($baseConfig['aggregator']);
     // Get the partition queue objects
     foreach ($partitionMap as $partition => $w) {
         if (!isset($params['configByPartition'][$partition])) {
             throw new MWException("No configuration for partition '{$partition}'.");
         }
         $this->partitionQueues[$partition] = JobQueue::factory($baseConfig + $params['configByPartition'][$partition]);
     }
     // Ring of all partitions
     $this->partitionRing = new HashRing($partitionMap);
 }
Ejemplo n.º 2
0
	/**
	 * @params include:
	 *   - redisConfig : An array of parameters to RedisConnectionPool::__construct().
	 *                   Note that the serializer option is ignored "none" is always used.
	 *   - redisServer : A hostname/port combination or the absolute path of a UNIX socket.
	 *                   If a hostname is specified but no port, the standard port number
	 *                   6379 will be used. Required.
	 *   - compression : The type of compression to use; one of (none,gzip).
	 * @param array $params
	 */
	public function __construct( array $params ) {
		parent::__construct( $params );
		$params['redisConfig']['serializer'] = 'none'; // make it easy to use Lua
		$this->server = $params['redisServer'];
		$this->compression = isset( $params['compression'] ) ? $params['compression'] : 'none';
		$this->redisPool = RedisConnectionPool::singleton( $params['redisConfig'] );
	}
Ejemplo n.º 3
0
 /**
  * Additional parameters include:
  *   - cluster : The name of an external cluster registered via LBFactory.
  *               If not specified, the primary DB cluster for the wiki will be used.
  *               This can be overridden with a custom cluster so that DB handles will
  *               be retrieved via LBFactory::getExternalLB() and getConnection().
  * @param $params array
  */
 protected function __construct(array $params)
 {
     global $wgMemc;
     parent::__construct($params);
     $this->cluster = isset($params['cluster']) ? $params['cluster'] : false;
     // Make sure that we don't use the SQL cache, which would be harmful
     $this->cache = $wgMemc instanceof SqlBagOStuff ? new EmptyBagOStuff() : $wgMemc;
 }
Ejemplo n.º 4
0
 /**
  * @param array $params Possible keys:
  *   - redisConfig : An array of parameters to RedisConnectionPool::__construct().
  *                   Note that the serializer option is ignored as "none" is always used.
  *   - redisServer : A hostname/port combination or the absolute path of a UNIX socket.
  *                   If a hostname is specified but no port, the standard port number
  *                   6379 will be used. Required.
  *   - compression : The type of compression to use; one of (none,gzip).
  *   - daemonized  : Set to true if the redisJobRunnerService runs in the background.
  *                   This will disable job recycling/undelaying from the MediaWiki side
  *                   to avoid redundance and out-of-sync configuration.
  * @throws InvalidArgumentException
  */
 public function __construct(array $params)
 {
     parent::__construct($params);
     $params['redisConfig']['serializer'] = 'none';
     // make it easy to use Lua
     $this->server = $params['redisServer'];
     $this->compression = isset($params['compression']) ? $params['compression'] : 'none';
     $this->redisPool = RedisConnectionPool::singleton($params['redisConfig']);
     if (empty($params['daemonized'])) {
         throw new InvalidArgumentException("Non-daemonized mode is no longer supported. Please install the " . "mediawiki/services/jobrunner service and update \$wgJobTypeConf as needed.");
     }
 }
Ejemplo n.º 5
0
 /**
  * @param array $params Possible keys:
  *  - sectionsByWiki      : A map of wiki IDs to section names.
  *                          Wikis will default to using the section "default".
  *  - partitionsBySection : Map of section names to maps of (partition name => weight).
  *                          A section called 'default' must be defined if not all wikis
  *                          have explicitly defined sections.
  *  - configByPartition   : Map of queue partition names to configuration arrays.
  *                          These configuration arrays are passed to JobQueue::factory().
  *                          The options set here are overriden by those passed to this
  *                          the federated queue itself (e.g. 'order' and 'claimTTL').
  *  - partitionsNoPush    : List of partition names that can handle pop() but not push().
  *                          This can be used to migrate away from a certain partition.
  *  - maxPartitionsTry    : Maximum number of times to attempt job insertion using
  *                          different partition queues. This improves availability
  *                          during failure, at the cost of added latency and somewhat
  *                          less reliable job de-duplication mechanisms.
  * @throws MWException
  */
 protected function __construct(array $params)
 {
     parent::__construct($params);
     $section = isset($params['sectionsByWiki'][$this->wiki]) ? $params['sectionsByWiki'][$this->wiki] : 'default';
     if (!isset($params['partitionsBySection'][$section])) {
         throw new MWException("No configuration for section '{$section}'.");
     }
     $this->maxPartitionsTry = isset($params['maxPartitionsTry']) ? $params['maxPartitionsTry'] : 2;
     // Get the full partition map
     $partitionMap = $params['partitionsBySection'][$section];
     arsort($partitionMap, SORT_NUMERIC);
     // Get the partitions jobs can actually be pushed to
     $partitionPushMap = $partitionMap;
     if (isset($params['partitionsNoPush'])) {
         foreach ($params['partitionsNoPush'] as $partition) {
             unset($partitionPushMap[$partition]);
         }
     }
     // Get the config to pass to merge into each partition queue config
     $baseConfig = $params;
     foreach (array('class', 'sectionsByWiki', 'maxPartitionsTry', 'partitionsBySection', 'configByPartition', 'partitionsNoPush') as $o) {
         unset($baseConfig[$o]);
         // partition queue doesn't care about this
     }
     // Get the partition queue objects
     foreach ($partitionMap as $partition => $w) {
         if (!isset($params['configByPartition'][$partition])) {
             throw new MWException("No configuration for partition '{$partition}'.");
         }
         $this->partitionQueues[$partition] = JobQueue::factory($baseConfig + $params['configByPartition'][$partition]);
     }
     // Ring of all partitions
     $this->partitionRing = new HashRing($partitionMap);
     // Get the ring of partitions to push jobs into
     if (count($partitionPushMap) === count($partitionMap)) {
         $this->partitionPushRing = clone $this->partitionRing;
         // faster
     } else {
         $this->partitionPushRing = new HashRing($partitionPushMap);
     }
     // Aggregate cache some per-queue values if there are multiple partition queues
     $this->cache = count($partitionMap) > 1 ? wfGetMainCache() : new EmptyBagOStuff();
 }
Ejemplo n.º 6
0
 /**
  * @params include:
  *  - sectionsByWiki      : A map of wiki IDs to section names.
  *                          Wikis will default to using the section "default".
  *  - partitionsBySection : Map of section names to maps of (partition name => weight).
  *                          A section called 'default' must be defined if not all wikis
  *                          have explicitly defined sections.
  *  - configByPartition   : Map of queue partition names to configuration arrays.
  *                          These configuration arrays are passed to JobQueue::factory().
  *                          The options set here are overriden by those passed to this
  *                          the federated queue itself (e.g. 'order' and 'claimTTL').
  *  - partitionsNoPush    : List of partition names that can handle pop() but not push().
  *                          This can be used to migrate away from a certain partition.
  * @param array $params
  */
 protected function __construct(array $params)
 {
     parent::__construct($params);
     $this->sectionsByWiki = $params['sectionsByWiki'];
     $this->partitionsBySection = $params['partitionsBySection'];
     $this->configByPartition = $params['configByPartition'];
     if (isset($params['partitionsNoPush'])) {
         $this->partitionsNoPush = array_flip($params['partitionsNoPush']);
     }
     $baseConfig = $params;
     foreach (array('class', 'sectionsByWiki', 'partitionsBySection', 'configByPartition', 'partitionsNoPush') as $o) {
         unset($baseConfig[$o]);
     }
     foreach ($this->getPartitionMap() as $partition => $w) {
         if (!isset($this->configByPartition[$partition])) {
             throw new MWException("No configuration for partition '{$partition}'.");
         }
         $this->partitionQueues[$partition] = JobQueue::factory($baseConfig + $this->configByPartition[$partition]);
     }
     // Aggregate cache some per-queue values if there are multiple partition queues
     $this->cache = $this->isFederated() ? wfGetMainCache() : new EmptyBagOStuff();
 }
Ejemplo n.º 7
0
 /**
  * Additional parameters include:
  *   - cluster : The name of an external cluster registered via LBFactory.
  *               If not specified, the primary DB cluster for the wiki will be used.
  *               This can be overridden with a custom cluster so that DB handles will
  *               be retrieved via LBFactory::getExternalLB() and getConnection().
  * @param array $params
  */
 protected function __construct(array $params)
 {
     parent::__construct($params);
     $this->cluster = isset($params['cluster']) ? $params['cluster'] : false;
     $this->cache = ObjectCache::getMainWANInstance();
 }
Ejemplo n.º 8
0
 /**
  * Additional parameters include:
  *   - cluster : The name of an external cluster registered via LBFactory.
  *               If not specified, the primary DB cluster for the wiki will be used.
  *               This can be overridden with a custom cluster so that DB handles will
  *               be retrieved via LBFactory::getExternalLB() and getConnection().
  * @param $params array
  */
 protected function __construct(array $params)
 {
     parent::__construct($params);
     $this->cluster = isset($params['cluster']) ? $params['cluster'] : false;
 }