MediaWiki
master
|
Basic DB load monitor with no external dependencies. More...
Public Member Functions | |
__construct (ILoadBalancer $lb, BagOStuff $srvCache, WANObjectCache $wCache, array $options=[]) | |
getLagTimes (array $serverIndexes) | |
Get an estimate of replication lag (in seconds) for each server. More... | |
movingAverage ( $priorValue, $gaugeValue, float $delay, float $movAveRatio) | |
Update a moving average for a gauge, accounting for the time delay since the last gauge. More... | |
scaleLoads (array &$weightByServer) | |
Perform load ratio adjustment before deciding which server to use. More... | |
setLogger (LoggerInterface $logger) | |
setMockTime (&$time) | |
setStatsdDataFactory (StatsdDataFactoryInterface $statsFactory) | |
Sets a StatsdDataFactory instance on the object. More... | |
Protected Member Functions | |
computeServerStates (array $serverIndexes, $priorStates) | |
getCurrentTime () | |
getServerStates (array $serverIndexes) | |
getWeightScale ( $index, IDatabase $conn=null) | |
isStateRefreshDue ( $priorAsOf, $priorGenDelay, $referenceTTL, $now) | |
Protected Attributes | |
ILoadBalancer | $lb |
LoggerInterface | $logger |
BagOStuff | $srvCache |
StatsdDataFactoryInterface | $statsd |
WANObjectCache | $wanCache |
Basic DB load monitor with no external dependencies.
Uses both server-local and shared caches for server state information.
The "domain" parameters are unused, though they might be used in the future. Therefore, at present, this assumes one channel of replication per server.
Definition at line 41 of file LoadMonitor.php.
Wikimedia\Rdbms\LoadMonitor::__construct | ( | ILoadBalancer | $lb, |
BagOStuff | $srvCache, | ||
WANObjectCache | $wCache, | ||
array | $options = [] |
||
) |
ILoadBalancer | $lb | |
BagOStuff | $srvCache | |
WANObjectCache | $wCache | |
array | $options | Additional parameters include:
|
Implements Wikimedia\Rdbms\ILoadMonitor.
Definition at line 83 of file LoadMonitor.php.
References Wikimedia\Rdbms\LoadMonitor\$lb, Wikimedia\Rdbms\LoadMonitor\$srvCache, and Wikimedia\Rdbms\LoadBalancer\MAX_LAG_DEFAULT.
|
protected |
array | $serverIndexes | |
array | false | $priorStates |
DBAccessError |
Definition at line 232 of file LoadMonitor.php.
References Wikimedia\Rdbms\LoadMonitor\getCurrentTime(), Wikimedia\Rdbms\LoadMonitor\getWeightScale(), and Wikimedia\Rdbms\LoadMonitor\movingAverage().
Referenced by Wikimedia\Rdbms\LoadMonitor\getServerStates().
|
protected |
Definition at line 420 of file LoadMonitor.php.
Referenced by Wikimedia\Rdbms\LoadMonitor\computeServerStates(), and Wikimedia\Rdbms\LoadMonitor\getServerStates().
|
final |
Get an estimate of replication lag (in seconds) for each server.
Values may be "false" if replication is too broken to estimate
int[] | $serverIndexes |
Implements Wikimedia\Rdbms\ILoadMonitor.
Definition at line 118 of file LoadMonitor.php.
References Wikimedia\Rdbms\LoadMonitor\getServerStates().
|
protected |
array | $serverIndexes |
DBAccessError |
Definition at line 127 of file LoadMonitor.php.
References Wikimedia\Rdbms\LoadMonitor\computeServerStates(), Wikimedia\Rdbms\LoadMonitor\getCurrentTime(), and Wikimedia\Rdbms\LoadMonitor\isStateRefreshDue().
Referenced by Wikimedia\Rdbms\LoadMonitor\getLagTimes(), and Wikimedia\Rdbms\LoadMonitor\scaleLoads().
|
protected |
int | $index | Server index |
IDatabase | null | $conn | Connection handle or null on connection failure |
Definition at line 351 of file LoadMonitor.php.
Referenced by Wikimedia\Rdbms\LoadMonitor\computeServerStates().
|
protected |
float | $priorAsOf | |
float | $priorGenDelay | |
float | $referenceTTL | |
float | $now |
Definition at line 213 of file LoadMonitor.php.
Referenced by Wikimedia\Rdbms\LoadMonitor\getServerStates().
Wikimedia\Rdbms\LoadMonitor::movingAverage | ( | $priorValue, | |
$gaugeValue, | |||
float | $delay, | ||
float | $movAveRatio | ||
) |
Update a moving average for a gauge, accounting for the time delay since the last gauge.
float | int | null | $priorValue | Prior moving average of value or null |
float | int | null | $gaugeValue | Newly gauged value or null |
float | $delay | Seconds between the new gauge and the prior one |
float | $movAveRatio | New gauge weight when it is 1 second newer than the prior one |
Definition at line 364 of file LoadMonitor.php.
Referenced by Wikimedia\Rdbms\LoadMonitor\computeServerStates().
|
final |
Perform load ratio adjustment before deciding which server to use.
int[] | &$weightByServer | Map of (server index => float weight) |
Implements Wikimedia\Rdbms\ILoadMonitor.
Definition at line 104 of file LoadMonitor.php.
References Wikimedia\Rdbms\LoadMonitor\getServerStates().
Wikimedia\Rdbms\LoadMonitor::setLogger | ( | LoggerInterface | $logger | ) |
Definition at line 96 of file LoadMonitor.php.
References Wikimedia\Rdbms\LoadMonitor\$logger.
Wikimedia\Rdbms\LoadMonitor::setMockTime | ( | & | $time | ) |
float | null | &$time | Mock UNIX timestamp for testing |
Definition at line 428 of file LoadMonitor.php.
Wikimedia\Rdbms\LoadMonitor::setStatsdDataFactory | ( | StatsdDataFactoryInterface | $statsFactory | ) |
Sets a StatsdDataFactory instance on the object.
StatsdDataFactoryInterface | $statsFactory |
Implements StatsdAwareInterface.
Definition at line 100 of file LoadMonitor.php.
|
protected |
Definition at line 43 of file LoadMonitor.php.
Referenced by Wikimedia\Rdbms\LoadMonitor\__construct().
|
protected |
Definition at line 49 of file LoadMonitor.php.
Referenced by Wikimedia\Rdbms\LoadMonitor\setLogger().
|
protected |
Definition at line 45 of file LoadMonitor.php.
Referenced by Wikimedia\Rdbms\LoadMonitor\__construct().
|
protected |
Definition at line 51 of file LoadMonitor.php.
|
protected |
Definition at line 47 of file LoadMonitor.php.