MediaWiki  1.29.2
Wikimedia\Rdbms\LoadMonitor Class Reference

Basic DB load monitor with no external dependencies Uses memcached to cache the replication lag for a short time. More...

Inheritance diagram for Wikimedia\Rdbms\LoadMonitor:
Collaboration diagram for Wikimedia\Rdbms\LoadMonitor:

Public Member Functions

 __construct (ILoadBalancer $lb, BagOStuff $srvCache, BagOStuff $cache, array $options=[])
 Construct a new LoadMonitor with a given LoadBalancer parent. More...
 
 getLagTimes (array $serverIndexes, $domain)
 Get an estimate of replication lag (in seconds) for each server. More...
 
 scaleLoads (array &$weightByServer, $domain)
 Perform load ratio adjustment before deciding which server to use. More...
 
 setLogger (LoggerInterface $logger)
 

Public Attributes

const VERSION = 1
 

Protected Member Functions

 getServerStates (array $serverIndexes, $domain)
 
 getWeightScale ( $index, IDatabase $conn=null)
 

Protected Attributes

BagOStuff $mainCache
 
ILoadBalancer $parent
 
LoggerInterface $replLogger
 
BagOStuff $srvCache
 

Private Member Functions

 getCacheKey (array $serverIndexes)
 

Private Attributes

float $movingAveRatio
 Moving average ratio (e.g. More...
 

Detailed Description

Basic DB load monitor with no external dependencies Uses memcached to cache the replication lag for a short time.

Definition at line 35 of file LoadMonitor.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Rdbms\LoadMonitor::__construct ( ILoadBalancer  $lb,
BagOStuff  $sCache,
BagOStuff  $cCache,
array  $options = [] 
)

Construct a new LoadMonitor with a given LoadBalancer parent.

Parameters
ILoadBalancer$lbLoadBalancer this instance serves
BagOStuff$sCacheLocal server memory cache
BagOStuff$cCacheLocal cluster memory cache
array$optionsOptions map

Implements Wikimedia\Rdbms\ILoadMonitor.

Reimplemented in Wikimedia\Rdbms\LoadMonitorMySQL.

Definition at line 50 of file LoadMonitor.php.

References $cache, $options, and Wikimedia\Rdbms\LoadMonitor\$srvCache.

Member Function Documentation

◆ getCacheKey()

Wikimedia\Rdbms\LoadMonitor::getCacheKey ( array  $serverIndexes)
private

Definition at line 209 of file LoadMonitor.php.

Referenced by Wikimedia\Rdbms\LoadMonitor\getServerStates().

◆ getLagTimes()

Wikimedia\Rdbms\LoadMonitor::getLagTimes ( array  $serverIndexes,
  $domain 
)

Get an estimate of replication lag (in seconds) for each server.

Values may be "false" if replication is too broken to estimate

Parameters
integer[]$serverIndexes
string$domain
Returns
array Map of (server index => float|int|bool)

Implements Wikimedia\Rdbms\ILoadMonitor.

Definition at line 81 of file LoadMonitor.php.

References Wikimedia\Rdbms\LoadMonitor\getServerStates().

◆ getServerStates()

◆ getWeightScale()

Wikimedia\Rdbms\LoadMonitor::getWeightScale (   $index,
IDatabase  $conn = null 
)
protected
Parameters
integer$indexServer index
IDatabase | null$connConnection handle or null on connection failure
Returns
float

Reimplemented in Wikimedia\Rdbms\LoadMonitorMySQL.

Definition at line 205 of file LoadMonitor.php.

Referenced by Wikimedia\Rdbms\LoadMonitor\getServerStates().

◆ scaleLoads()

Wikimedia\Rdbms\LoadMonitor::scaleLoads ( array $weightByServer,
  $domain 
)

Perform load ratio adjustment before deciding which server to use.

Parameters
int[]&$weightByServerMap of (server index => float weight)
string | bool$domain

Implements Wikimedia\Rdbms\ILoadMonitor.

Definition at line 67 of file LoadMonitor.php.

References as, and Wikimedia\Rdbms\LoadMonitor\getServerStates().

◆ setLogger()

Wikimedia\Rdbms\LoadMonitor::setLogger ( LoggerInterface  $logger)

Definition at line 63 of file LoadMonitor.php.

Member Data Documentation

◆ $mainCache

BagOStuff Wikimedia\Rdbms\LoadMonitor::$mainCache
protected

Definition at line 41 of file LoadMonitor.php.

Referenced by Wikimedia\Rdbms\LoadMonitor\getServerStates().

◆ $movingAveRatio

float Wikimedia\Rdbms\LoadMonitor::$movingAveRatio
private

Moving average ratio (e.g.

0.1 for 10% weight to new weight)

Definition at line 46 of file LoadMonitor.php.

Referenced by Wikimedia\Rdbms\LoadMonitor\getServerStates().

◆ $parent

ILoadBalancer Wikimedia\Rdbms\LoadMonitor::$parent
protected

Definition at line 37 of file LoadMonitor.php.

◆ $replLogger

LoggerInterface Wikimedia\Rdbms\LoadMonitor::$replLogger
protected

Definition at line 43 of file LoadMonitor.php.

◆ $srvCache

BagOStuff Wikimedia\Rdbms\LoadMonitor::$srvCache
protected

◆ VERSION

const Wikimedia\Rdbms\LoadMonitor::VERSION = 1

Definition at line 48 of file LoadMonitor.php.


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