MediaWiki  1.23.2
LBFactoryMulti Class Reference

A multi-wiki, multi-master factory for Wikimedia and similar installations. More...

Inheritance diagram for LBFactoryMulti:
Collaboration diagram for LBFactoryMulti:

Public Member Functions

 __construct ( $conf)
 
 forEachLB ( $callback, $params=array())
 Execute a function for each tracked load balancer The callback is called with the load balancer as the first parameter, and $params passed as the subsequent parameters. More...
 
 getDBNameAndPrefix ( $wiki=false)
 Get the database name and prefix based on the wiki ID. More...
 
getExternalLB ( $cluster, $wiki=false)
 
 getMainLB ( $wiki=false)
 
 getSectionForWiki ( $wiki=false)
 
 makeServerArray ( $template, $loads, $groupLoads)
 Make a server array as expected by LoadBalancer::__construct, using a template and load array. More...
 
 newExternalLB ( $cluster, $wiki=false)
 
 newLoadBalancer ( $template, $loads, $groupLoads)
 Make a new load balancer object based on template and load array. More...
 
 newMainLB ( $wiki=false)
 
 reindexGroupLoads ( $groupLoads)
 Take a group load array indexed by group then server, and reindex it by server then group. More...
 
 shutdown ()
 Prepare all tracked load balancers for shutdown STUB. More...
 
- Public Member Functions inherited from LBFactory
 callMethod ( $loadBalancer, $methodName, $args)
 Private helper for forEachLBCallMethod. More...
 
 commitMasterChanges ()
 Commit changes on all master connections. More...
 
 forEachLBCallMethod ( $methodName, $args=array())
 Call a method of each tracked load balancer. More...
 
 hasMasterChanges ()
 Detemine if any master connection has pending changes. More...
 
 rollbackMasterChanges ()
 Rollback changes on all master connections. More...
 

Protected Attributes

array $conf
 Load balancer factory configuration *. More...
 
array $externalLoads = array()
 A map of external storage cluster name to server load map *. More...
 
array $externalTemplateOverrides
 A set of server info keys overriding serverTemplate for external storage. More...
 
LoadBalancer[] $extLBs = array()
 
array $groupLoadsByDB = array()
 A 3-d map giving server load ratios by DB name *. More...
 
array $groupLoadsBySection = array()
 A 3-d map giving server load ratios for each section and group *. More...
 
array $hostsByName = array()
 A map of hostname to IP address *. More...
 
string $lastSection
 
string $lastWiki
 
LoadBalancer[] $mainLBs = array()
 
array $masterTemplateOverrides
 An override array for all master servers *. More...
 
 $readOnlyBySection = array()
 
array $sectionLoads
 A 2-d map. More...
 
array $sectionsByDB
 A map of database names to section names *. More...
 
array $serverTemplate
 A server info associative array as documented for $wgDBservers. More...
 
array $templateOverridesByCluster
 A 2-d map overriding the server info by external storage cluster *. More...
 
array $templateOverridesByServer
 A 2-d map overriding serverTemplate and externalTemplateOverrides on a server-by-server basis. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from LBFactory
static destroyInstance ()
 Shut down, close connections and destroy the cached instance. More...
 
static disableBackend ()
 Disables all access to the load balancer, will cause all database access to throw a DBAccessError. More...
 
static getLBFactoryClass (array $config)
 Returns the LBFactory class to use and the load balancer configuration. More...
 
static setInstance ( $instance)
 Set the instance to be the given object. More...
 
static & singleton ()
 Get an LBFactory instance. More...
 
- Static Protected Attributes inherited from LBFactory
static $instance
 

Detailed Description

A multi-wiki, multi-master factory for Wikimedia and similar installations.

Ignores the old configuration globals

Configuration: sectionsByDB A map of database names to section names.

sectionLoads A 2-d map. For each section, gives a map of server names to load ratios. For example: array( 'section1' => array( 'db1' => 100, 'db2' => 100 ) )

serverTemplate A server info associative array as documented for $wgDBservers. The host, hostName and load entries will be overridden.

groupLoadsBySection A 3-d map giving server load ratios for each section and group. For example: array( 'section1' => array( 'group1' => array( 'db1' => 100, 'db2' => 100 ) ) )

groupLoadsByDB A 3-d map giving server load ratios by DB name.

hostsByName A map of hostname to IP address.

externalLoads A map of external storage cluster name to server load map.

externalTemplateOverrides A set of server info keys overriding serverTemplate for external storage.

templateOverridesByServer A 2-d map overriding serverTemplate and externalTemplateOverrides on a server-by-server basis. Applies to both core and external storage.

templateOverridesByCluster A 2-d map overriding the server info by external storage cluster.

masterTemplateOverrides An override array for all master servers.

readOnlyBySection A map of section name to read-only message. Missing or false for read/write.

Definition at line 76 of file LBFactoryMulti.php.

Constructor & Destructor Documentation

◆ __construct()

LBFactoryMulti::__construct (   $conf)
Parameters
array$conf
Exceptions
MWException

Reimplemented from LBFactory.

Definition at line 139 of file LBFactoryMulti.php.

References $conf, $section, array(), as, getSectionForWiki(), and global.

Member Function Documentation

◆ forEachLB()

LBFactoryMulti::forEachLB (   $callback,
  $params = array() 
)

Execute a function for each tracked load balancer The callback is called with the load balancer as the first parameter, and $params passed as the subsequent parameters.

Parameters
callable$callback
array$params

Reimplemented from LBFactory.

Definition at line 366 of file LBFactoryMulti.php.

References $lb, $params, array(), and as.

◆ getDBNameAndPrefix()

LBFactoryMulti::getDBNameAndPrefix (   $wiki = false)

Get the database name and prefix based on the wiki ID.

Parameters
bool | string$wiki
Returns
array

Definition at line 349 of file LBFactoryMulti.php.

References $wgDBname, array(), global, and wfSplitWikiID().

Referenced by getSectionForWiki(), and newMainLB().

◆ getExternalLB()

& LBFactoryMulti::getExternalLB (   $cluster,
  $wiki = false 
)
Parameters
string$clusterexternal storage cluster, or false for core
bool | string$wikiWiki ID, or false for the current wiki
Returns
LoadBalancer

Reimplemented from LBFactory.

Definition at line 254 of file LBFactoryMulti.php.

References array(), and newExternalLB().

◆ getMainLB()

LBFactoryMulti::getMainLB (   $wiki = false)
Parameters
bool | string$wiki
Returns
LoadBalancer

Reimplemented from LBFactory.

Definition at line 216 of file LBFactoryMulti.php.

References $lb, $section, array(), getSectionForWiki(), and newMainLB().

◆ getSectionForWiki()

LBFactoryMulti::getSectionForWiki (   $wiki = false)
Parameters
bool | string$wiki
Returns
string

Definition at line 173 of file LBFactoryMulti.php.

References $lastSection, $section, getDBNameAndPrefix(), and list.

Referenced by __construct(), getMainLB(), and newMainLB().

◆ makeServerArray()

LBFactoryMulti::makeServerArray (   $template,
  $loads,
  $groupLoads 
)

Make a server array as expected by LoadBalancer::__construct, using a template and load array.

Parameters
array$template
array$loads
array$groupLoads
Returns
array

Definition at line 291 of file LBFactoryMulti.php.

References array(), as, and reindexGroupLoads().

Referenced by newLoadBalancer().

◆ newExternalLB()

LBFactoryMulti::newExternalLB (   $cluster,
  $wiki = false 
)
Parameters
string$cluster
bool | string$wiki
Exceptions
MWException
Returns
LoadBalancer

Reimplemented from LBFactory.

Definition at line 234 of file LBFactoryMulti.php.

References $serverTemplate, array(), and newLoadBalancer().

Referenced by getExternalLB().

◆ newLoadBalancer()

LBFactoryMulti::newLoadBalancer (   $template,
  $loads,
  $groupLoads 
)

Make a new load balancer object based on template and load array.

Parameters
array$template
array$loads
array$groupLoads
Returns
LoadBalancer

Definition at line 272 of file LBFactoryMulti.php.

References $lb, array(), global, and makeServerArray().

Referenced by newExternalLB(), and newMainLB().

◆ newMainLB()

LBFactoryMulti::newMainLB (   $wiki = false)
Parameters
bool | string$wiki
Returns
LoadBalancer

Reimplemented from LBFactory.

Definition at line 193 of file LBFactoryMulti.php.

References $section, array(), getDBNameAndPrefix(), getSectionForWiki(), list, and newLoadBalancer().

Referenced by getMainLB().

◆ reindexGroupLoads()

LBFactoryMulti::reindexGroupLoads (   $groupLoads)

Take a group load array indexed by group then server, and reindex it by server then group.

Parameters
array$groupLoads
Returns
array

Definition at line 333 of file LBFactoryMulti.php.

References array(), and as.

Referenced by makeServerArray().

◆ shutdown()

LBFactoryMulti::shutdown ( )

Prepare all tracked load balancers for shutdown STUB.

Reimplemented from LBFactory.

Definition at line 375 of file LBFactoryMulti.php.

References $lb, as, and LBFactory\commitMasterChanges().

Member Data Documentation

◆ $conf

array LBFactoryMulti::$conf
protected

Load balancer factory configuration *.

Definition at line 125 of file LBFactoryMulti.php.

Referenced by __construct().

◆ $externalLoads

array LBFactoryMulti::$externalLoads = array()
protected

A map of external storage cluster name to server load map *.

Definition at line 100 of file LBFactoryMulti.php.

◆ $externalTemplateOverrides

array LBFactoryMulti::$externalTemplateOverrides
protected

A set of server info keys overriding serverTemplate for external storage.

Definition at line 105 of file LBFactoryMulti.php.

◆ $extLBs

LoadBalancer [] LBFactoryMulti::$extLBs = array()
protected

Definition at line 129 of file LBFactoryMulti.php.

◆ $groupLoadsByDB

array LBFactoryMulti::$groupLoadsByDB = array()
protected

A 3-d map giving server load ratios by DB name *.

Definition at line 96 of file LBFactoryMulti.php.

◆ $groupLoadsBySection

array LBFactoryMulti::$groupLoadsBySection = array()
protected

A 3-d map giving server load ratios for each section and group *.

Definition at line 94 of file LBFactoryMulti.php.

◆ $hostsByName

array LBFactoryMulti::$hostsByName = array()
protected

A map of hostname to IP address *.

Definition at line 98 of file LBFactoryMulti.php.

◆ $lastSection

string LBFactoryMulti::$lastSection
protected

Definition at line 133 of file LBFactoryMulti.php.

Referenced by getSectionForWiki().

◆ $lastWiki

string LBFactoryMulti::$lastWiki
protected

Definition at line 131 of file LBFactoryMulti.php.

◆ $mainLBs

LoadBalancer [] LBFactoryMulti::$mainLBs = array()
protected

Definition at line 127 of file LBFactoryMulti.php.

◆ $masterTemplateOverrides

array LBFactoryMulti::$masterTemplateOverrides
protected

An override array for all master servers *.

Definition at line 115 of file LBFactoryMulti.php.

◆ $readOnlyBySection

LBFactoryMulti::$readOnlyBySection = array()
protected

Definition at line 121 of file LBFactoryMulti.php.

◆ $sectionLoads

array LBFactoryMulti::$sectionLoads
protected

A 2-d map.

For each section, gives a map of server names to load ratios

Definition at line 84 of file LBFactoryMulti.php.

◆ $sectionsByDB

array LBFactoryMulti::$sectionsByDB
protected

A map of database names to section names *.

Definition at line 79 of file LBFactoryMulti.php.

◆ $serverTemplate

array LBFactoryMulti::$serverTemplate
protected

A server info associative array as documented for $wgDBservers.

The host, hostName and load entries will be overridden

Definition at line 90 of file LBFactoryMulti.php.

Referenced by newExternalLB().

◆ $templateOverridesByCluster

array LBFactoryMulti::$templateOverridesByCluster
protected

A 2-d map overriding the server info by external storage cluster *.

Definition at line 113 of file LBFactoryMulti.php.

◆ $templateOverridesByServer

array LBFactoryMulti::$templateOverridesByServer
protected

A 2-d map overriding serverTemplate and externalTemplateOverrides on a server-by-server basis.

Applies to both core and external storage

Definition at line 111 of file LBFactoryMulti.php.


The documentation for this class was generated from the following file: