MediaWiki master
|
Basic DB load monitor with no external dependencies. More...
Inherits Wikimedia\Rdbms\ILoadMonitor.
Inherited by Wikimedia\Rdbms\LoadMonitorNull.
Public Member Functions | |
__construct (ILoadBalancer $lb, BagOStuff $srvCache, WANObjectCache $wCache, array $options=[]) | |
getLagTimes (array $serverIndexes) | |
Get an estimate of replication lag (in seconds) for the specified servers. | |
getServerStates (array $serverIndexes) | |
Get a server gauge map for the specified servers. | |
movingAverage ( $priorValue, $gaugeValue, float $delay, float $movAveRatio) | |
Update a moving average for a gauge, accounting for the time delay since the last gauge. | |
scaleLoads (array &$weightByServer) | |
Perform load ratio adjustment before deciding which server to use. | |
setLogger (LoggerInterface $logger) | |
setMockTime (&$time) | |
setStatsdDataFactory (StatsdDataFactoryInterface $statsFactory) | |
Sets a StatsdDataFactory instance on the object. | |
Protected Member Functions | |
computeServerState (int $i, ?array $priorState) | |
getCurrentTime () | |
getWeightScale (array $state) | |
isStateFresh ( $state, $now) | |
isStateRefreshDue ( $priorAsOf, $priorGenDelay, $referenceTTL, $now) | |
makeStateKey (IStoreKeyEncoder $cache, int $i) | |
newInitialServerState () | |
Protected Attributes | |
ILoadBalancer | $lb |
LoggerInterface | $logger |
BagOStuff | $srvCache |
StatsdDataFactoryInterface | $statsd |
WANObjectCache | $wanCache |
Additional Inherited Members | |
![]() | |
const | STATE_AS_OF = 'time' |
const | STATE_GEN_DELAY = 'delay' |
const | STATE_LAG = 'lag' |
const | STATE_UP = 'up' |
Basic DB load monitor with no external dependencies.
This uses both local server and local datacenter caches for DB 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 42 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 82 of file LoadMonitor.php.
References Wikimedia\Rdbms\LoadMonitor\$lb, Wikimedia\Rdbms\LoadMonitor\$srvCache, and Wikimedia\Rdbms\LoadBalancer\MAX_LAG_DEFAULT.
|
protected |
int | $i | |
array | null | $priorState |
DBAccessError |
Definition at line 219 of file LoadMonitor.php.
|
protected |
Definition at line 420 of file LoadMonitor.php.
|
final |
Get an estimate of replication lag (in seconds) for the specified servers.
Values may be "false" if replication is too broken to estimate
int[] | $serverIndexes |
Implements Wikimedia\Rdbms\ILoadMonitor.
Definition at line 116 of file LoadMonitor.php.
Wikimedia\Rdbms\LoadMonitor::getServerStates | ( | array | $serverIndexes | ) |
Get a server gauge map for the specified servers.
int[] | $serverIndexes |
Implements Wikimedia\Rdbms\ILoadMonitor.
Reimplemented in Wikimedia\Rdbms\LoadMonitorNull.
Definition at line 127 of file LoadMonitor.php.
Referenced by Wikimedia\Rdbms\LoadMonitor\scaleLoads().
|
protected |
array | $state |
Definition at line 308 of file LoadMonitor.php.
Referenced by Wikimedia\Rdbms\LoadMonitor\scaleLoads().
|
protected |
|
protected |
float | $priorAsOf | |
float | $priorGenDelay | |
float | int | $referenceTTL | |
float | $now |
Definition at line 354 of file LoadMonitor.php.
|
protected |
Definition at line 202 of file LoadMonitor.php.
References IStoreKeyEncoder\makeGlobalKey().
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 377 of file LoadMonitor.php.
|
protected |
Definition at line 317 of file LoadMonitor.php.
|
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 102 of file LoadMonitor.php.
References Wikimedia\Rdbms\LoadMonitor\getServerStates(), and Wikimedia\Rdbms\LoadMonitor\getWeightScale().
Wikimedia\Rdbms\LoadMonitor::setLogger | ( | LoggerInterface | $logger | ) |
Definition at line 94 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 98 of file LoadMonitor.php.
|
protected |
Definition at line 44 of file LoadMonitor.php.
Referenced by Wikimedia\Rdbms\LoadMonitor\__construct().
|
protected |
Definition at line 50 of file LoadMonitor.php.
Referenced by Wikimedia\Rdbms\LoadMonitor\setLogger().
|
protected |
Definition at line 46 of file LoadMonitor.php.
Referenced by Wikimedia\Rdbms\LoadMonitor\__construct().
|
protected |
Definition at line 52 of file LoadMonitor.php.
|
protected |
Definition at line 48 of file LoadMonitor.php.