X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdb%2Floadbalancer%2FLBFactorySimple.php;h=1c9e094469123bd330a3f2e74079c6262b1e0609;hb=1af6474a6ea3b77268f3af097894061286d61f80;hp=23cdbc635031d53e71b3569bec3f2ca96846b896;hpb=b4abac8fff280d6f12f5b6a1a681d13b2eea8e78;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/db/loadbalancer/LBFactorySimple.php b/includes/db/loadbalancer/LBFactorySimple.php index 23cdbc6350..1c9e094469 100644 --- a/includes/db/loadbalancer/LBFactorySimple.php +++ b/includes/db/loadbalancer/LBFactorySimple.php @@ -27,15 +27,18 @@ class LBFactorySimple extends LBFactory { /** @var LoadBalancer */ private $mainLB; - /** @var LoadBalancer[] */ private $extLBs = array(); - /** @var ChronologyProtector */ - private $chronProt; + /** @var string */ + private $loadMonitorClass; public function __construct( array $conf ) { - $this->chronProt = new ChronologyProtector; + parent::__construct( $conf ); + + $this->loadMonitorClass = isset( $conf['loadMonitorClass'] ) + ? $conf['loadMonitorClass'] + : null; } /** @@ -44,8 +47,16 @@ class LBFactorySimple extends LBFactory { */ public function newMainLB( $wiki = false ) { global $wgDBservers; - if ( $wgDBservers ) { + + if ( is_array( $wgDBservers ) ) { $servers = $wgDBservers; + foreach ( $servers as $i => &$server ) { + if ( $i == 0 ) { + $server['master'] = true; + } else { + $server['slave'] = true; + } + } } else { global $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, $wgDBtype, $wgDebugDumpSql; global $wgDBssl, $wgDBcompress; @@ -68,12 +79,15 @@ class LBFactorySimple extends LBFactory { 'dbname' => $wgDBname, 'type' => $wgDBtype, 'load' => 1, - 'flags' => $flags + 'flags' => $flags, + 'master' => true ) ); } return new LoadBalancer( array( 'servers' => $servers, + 'loadMonitor' => $this->loadMonitorClass, + 'readOnlyReason' => $this->readOnlyReason ) ); } @@ -104,7 +118,9 @@ class LBFactorySimple extends LBFactory { } return new LoadBalancer( array( - 'servers' => $wgExternalServers[$cluster] + 'servers' => $wgExternalServers[$cluster], + 'loadMonitor' => $this->loadMonitorClass, + 'readOnlyReason' => $this->readOnlyReason ) ); } @@ -140,14 +156,10 @@ class LBFactorySimple extends LBFactory { } } - public function shutdown() { - if ( $this->mainLB ) { - $this->chronProt->shutdownLB( $this->mainLB ); - } - foreach ( $this->extLBs as $extLB ) { - $this->chronProt->shutdownLB( $extLB ); + public function shutdown( $flags = 0 ) { + if ( !( $flags & self::SHUTDOWN_NO_CHRONPROT ) ) { + $this->shutdownChronologyProtector( $this->chronProt ); } - $this->chronProt->shutdown(); - $this->commitMasterChanges(); + $this->commitMasterChanges(); // sanity } }