* readOnlyBySection A map of section name to read-only message.
* Missing or false for read/write.
*
* @ingroup Database
*/
class LBFactoryMulti extends LBFactory {
* readOnlyBySection A map of section name to read-only message.
* Missing or false for read/write.
*
* @ingroup Database
*/
class LBFactoryMulti extends LBFactory {
$this->conf = $conf;
$required = array( 'sectionsByDB', 'sectionLoads', 'serverTemplate' );
$optional = array( 'groupLoadsBySection', 'groupLoadsByDB', 'hostsByName',
'externalLoads', 'externalTemplateOverrides', 'templateOverridesByServer',
'templateOverridesByCluster', 'masterTemplateOverrides',
$this->conf = $conf;
$required = array( 'sectionsByDB', 'sectionLoads', 'serverTemplate' );
$optional = array( 'groupLoadsBySection', 'groupLoadsByDB', 'hostsByName',
'externalLoads', 'externalTemplateOverrides', 'templateOverridesByServer',
'templateOverridesByCluster', 'masterTemplateOverrides',
public function newMainLB( $wiki = false ) {
list( $dbName, ) = $this->getDBNameAndPrefix( $wiki );
$section = $this->getSectionForWiki( $wiki );
public function newMainLB( $wiki = false ) {
list( $dbName, ) = $this->getDBNameAndPrefix( $wiki );
$section = $this->getSectionForWiki( $wiki );
}
if ( isset( $this->groupLoadsBySection[$section] ) ) {
$groupLoads = array_merge_recursive( $groupLoads, $this->groupLoadsBySection[$section] );
}
}
if ( isset( $this->groupLoadsBySection[$section] ) ) {
$groupLoads = array_merge_recursive( $groupLoads, $this->groupLoadsBySection[$section] );
}
+ $readOnlyReason = $this->readOnlyReason;
+ // Use the LB-specific read-only reason if everything isn't already read-only
+ if ( $readOnlyReason === false && isset( $this->readOnlyBySection[$section] ) ) {
+ $readOnlyReason = $this->readOnlyBySection[$section];
+ }
+
return $this->newLoadBalancer(
$this->serverTemplate,
$this->sectionLoads[$section],
return $this->newLoadBalancer(
$this->serverTemplate,
$this->sectionLoads[$section],
- return $this->newLoadBalancer( $template, $this->externalLoads[$cluster], array() );
+ return $this->newLoadBalancer(
+ $template,
+ $this->externalLoads[$cluster],
+ array(),
+ $this->readOnlyReason
+ );
- private function newLoadBalancer( $template, $loads, $groupLoads ) {
- $servers = $this->makeServerArray( $template, $loads, $groupLoads );
- $lb = new LoadBalancer( array(
- 'servers' => $servers,
+ private function newLoadBalancer( $template, $loads, $groupLoads, $readOnlyReason ) {
+ return new LoadBalancer( array(
+ 'servers' => $this->makeServerArray( $template, $loads, $groupLoads ),
+ 'loadMonitor' => $this->loadMonitorClass,
+ 'readOnlyReason' => $readOnlyReason
}
if ( isset( $this->templateOverridesByServer[$serverName] ) ) {
$serverInfo = $this->templateOverridesByServer[$serverName] + $serverInfo;
}
if ( isset( $this->templateOverridesByServer[$serverName] ) ) {
$serverInfo = $this->templateOverridesByServer[$serverName] + $serverInfo;
- public function shutdown() {
- foreach ( $this->mainLBs as $lb ) {
- $this->chronProt->shutdownLB( $lb );
- }
- foreach ( $this->extLBs as $extLB ) {
- $this->chronProt->shutdownLB( $extLB );
+ public function shutdown( $flags = 0 ) {
+ if ( !( $flags & self::SHUTDOWN_NO_CHRONPROT ) ) {
+ $this->shutdownChronologyProtector( $this->chronProt );