MediaWiki  REL1_24
LBFactory Class Reference

An interface for generating database load balancers. More...

Inheritance diagram for LBFactory:

List of all members.

Public Member Functions

 __construct ($conf)
 Construct a factory based on a configuration array (typically from $wgLBFactoryConf)
 callMethod ($loadBalancer, $methodName, $args)
 Private helper for forEachLBCallMethod.
 commitMasterChanges ()
 Commit changes on all master connections.
 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.
 forEachLBCallMethod ($methodName, $args=array())
 Call a method of each tracked load balancer.
getExternalLB ($cluster, $wiki=false)
 Get a cached (tracked) load balancer for external storage.
 getMainLB ($wiki=false)
 Get a cached (tracked) load balancer object.
 hasMasterChanges ()
 Detemine if any master connection has pending changes.
 newExternalLB ($cluster, $wiki=false)
 Create a new load balancer for external storage.
 newMainLB ($wiki=false)
 Create a new load balancer object.
 rollbackMasterChanges ()
 Rollback changes on all master connections.
 shutdown ()
 Prepare all tracked load balancers for shutdown STUB.

Static Public Member Functions

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

Static Protected Attributes

static $instance

Detailed Description

An interface for generating database load balancers.

Definition at line 28 of file LBFactory.php.


Constructor & Destructor Documentation

LBFactory::__construct ( conf) [abstract]

Construct a factory based on a configuration array (typically from $wgLBFactoryConf)

Parameters:
array$conf

Reimplemented in LBFactoryFake, LBFactorySimple, LBFactoryMulti, and LBFactorySingle.


Member Function Documentation

LBFactory::callMethod ( loadBalancer,
methodName,
args 
)

Private helper for forEachLBCallMethod.

Parameters:
LoadBalancer$loadBalancer
string$methodName
array$args

Definition at line 184 of file LBFactory.php.

References array().

Commit changes on all master connections.

Definition at line 191 of file LBFactory.php.

References forEachLBCallMethod().

static LBFactory::destroyInstance ( ) [static]

Shut down, close connections and destroy the cached instance.

Definition at line 90 of file LBFactory.php.

Referenced by Maintenance\finalSetup(), and setInstance().

static LBFactory::disableBackend ( ) [static]

Disables all access to the load balancer, will cause all database access to throw a DBAccessError.

Definition at line 36 of file LBFactory.php.

References global.

LBFactory::forEachLB ( callback,
params = array() 
) [abstract]

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 in LBFactoryFake, LBFactoryMulti, LBFactorySimple, and LBFactorySingle.

Referenced by forEachLBCallMethod(), and hasMasterChanges().

LBFactory::forEachLBCallMethod ( methodName,
args = array() 
)

Call a method of each tracked load balancer.

Parameters:
string$methodName
array$args

Definition at line 174 of file LBFactory.php.

References array(), and forEachLB().

Referenced by commitMasterChanges(), and rollbackMasterChanges().

& LBFactory::getExternalLB ( cluster,
wiki = false 
) [abstract]

Get a cached (tracked) load balancer for external storage.

Parameters:
string$clusterExternal storage cluster, or false for core
bool | string$wikiWiki ID, or false for the current wiki
Returns:
LoadBalancer

Reimplemented in LBFactoryFake, LBFactorySimple, LBFactoryMulti, and LBFactorySingle.

static LBFactory::getLBFactoryClass ( array config) [static]

Returns the LBFactory class to use and the load balancer configuration.

Parameters:
array$config(e.g. $wgLBFactoryConf)
Returns:
string Class name

Definition at line 64 of file LBFactory.php.

References array(), and wfDeprecated().

Referenced by singleton(), and LBFactoryTest\testGetLBFactoryClass().

LBFactory::getMainLB ( wiki = false) [abstract]

Get a cached (tracked) load balancer object.

Parameters:
bool | string$wikiWiki ID, or false for the current wiki
Returns:
LoadBalancer

Reimplemented in LBFactoryFake, LBFactorySimple, LBFactoryMulti, and LBFactorySingle.

Detemine if any master connection has pending changes.

Since:
1.23
Returns:
bool

Definition at line 208 of file LBFactory.php.

References $lb, $ret, and forEachLB().

LBFactory::newExternalLB ( cluster,
wiki = false 
) [abstract]

Create a new load balancer for external storage.

The resulting object will be untracked, not chronology-protected, and the caller is responsible for cleaning it up.

Parameters:
string$clusterExternal storage cluster, or false for core
bool | string$wikiWiki ID, or false for the current wiki
Returns:
LoadBalancer

Reimplemented in LBFactoryFake, LBFactorySimple, LBFactoryMulti, and LBFactorySingle.

LBFactory::newMainLB ( wiki = false) [abstract]

Create a new load balancer object.

The resulting object will be untracked, not chronology-protected, and the caller is responsible for cleaning it up.

Parameters:
bool | string$wikiWiki ID, or false for the current wiki
Returns:
LoadBalancer

Reimplemented in LBFactoryFake, LBFactorySimple, LBFactoryMulti, and LBFactorySingle.

Rollback changes on all master connections.

Since:
1.23

Definition at line 199 of file LBFactory.php.

References forEachLBCallMethod().

static LBFactory::setInstance ( instance) [static]

Set the instance to be the given object.

Parameters:
LBFactory$instance

Definition at line 103 of file LBFactory.php.

References $instance, and destroyInstance().

Prepare all tracked load balancers for shutdown STUB.

Reimplemented in LBFactoryMulti, and LBFactorySimple.

Definition at line 165 of file LBFactory.php.

static& LBFactory::singleton ( ) [static]

Get an LBFactory instance.

Returns:
LBFactory

Definition at line 46 of file LBFactory.php.

References $instance, getLBFactoryClass(), and global.

Referenced by wfGetLBFactory().


Member Data Documentation

LBFactory::$instance [static, protected]

Definition at line 30 of file LBFactory.php.

Referenced by setInstance(), and singleton().


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