(bug 47070) check content model namespace on import.
[lhc/web/wiklou.git] / includes / db / LBFactory_Multi.php
index 2e4963d..a37a560 100644 (file)
  * 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
  */
@@ -117,6 +134,7 @@ class LBFactory_Multi extends LBFactory {
                }
                $this->lastSection = $section;
                $this->lastWiki = $wiki;
+
                return $section;
        }
 
@@ -131,10 +149,16 @@ class LBFactory_Multi extends LBFactory {
                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
+               );
        }
 
        /**
@@ -145,10 +169,11 @@ class LBFactory_Multi extends LBFactory {
                $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];
        }
 
@@ -169,6 +194,7 @@ class LBFactory_Multi extends LBFactory {
                if ( isset( $this->templateOverridesByCluster[$cluster] ) ) {
                        $template = $this->templateOverridesByCluster[$cluster] + $template;
                }
+
                return $this->newLoadBalancer( $template, $this->externalLoads[$cluster], array() );
        }
 
@@ -181,7 +207,9 @@ class LBFactory_Multi extends LBFactory {
                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];
        }
 
@@ -199,7 +227,8 @@ class LBFactory_Multi extends LBFactory {
                $lb = new LoadBalancer( array(
                        'servers' => $servers,
                        'masterWaitTimeout' => $wgMasterWaitTimeout
-               ));
+               ) );
+
                return $lb;
        }
 
@@ -244,6 +273,7 @@ class LBFactory_Multi extends LBFactory {
                        $serverInfo['load'] = $load;
                        $servers[] = $serverInfo;
                }
+
                return $servers;
        }
 
@@ -259,6 +289,7 @@ class LBFactory_Multi extends LBFactory {
                                $reindexed[$server][$group] = $load;
                        }
                }
+
                return $reindexed;
        }
 
@@ -270,6 +301,7 @@ class LBFactory_Multi extends LBFactory {
        function getDBNameAndPrefix( $wiki = false ) {
                if ( $wiki === false ) {
                        global $wgDBname, $wgDBprefix;
+
                        return array( $wgDBname, $wgDBprefix );
                } else {
                        return wfSplitWikiID( $wiki );
@@ -296,6 +328,9 @@ class LBFactory_Multi extends LBFactory {
                foreach ( $this->mainLBs as $lb ) {
                        $this->chronProt->shutdownLB( $lb );
                }
+               foreach ( $this->extLBs as $extLB ) {
+                       $this->chronProt->shutdownLB( $extLB );
+               }
                $this->chronProt->shutdown();
                $this->commitMasterChanges();
        }