From: Aaron Schulz Date: Tue, 23 Jul 2019 00:05:40 +0000 (-0700) Subject: rdbms: update ILBFactory comments and simplify LoadBalancer "load" code a bit X-Git-Tag: 1.34.0-rc.0~791^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=0465a6dd04f7f96a6efffa0a35888fe78eab0d92;p=lhc%2Fweb%2Fwiklou.git rdbms: update ILBFactory comments and simplify LoadBalancer "load" code a bit Change-Id: I391a2f873c623b3086703a9b078def40363d9520 --- diff --git a/includes/libs/rdbms/lbfactory/ILBFactory.php b/includes/libs/rdbms/lbfactory/ILBFactory.php index 812064a772..4b6afe7089 100644 --- a/includes/libs/rdbms/lbfactory/ILBFactory.php +++ b/includes/libs/rdbms/lbfactory/ILBFactory.php @@ -31,9 +31,12 @@ use InvalidArgumentException; * @since 1.28 */ interface ILBFactory { + /** @var int Don't save DB positions at all */ const SHUTDOWN_NO_CHRONPROT = 0; // don't save DB positions at all - const SHUTDOWN_CHRONPROT_ASYNC = 1; // save DB positions, but don't wait on remote DCs - const SHUTDOWN_CHRONPROT_SYNC = 2; // save DB positions, waiting on all DCs + /** @var int Save DB positions, but don't wait on remote DCs */ + const SHUTDOWN_CHRONPROT_ASYNC = 1; + /** @var int Save DB positions, waiting on all DCs */ + const SHUTDOWN_CHRONPROT_SYNC = 2; /** * Construct a manager of ILoadBalancer objects @@ -140,6 +143,8 @@ interface ILBFactory { /** * Get cached (tracked) load balancers for all main database clusters * + * The default cluster name is ILoadBalancer::CLUSTER_MAIN_DEFAULT + * * @return ILoadBalancer[] Map of (cluster name => ILoadBalancer) * @since 1.29 */ @@ -154,7 +159,8 @@ interface ILBFactory { public function getAllExternalLBs(); /** - * Execute a function for each tracked load balancer + * Execute a function for each currently tracked (instantiated) load balancer + * * The callback is called with the load balancer as the first parameter, * and $params passed as the subsequent parameters. * @@ -164,7 +170,8 @@ interface ILBFactory { public function forEachLB( $callback, array $params = [] ); /** - * Prepare all tracked load balancers for shutdown + * Prepare all currently tracked (instantiated) load balancers for shutdown + * * @param int $mode One of the class SHUTDOWN_* constants * @param callable|null $workCallback Work to mask ChronologyProtector writes * @param int|null &$cpIndex Position key write counter for ChronologyProtector diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index 46d8c068ad..98607ce807 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -177,11 +177,10 @@ class LoadBalancer implements ILoadBalancer { $server['replica'] = true; } $this->servers[$i] = $server; - $serverGroupLoads = [ self::GROUP_GENERIC => $server['load'] ]; - $serverGroupLoads += ( $server['groupLoads'] ?? [] ); - foreach ( $serverGroupLoads as $group => $ratio ) { + foreach ( ( $server['groupLoads'] ?? [] ) as $group => $ratio ) { $this->groupLoads[$group][$i] = $ratio; } + $this->groupLoads[self::GROUP_GENERIC][$i] = $server['load']; } $localDomain = isset( $params['localDomain'] )