private $masterTemplateOverrides = [];
/** @var array[] Map of (host => server config map overrides) for main and external servers */
private $templateOverridesByServer = [];
- /** @var string[]|bool[] A map of section name to read-only message */
+ /** @var string[]|bool[] A map of section name to read-only message */
private $readOnlyBySection = [];
/** @var string An ILoadMonitor class */
* data can be before the load balancer tries to avoid using it. The map can have 'is static'
* set to disable blocking replication sync checks (intended for archive servers with
* unchanging data).
-
+ *
* @see LBFactory::__construct()
* @param array $conf Additional parameters include:
* - hostsByName Optional (hostname => IP address) map.
$this->loadMonitorClass = $conf['loadMonitorClass'] ?? LoadMonitor::class;
}
- public function newMainLB( $domain = false ) {
+ public function newMainLB( $domain = false, $owner = null ) {
$section = $this->getSectionForDomain( $domain );
if ( !isset( $this->groupLoadsBySection[$section][ILoadBalancer::GROUP_GENERIC] ) ) {
throw new UnexpectedValueException( "Section '$section' has no hosts defined." );
// Use the LB-specific read-only reason if everything isn't already read-only
is_string( $this->readOnlyReason )
? $this->readOnlyReason
- : ( $this->readOnlyBySection[$section] ?? false )
+ : ( $this->readOnlyBySection[$section] ?? false ),
+ $owner
);
}
$section = $this->getSectionForDomain( $domain );
if ( !isset( $this->mainLBs[$section] ) ) {
- $this->mainLBs[$section] = $this->newMainLB( $domain );
+ $this->mainLBs[$section] = $this->newMainLB( $domain, $this->getOwnershipId() );
}
return $this->mainLBs[$section];
}
- public function newExternalLB( $cluster ) {
+ public function newExternalLB( $cluster, $owner = null ) {
if ( !isset( $this->externalLoads[$cluster] ) ) {
throw new InvalidArgumentException( "Unknown cluster '$cluster'" );
}
$this->templateOverridesByCluster[$cluster] ?? []
),
[ ILoadBalancer::GROUP_GENERIC => $this->externalLoads[$cluster] ],
- $this->readOnlyReason
+ $this->readOnlyReason,
+ $owner
);
}
public function getExternalLB( $cluster ) {
if ( !isset( $this->externalLBs[$cluster] ) ) {
- $this->externalLBs[$cluster] = $this->newExternalLB( $cluster );
+ $this->externalLBs[$cluster] =
+ $this->newExternalLB( $cluster, $this->getOwnershipId() );
}
return $this->externalLBs[$cluster];
* @param array $serverTemplate Server config map
* @param int[][] $groupLoads Map of (group => host => load)
* @param string|bool $readOnlyReason
+ * @param int|null $owner
* @return LoadBalancer
*/
- private function newLoadBalancer( $serverTemplate, $groupLoads, $readOnlyReason ) {
+ private function newLoadBalancer( $serverTemplate, $groupLoads, $readOnlyReason, $owner ) {
$lb = new LoadBalancer( array_merge(
- $this->baseLoadBalancerParams(),
+ $this->baseLoadBalancerParams( $owner ),
[
'servers' => $this->makeServerArray( $serverTemplate, $groupLoads ),
'loadMonitor' => [ 'class' => $this->loadMonitorClass ],