/**
* A multi-wiki, multi-master factory for Wikimedia and similar installations.
- * Ignores the old configuration globals
+ * Ignores the old configuration globals.
+ *
+ * Template override precedence (highest => lowest):
+ * - templateOverridesByServer
+ * - masterTemplateOverrides
+ * - templateOverridesBySection/templateOverridesByCluster
+ * - externalTemplateOverrides
+ * - serverTemplate
+ * Overrides only work on top level keys (so nested values will not be merged).
*
* 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(
+ * [
+ * 'section1' => [
* 'db1' => 100,
* 'db2' => 100
- * )
- * )
+ * ]
+ * ]
*
* 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(
+ * [
+ * 'section1' => [
+ * 'group1' => [
* 'db1' => 100,
* 'db2' => 100
- * )
- * )
- * )
+ * ]
+ * ]
+ * ]
*
* groupLoadsByDB A 3-d map giving server load ratios by DB name.
*
* templateOverridesByServer A 2-d map overriding serverTemplate and
* externalTemplateOverrides on a server-by-server basis. Applies
* to both core and external storage.
- *
+ * templateOverridesBySection A 2-d map overriding the server info by section.
* templateOverridesByCluster A 2-d map overriding the server info by external storage cluster.
*
* masterTemplateOverrides An override array for all master servers.
*/
private $templateOverridesByServer;
+ /** @var array A 2-d map overriding the server info by section */
+ private $templateOverridesBySection;
+
/** @var array A 2-d map overriding the server info by external storage cluster */
private $templateOverridesByCluster;
$required = [ 'sectionsByDB', 'sectionLoads', 'serverTemplate' ];
$optional = [ 'groupLoadsBySection', 'groupLoadsByDB', 'hostsByName',
'externalLoads', 'externalTemplateOverrides', 'templateOverridesByServer',
- 'templateOverridesByCluster', 'masterTemplateOverrides',
+ 'templateOverridesByCluster', 'templateOverridesBySection', 'masterTemplateOverrides',
'readOnlyBySection', 'loadMonitorClass' ];
foreach ( $required as $key ) {
$readOnlyReason = $this->readOnlyBySection[$section];
}
+ $template = $this->serverTemplate;
+ if ( isset( $this->templateOverridesBySection[$section] ) ) {
+ $template = $this->templateOverridesBySection[$section] + $template;
+ }
+
return $this->newLoadBalancer(
- $this->serverTemplate,
+ $template,
$this->sectionLoads[$section],
$groupLoads,
$readOnlyReason
'servers' => $this->makeServerArray( $template, $loads, $groupLoads ),
'loadMonitor' => $this->loadMonitorClass,
'readOnlyReason' => $readOnlyReason,
- 'trxProfiler' => $this->trxProfiler
+ 'trxProfiler' => $this->trxProfiler,
+ 'srvCache' => $this->srvCache,
+ 'wanCache' => $this->wanCache
] );
}
}
$serverInfo['hostName'] = $serverName;
$serverInfo['load'] = $load;
+ $serverInfo += [ 'flags' => DBO_DEFAULT ];
+
$servers[] = $serverInfo;
}