2016-09-15 05:38:47 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Database load monitoring interface
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup Database
|
|
|
|
|
*/
|
2017-01-26 17:59:18 +00:00
|
|
|
|
|
|
|
|
namespace Wikimedia\Rdbms;
|
|
|
|
|
|
2016-09-15 05:38:47 +00:00
|
|
|
use Psr\Log\LoggerAwareInterface;
|
2017-01-26 17:59:18 +00:00
|
|
|
use BagOStuff;
|
2017-08-17 05:14:48 +00:00
|
|
|
use WANObjectCache;
|
2016-09-15 05:38:47 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* An interface for database load monitoring
|
|
|
|
|
*
|
|
|
|
|
* @ingroup Database
|
|
|
|
|
*/
|
|
|
|
|
interface ILoadMonitor extends LoggerAwareInterface {
|
|
|
|
|
/**
|
|
|
|
|
* Construct a new LoadMonitor with a given LoadBalancer parent
|
|
|
|
|
*
|
|
|
|
|
* @param ILoadBalancer $lb LoadBalancer this instance serves
|
|
|
|
|
* @param BagOStuff $sCache Local server memory cache
|
2017-08-17 05:14:48 +00:00
|
|
|
* @param WANObjectCache $wCache Local cluster memory cache
|
2016-09-15 07:04:41 +00:00
|
|
|
* @param array $options Options map
|
2016-09-15 05:38:47 +00:00
|
|
|
*/
|
2016-09-15 07:04:41 +00:00
|
|
|
public function __construct(
|
2017-08-17 05:14:48 +00:00
|
|
|
ILoadBalancer $lb, BagOStuff $sCache, WANObjectCache $wCache, array $options = []
|
2016-09-15 07:04:41 +00:00
|
|
|
);
|
2016-09-15 05:38:47 +00:00
|
|
|
|
|
|
|
|
/**
|
2016-10-05 19:47:10 +00:00
|
|
|
* Perform load ratio adjustment before deciding which server to use
|
|
|
|
|
*
|
|
|
|
|
* @param int[] &$weightByServer Map of (server index => float weight)
|
|
|
|
|
* @param string|bool $domain
|
2016-09-15 05:38:47 +00:00
|
|
|
*/
|
2016-10-05 19:47:10 +00:00
|
|
|
public function scaleLoads( array &$weightByServer, $domain );
|
2016-09-15 05:38:47 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get an estimate of replication lag (in seconds) for each server
|
|
|
|
|
*
|
|
|
|
|
* Values may be "false" if replication is too broken to estimate
|
|
|
|
|
*
|
2017-08-20 11:20:59 +00:00
|
|
|
* @param int[] $serverIndexes
|
2016-09-15 05:38:47 +00:00
|
|
|
* @param string $domain
|
|
|
|
|
* @return array Map of (server index => float|int|bool)
|
|
|
|
|
*/
|
2016-09-15 07:04:41 +00:00
|
|
|
public function getLagTimes( array $serverIndexes, $domain );
|
2016-09-15 05:38:47 +00:00
|
|
|
}
|