Introduce InterwikiLookupAdapter on top of SiteLookup
[lhc/web/wiklou.git] / includes / db / loadbalancer / LBFactorySimple.php
index 3702c8b..d8590b7 100644 (file)
@@ -54,7 +54,7 @@ class LBFactorySimple extends LBFactory {
                                if ( $i == 0 ) {
                                        $server['master'] = true;
                                } else {
-                                       $server['slave'] = true;
+                                       $server['replica'] = true;
                                }
                                $server += [ 'flags' => DBO_DEFAULT ];
                        }
@@ -95,7 +95,6 @@ class LBFactorySimple extends LBFactory {
        public function getMainLB( $wiki = false ) {
                if ( !isset( $this->mainLB ) ) {
                        $this->mainLB = $this->newMainLB( $wiki );
-                       $this->mainLB->parentInfo( [ 'id' => 'main' ] );
                        $this->chronProt->initLB( $this->mainLB );
                }
 
@@ -111,7 +110,7 @@ class LBFactorySimple extends LBFactory {
        protected function newExternalLB( $cluster, $wiki = false ) {
                global $wgExternalServers;
                if ( !isset( $wgExternalServers[$cluster] ) ) {
-                       throw new MWException( __METHOD__ . ": Unknown cluster \"$cluster\"" );
+                       throw new InvalidArgumentException( __METHOD__ . ": Unknown cluster \"$cluster\"" );
                }
 
                return $this->newLoadBalancer( $wgExternalServers[$cluster] );
@@ -122,10 +121,9 @@ class LBFactorySimple extends LBFactory {
         * @param bool|string $wiki
         * @return array
         */
-       public function &getExternalLB( $cluster, $wiki = false ) {
+       public function getExternalLB( $cluster, $wiki = false ) {
                if ( !isset( $this->extLBs[$cluster] ) ) {
                        $this->extLBs[$cluster] = $this->newExternalLB( $cluster, $wiki );
-                       $this->extLBs[$cluster]->parentInfo( [ 'id' => "ext-$cluster" ] );
                        $this->chronProt->initLB( $this->extLBs[$cluster] );
                }
 
@@ -133,14 +131,16 @@ class LBFactorySimple extends LBFactory {
        }
 
        private function newLoadBalancer( array $servers ) {
-               return new LoadBalancer( [
-                       'servers' => $servers,
-                       'loadMonitor' => $this->loadMonitorClass,
-                       'readOnlyReason' => $this->readOnlyReason,
-                       'trxProfiler' => $this->trxProfiler,
-                       'srvCache' => $this->srvCache,
-                       'wanCache' => $this->wanCache
-               ] );
+               $lb = new LoadBalancer( array_merge(
+                       $this->baseLoadBalancerParams(),
+                       [
+                               'servers' => $servers,
+                               'loadMonitor' => $this->loadMonitorClass,
+                       ]
+               ) );
+               $this->initLoadBalancer( $lb );
+
+               return $lb;
        }
 
        /**
@@ -159,11 +159,4 @@ class LBFactorySimple extends LBFactory {
                        call_user_func_array( $callback, array_merge( [ $lb ], $params ) );
                }
        }
-
-       public function shutdown( $flags = 0 ) {
-               if ( !( $flags & self::SHUTDOWN_NO_CHRONPROT ) ) {
-                       $this->shutdownChronologyProtector( $this->chronProt );
-               }
-               $this->commitMasterChanges( __METHOD__ ); // sanity
-       }
 }