*
* @ingroup Database
*/
-class LBFactoryMulti extends LBFactory {
+class LBFactoryMulti extends LBFactoryMW {
/** @var array A map of database names to section names */
private $sectionsByDB;
/**
* @param array $conf
- * @throws MWException
+ * @throws InvalidArgumentException
*/
public function __construct( array $conf ) {
parent::__construct( $conf );
foreach ( $required as $key ) {
if ( !isset( $conf[$key] ) ) {
- throw new MWException( __CLASS__ . ": $key is required in configuration" );
+ throw new InvalidArgumentException( __CLASS__ . ": $key is required in configuration" );
}
$this->$key = $conf[$key];
}
$section = $this->getSectionForWiki( $wiki );
if ( !isset( $this->mainLBs[$section] ) ) {
$lb = $this->newMainLB( $wiki );
- $lb->parentInfo( [ 'id' => "main-$section" ] );
$this->chronProt->initLB( $lb );
$this->mainLBs[$section] = $lb;
}
/**
* @param string $cluster
* @param bool|string $wiki
- * @throws MWException
+ * @throws InvalidArgumentException
* @return LoadBalancer
*/
protected function newExternalLB( $cluster, $wiki = false ) {
if ( !isset( $this->externalLoads[$cluster] ) ) {
- throw new MWException( __METHOD__ . ": Unknown cluster \"$cluster\"" );
+ throw new InvalidArgumentException( __METHOD__ . ": Unknown cluster \"$cluster\"" );
}
$template = $this->serverTemplate;
if ( isset( $this->externalTemplateOverrides ) ) {
* @param bool|string $wiki Wiki ID, or false for the current wiki
* @return LoadBalancer
*/
- public function &getExternalLB( $cluster, $wiki = false ) {
+ public function getExternalLB( $cluster, $wiki = false ) {
if ( !isset( $this->extLBs[$cluster] ) ) {
$this->extLBs[$cluster] = $this->newExternalLB( $cluster, $wiki );
- $this->extLBs[$cluster]->parentInfo( [ 'id' => "ext-$cluster" ] );
$this->chronProt->initLB( $this->extLBs[$cluster] );
}
* @return LoadBalancer
*/
private function newLoadBalancer( $template, $loads, $groupLoads, $readOnlyReason ) {
- return new LoadBalancer( [
- 'servers' => $this->makeServerArray( $template, $loads, $groupLoads ),
- 'loadMonitor' => $this->loadMonitorClass,
- 'readOnlyReason' => $readOnlyReason,
- 'trxProfiler' => $this->trxProfiler,
- 'srvCache' => $this->srvCache,
- 'wanCache' => $this->wanCache
- ] );
+ $lb = new LoadBalancer( array_merge(
+ $this->baseLoadBalancerParams(),
+ [
+ 'servers' => $this->makeServerArray( $template, $loads, $groupLoads ),
+ 'loadMonitor' => $this->loadMonitorClass,
+ 'readOnlyReason' => $readOnlyReason
+ ]
+ ) );
+ $this->initLoadBalancer( $lb );
+
+ return $lb;
}
/**
}
$master = false;
} else {
- $serverInfo['slave'] = true;
+ $serverInfo['replica'] = true;
}
if ( isset( $this->templateOverridesByServer[$serverName] ) ) {
$serverInfo = $this->templateOverridesByServer[$serverName] + $serverInfo;