* Configuration:
* sectionsByDB A map of database names to section names
*
- * sectionLoads A 2-d map. For each section, gives a map of server names to load ratios.
- * For example: array( 'section1' => array( 'db1' => 100, 'db2' => 100 ) )
+ * sectionLoads A 2-d map. For each section, gives a map of server names to
+ * load ratios. For example:
+ * array(
+ * 'section1' => array(
+ * 'db1' => 100,
+ * 'db2' => 100
+ * )
+ * )
*
- * serverTemplate A server info associative array as documented for $wgDBservers. The host,
- * hostName and load entries will be overridden.
+ * serverTemplate A server info associative array as documented for $wgDBservers.
+ * The host, hostName and load entries will be overridden.
*
- * groupLoadsBySection A 3-d map giving server load ratios for each section and group. For example:
- * array( 'section1' => array( 'group1' => array( 'db1' => 100, 'db2' => 100 ) ) )
+ * groupLoadsBySection A 3-d map giving server load ratios for each section and group.
+ * For example:
+ * array(
+ * 'section1' => array(
+ * 'group1' => array(
+ * 'db1' => 100,
+ * 'db2' => 100
+ * )
+ * )
+ * )
*
* groupLoadsByDB A 3-d map giving server load ratios by DB name.
*
*
* externalLoads A map of external storage cluster name to server load map
*
- * externalTemplateOverrides A set of server info keys overriding serverTemplate for external storage
+ * externalTemplateOverrides A set of server info keys overriding serverTemplate for external
+ * storage
*
- * templateOverridesByServer A 2-d map overriding serverTemplate and externalTemplateOverrides on a
- * server-by-server basis. Applies to both core and external storage.
+ * templateOverridesByServer A 2-d map overriding serverTemplate and
+ * externalTemplateOverrides on a server-by-server basis. Applies
+ * to both core and external storage.
*
* templateOverridesByCluster A 2-d map overriding the server info by external storage cluster
*
* masterTemplateOverrides An override array for all master servers.
*
- * readOnlyBySection A map of section name to read-only message. Missing or false for read/write.
+ * readOnlyBySection A map of section name to read-only message.
+ * Missing or false for read/write.
*
* @ingroup Database
*/
}
$this->lastSection = $section;
$this->lastWiki = $wiki;
+
return $section;
}
if ( isset( $this->groupLoadsByDB[$dbName] ) ) {
$groupLoads = $this->groupLoadsByDB[$dbName];
}
+
if ( isset( $this->groupLoadsBySection[$section] ) ) {
$groupLoads = array_merge_recursive( $groupLoads, $this->groupLoadsBySection[$section] );
}
- return $this->newLoadBalancer( $this->serverTemplate, $this->sectionLoads[$section], $groupLoads );
+
+ return $this->newLoadBalancer(
+ $this->serverTemplate,
+ $this->sectionLoads[$section],
+ $groupLoads
+ );
}
/**
$section = $this->getSectionForWiki( $wiki );
if ( !isset( $this->mainLBs[$section] ) ) {
$lb = $this->newMainLB( $wiki, $section );
- $this->chronProt->initLB( $lb );
$lb->parentInfo( array( 'id' => "main-$section" ) );
+ $this->chronProt->initLB( $lb );
$this->mainLBs[$section] = $lb;
}
+
return $this->mainLBs[$section];
}
if ( isset( $this->templateOverridesByCluster[$cluster] ) ) {
$template = $this->templateOverridesByCluster[$cluster] + $template;
}
+
return $this->newLoadBalancer( $template, $this->externalLoads[$cluster], array() );
}
if ( !isset( $this->extLBs[$cluster] ) ) {
$this->extLBs[$cluster] = $this->newExternalLB( $cluster, $wiki );
$this->extLBs[$cluster]->parentInfo( array( 'id' => "ext-$cluster" ) );
+ $this->chronProt->initLB( $this->extLBs[$cluster] );
}
+
return $this->extLBs[$cluster];
}
$lb = new LoadBalancer( array(
'servers' => $servers,
'masterWaitTimeout' => $wgMasterWaitTimeout
- ));
+ ) );
+
return $lb;
}
$serverInfo['load'] = $load;
$servers[] = $serverInfo;
}
+
return $servers;
}
$reindexed[$server][$group] = $load;
}
}
+
return $reindexed;
}
function getDBNameAndPrefix( $wiki = false ) {
if ( $wiki === false ) {
global $wgDBname, $wgDBprefix;
+
return array( $wgDBname, $wgDBprefix );
} else {
return wfSplitWikiID( $wiki );
foreach ( $this->mainLBs as $lb ) {
$this->chronProt->shutdownLB( $lb );
}
+ foreach ( $this->extLBs as $extLB ) {
+ $this->chronProt->shutdownLB( $extLB );
+ }
$this->chronProt->shutdown();
$this->commitMasterChanges();
}